It's getting frustrating. I've been trying to get a simple hello world type program to run, but it just isn't happening.
I'm using Windows 7 and my graphics card does support the newer OpenGL stuff. Writing in C with freeglut, and I am compiling with MinGW and Code::Blocks. In the linker I have freeglut, opengl32 and glu32. I keep the freeglut stuff in the freeglut folder that is located in my MinGW folder, so under search directories in my build settings I have "C:\MinGW\freeglut\include" for the compiler and "C:\MinGW\freeglut\lib" for the linker.
Here's my code:
#include <stdlib.h>
#include <GL/glut.h>
void NIAppIdle(void);
void NIAppDisplay(void);
int main(int argc, char *argv[])
{
// Setup windwing
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
glutInitWindowSize(800, 600);
glutCreateWindow("HELLO WORLD");
// Define GLUT callbacks
glutIdleFunc(NIAppIdle);
glutDisplayFunc(NIAppDisplay);
// Enter render loop
glutMainLoop();
return 0;
}
void NIAppIdle(void)
{
glutPostRedisplay();
}
void NIAppDisplay(void)
{
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
float geometry[] =
{
-0.5f, 0.5f, 0.0f, 1.0f,
0.5f, -5.0f, 0.0f, 1.0f,
0.0f, 0.5f, 0.0f, 1.0f
};
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, 0, 0, geometry);
glDrawArrays(GL_TRIANGLES, 0, 3);
glutSwapBuffers();
}
The problem is with the "glEnableVertexAttribArray" and "glVertexAttribPointer" functions. The compiler says that they are "not declared it this scope".
Program can run without those lines, so I guess OpenGL is linked properly, but I simply can't use those functions for some reason, and I know they are a part of OpenGL. Is it something to do with the version of OpenGL I have or something?
Anyway, it is my first time learning OpenGL, I've probably done something horribly wrong, so I'm asking for somebody to help me. I'm sorry if this post seems a bit crappy, this is also my first time posting in this site. Also I'm sorry for my grammar, English isn't my first language.
I think you can only get to glEnableVertexAttribArray by manually loading the function pointer for it. If all you want to do is create a simple hello world program, I'd recommend you use GLEW to handle that for you.