Reputation: 79
i am just starting with simple OpenGL/GLSL programming and running into a mistake. I want to build a struct for my data that i use. I would like to save parts of it in vec3 or vec4 etc. But i always get the Error vec3/vec2 not defined. What am i missing here? Help would be appreciated. Following a little bit of the example where i get the error.
#include <Windows.h>
#include <GL\glew.h>
#include <GL\freeglut.h>
#include <iostream>
#include <fstream>
using namespace std;
int windowWidth = 1280;
int windowHeight = 800;
int windowStartX = 100;
int windowStartY = 25;
struct HairData {
vec3 position;
vec2 uv;
};
void render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Left window
glViewport(0,0,windowWidth/2,windowHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, windowWidth / 2, windowHeight, 0);
glScissor(0, 0, windowWidth / 2, windowHeight);
// Right window
glViewport(windowWidth / 2, 0, windowWidth, windowHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLfloat)(windowWidth) / (GLfloat)(windowHeight), 0.1f, 500.0);
glutSwapBuffers();
}
int main(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitWindowPosition(windowStartX, windowStartY);
glutInitWindowSize(windowWidth, windowHeight);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Simple Hair Program");
glEnable(GL_SCISSOR_TEST);
glutDisplayFunc(render);
glutMainLoop();
return 0;
}
`
Upvotes: 0
Views: 3499
Reputation: 369
vec3 is only available in GLSL, i.e. in shaders, not in the CPU code.
To replace it, you can define your own datatypes or use a library like GLM that defines similar datatypes.
Upvotes: 2