Note that there are some explanatory texts on larger screens.

plurals
  1. POSDL/OpenGL commands not set in scope?
    primarykey
    data
    text
    <p>I'm trying to write a very simple sdl and gl program on a mac to create a triangle, but its not really working.</p> <p>(in c++)</p> <pre><code>#include &lt;iostream&gt; #include "SDL/SDL.h" #include &lt;OpenGL/gl.h&gt; #include &lt;OpenGL/glu.h&gt; /*INITIALIZE*/ void init() { glClearColor(0.0,0.0,0.0,1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,640.0/480.0,1.0,500.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } /*DISPLAY*/ void display() // drawing { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); glVertex3f(0.0,2.0,-5.0); glVertex3f(-2.0,-2.0,-5.0); glVertex3f(2.0,-2.0,-5.0); glEnd(); } /*MAIN*/ int main(int argc, char** argv) // arguments required { SDL_Init(SDL_INIT_EVERYTHING); // initialize and setup sdl SDL_Surface* screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE|SDL_OPENGL); bool running = true; Uint32 start; SDL_Event event; init(); while (running) { start = SDL_GetTicks(); while (SDL_PollEvent(&amp;event)) { switch (event.type) { case SDL_QUIT: running = false; break; } } display(); SDL_GL_SwapBuffers(); if(1000/30 &gt; (SDL_GetTicks() - start)) SDL_Delay(1000/30 - (SDL_GetTicks() - start)); } SDL_Quit(); return 0; } </code></pre> <p>But when I compile it:</p> <pre><code>Computer:sdlcode User$ g++ third.cpp -GL -GLU third.cpp: In function ‘int main(int, char**)’: third.cpp:34: error: ‘SDL_OPENGL’ was not declared in this scope third.cpp:34: error: ‘SDL_SetVideoMode’ was not declared in this scope third.cpp:55: error: ‘SDL_GL_SwapBuffers’ was not declared in this scope Computer:sdlcode User$ </code></pre> <p>Whats going wrong here and how do I prevent it from having further commands undeclared?</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