How to create and initialize a SDL 2.0 window to support 3D rendering with OpenGL 3.0+? -
i new sdl , trying use version 2.0. believe in previouse versions of sdl (1.2 , 1.3) creating window done sdl_setvideomode
, has since been droped source. how create window rendering 3d opengl 3.0+ sdl 2.0? (with programmable pipeline of course)
my first gess sdl_creatwindow
sdl_getwindowsurface
sdl_createrenderer
code below:
sdl_window* window = sdl_createwindow(title, x, y, w, h, sdl_window_shown | sdl_window_opengl); sdl_surface* s = sdl_getwindowsurface(window); sdl_renderer* renderer = sdl_createrenderer(window, -1, flags); sdl_setrenderdrawcolor(renderer, 0xff, 0xff, 0xff, 0xff);
however, documentation on sdl_getwindowsurface
says cannot used "3d or rendering api on window" source.
is there other way render 3d opengl 3.0+ in sdl 2.0, or should use sdl 1.2 because sdl 2.0 in release candidate status?
try using sdl_gl_setattribute()
before create window:
sdl_gl_setattribute( sdl_gl_context_major_version, 3 ); sdl_gl_setattribute( sdl_gl_context_minor_version, 2 ); //sdl_gl_setattribute( sdl_gl_context_profile_mask, sdl_gl_context_profile_core ); sdl_window* window = sdl_createwindow( ... ); sdl_glcontext ctx = sdl_gl_createcontext( window ); sdl_gl_makecurrent( window, ctx ); glewexperimental = true; glewinit(); ...
though wouldn't use sdl_renderer
stuff if create core context.
Comments
Post a Comment