SDL2 with OpenGL ? weird results, what's wrong? (stevo5800

Heres your problem notice I comment out the surface = SDL_Get… it was giving some weird results. Also you forgot to create the OpenGL context. Let me know if you have any other issues.

SDLWindow::SDLWindow(int width, int height, double axisLen, const std::string &caption)
:m_fov(axisLen)
,m_width(0)
,m_height(0)
,m_fps(0)
,m_idxSnapshot(0)
,m_camPos(0, 0, 2)
,m_camLookAt(0, 0, 0)
,m_camOrient(0, 1, 0)
,surface(NULL)
,m_texStar(0)
,m_bRunning(true)
{
SDL_GLContext ctx;

if (SDL_Init(SDL_INIT_VIDEO) < 0)
    throw std::runtime_error(SDL_GetError());
atexit(SDL_Quit);

SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 0 );
SDL_GL_SetAttribute( SDL_GL_RETAINED_BACKING, 1 ); 

if ((window = SDL_CreateWindow(caption.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                               width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS)) == NULL)
    throw std::runtime_error(SDL_GetError());     

/*if ((surface = SDL_GetWindowSurface(window)) == NULL)
    throw std::runtime_error(SDL_GetError());*/

m_width = width;
m_height = height;

//create OpenGL context
ctx = SDL_GL_CreateContext(window);

InitGL();

}

Berenyi Gabor wrote:> Thanks for taking a look.

The screenshot come from OS X, so you need to replace the iOS project file with the OS X project file that is located in the?“desktop OS X stuff” directory.
The middle and the last pictures use SDL2 instead of the original SDL – all on OS X. The last image uses a pre-alpha quality non-standard OpenGL library that they advertise as compatible with GLES.
The black screen on iOS problem is a separate issue that I addressed in another SO question here:?http://stackoverflow.com/questions/13231805/gl-arb-point-sprite-porting-to-ios-gles-v1 (it explains that I use a GLES compatibility library that is supposed to take care of glBegin/glEnd stuff)

----------------------------------------------------------------------Message: 1Date: Wed, 07 Nov 2012 08:25:06 -0800From: “stevo5800” <@stevo5800 (@stevo5800)>To: sdl at lists.libsdl.org (sdl at lists.libsdl.org)Subject: Re: [SDL] SDL2 with OpenGL ??? weird results, what’s wrong?Message-ID: <1352305505.m2f.34758 at forums.libsdl.org (1352305505.m2f.34758 at forums.libsdl.org)>Content-Type: text/plain; charset="iso-8859-1"The middle and last picture where taken from what platform? ?I download the code from a link on the stackexchange page and all I get is a black screen. Middle image seems like it’s missing a lot and the last image sees that it’s only missing textures. After looking at the code I realize that you are calling calls that are not compatible with OpenGL ES. You are using glBegin(…); glEnd(); witch are not available on mobile devices. You will need to use VBO’s or Vertex Arrays for all drawing to the screen. Berenyi Gabor wrote:

?Please reply to my issue here:?http://gamedev.stackexchange.com/questions/40249/sdl2-with-opengl-weird-results-whats-wrong (http://gamedev.stackexchange.com/questions/40249/sdl2-with-opengl-weird-results-whats-wrong)

?