Note that there are some explanatory texts on larger screens.

plurals
  1. POHello World OpenGL program: "glEnableVertexAttribArray was not declared it this scope"
    primarykey
    data
    text
    <p>It's getting frustrating. I've been trying to get a simple hello world type program to run, but it just isn't happening.</p> <p>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.</p> <p>Here's my code:</p> <pre><code>#include &lt;stdlib.h&gt; #include &lt;GL/glut.h&gt; void NIAppIdle(void); void NIAppDisplay(void); int main(int argc, char *argv[]) { // Setup windwing glutInit(&amp;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(); } </code></pre> <p>The problem is with the "glEnableVertexAttribArray" and "glVertexAttribPointer" functions. The compiler says that they are "not declared it this scope".</p> <p>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?</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload