Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm porting an app to iOS, and therefore need to upgrade it to SDL2 from SDL1.2 (so far I'm testing it as an on OS X desktop app only). However, when running the code with SDL2, I'm getting weird results as shown on the second image below (the first image is how it looks with SDL, correctly). The single changeset that causes this is this one, do you see something obviously wrong there, or does SDL2 have some OpenGL nuances I'm unaware of? My SDL is based on the latest from HG.

Update: another question about the iOS port of the same project is here.

Update 2: this is now also on the SDL newsgroup: http://thread.gmane.org/gmane.comp.lib.sdl/58026

Update 3: I tried using Regal for portable OpenGL, the not-so-good result is on the third screenshot, produced merely by replacing

#include <OpenGL/gl.h>
#include <OpenGL/glu.h>


#include "GL/Regal.h"
#include "GL/RegalGLU.h"

using SDL 1.2 using SDL 2 using Regal with SDL 2

share|improve this question
Is it possible that (for whatever reason) the sprites/particles are simply rotated ~90°, or stretched to very thin rectangles? A wireframe view should let you check that quickly. –  melak47 Oct 19 '12 at 11:06
According to the changeset you linked, you're rendering using glCallLists(), which is not supported under OpenGL ES (which is what you'll be using under iOS). (I'm kind of surprised that it doesn't give you compile errors on iOS, to be honest.) –  Trevor Powell Oct 19 '12 at 11:36
the screenshots were coming from OS X, the iOS porting came after that (an glCallLists was only used for text rendering which was linux specific so I was not using it even on OS X) –  Gabor Oct 26 '12 at 9:45

1 Answer 1

up vote 5 down vote accepted

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_camPos(0, 0, 2)
,m_camLookAt(0, 0, 0)
,m_camOrient(0, 1, 0)
SDL_GLContext ctx;

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

SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 0 );

 if ((window = SDL_CreateWindow(caption.c_str(), SDL_WINDOWPOS_CENTERED,
    throw std::runtime_error(SDL_GetError());     

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

m_width = width;
m_height = height;

ctx = SDL_GL_CreateContext(window);

share|improve this answer
wow, it works like a charm, thanks a lot! –  Gabor Nov 8 '12 at 15:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.