1
\$\begingroup\$

I've started to do sth. with SDL/openGL, but I haven't managed to get this tutorial running yet (http://www.sdltutorials.com/sdl-opengl-tutorial-basics).

Since this tutorial, or most tutorials at all, are written in SDL 1.2, I changed just this part of the tutorial's code:

instead of:

if((Surf_Display = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL)

to:

SDL_Window *window;
if((window = SDL_CreateWindow("SDLWindow", SDL_WINDOWPOS_UNDEFINED,
                              SDL_WINDOWPOS_UNDEFINED,
                              640, 480,
                              SDL_GL_DOUBLEBUFFER | SDL_WINDOW_OPENGL)) == NULL)

Now, all parts of the code seem to be correctly except the last one, this is "SDL_GL_SwapBuffers()";

Xcode says: use of undeclared identifier....

I think it's deprecated in SDL 2.0, but I couldn't find the right function in the migration guide, or is the problem something else?

Can anyone help me with that?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The new function is SDL_GL_SwapWindow() and it takes your window pointer.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ I already tried SDL_GL_SwapWindow(pointer), but it does exactly the same like without this function: instead of a sdl window with that simple graphic, i got an enlarged view on a part of the XCode GUI(like 300 %), no keyboard input is possible and so i have restart my mac completely by pushing the on/off button... \$\endgroup\$
    – reynmar
    Jan 18, 2015 at 16:37
  • \$\begingroup\$ Have you acquired an OpenGL context yet using SDL_GL_CreateContext(window)? \$\endgroup\$
    – jmegaffin
    Jan 18, 2015 at 16:55
  • \$\begingroup\$ No I did not...Actually i was under the impression, SDL_createWindow() provides this functionality and in this tutorial, there is no usage of SDL_GL_CreateContext(window) . However I have tried so, if i put this function before SDL_GL_CreateContext(window), there is no difference in behavior, if i put it after, i get the enlarged view of Xcode but after a second, it moves away and I get a full black screen. Really weird and frustrating....... \$\endgroup\$
    – reynmar
    Jan 18, 2015 at 17:41
  • \$\begingroup\$ >> "i got an enlarged view on a part of the XCode GUI(like 300 %)" << That's good! It is probably your OpenGL backing buffer, but you haven't drawn anything into it. (It has a different app's contents still sitting in it.) I think you're ready to do glClearColor() and glClear(). Do a clear, a swap, a clear, and a swap, all at once if you like, just to check that theory. \$\endgroup\$ Jan 18, 2015 at 18:49
  • \$\begingroup\$ Okay, I'm not familiar with developing on OSX so I wasn't sure if that was a problem. In SDL you need to explicitly tell the application to handle input events so that your window is responsive. You can do this with a call to SDL_QuitRequested(), SDL_PumpEvents() or with SDL_PollEvent() in a loop. \$\endgroup\$
    – jmegaffin
    Jan 19, 2015 at 0:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .