Convert SDL commands to OpenGL

Started by
3 comments, last by Shaarigan 4 years ago

HI

how would those sdl commands look in OpenGL?

Many thanks

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);

SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);

SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);

SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, kStencilBits);

SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);

SDL_GL_SwapWindow(window);

SDL_GL_DeleteContext(glContext);

Advertisement

These commands don't have an equivalent in OpenGL. OpenGL provides commands for drawing to an OpenGL context, but creating that context is outside of the domain of the OpenGL standard. There are several different platform-dependent ways of setting up an OpenGL context, and SDL provides a wrapper around these different methods to provide a single clean cross-platform API.

Nevermind, your right, it's the context. Even at a lower level of xcb/xlib in my case.

One can create one's own objects (framebuffers with depth and colour attachments) but in the end everything lands in the default buffer.

MikeCyber said:
how would those sdl commands look in OpenGL

One tip you should every try first before asking such things:

  • Read the docs
  • Read the source code if available
  • Set a breakpoint in your favourite IDE and follow the function step by step to se what's going on under the hood

You'll learn more on debugging and understanding running code than let someone else explain how it works

This topic is closed to new replies.

Advertisement