SDL 1.2x to SDL2 - need some help with OpenGL

someone had started to port Exult to SDL2 and it is somewhat working except for our OpenGL scaler. That guy stopped working on it and I wondered if you could help me moving on with this.
The problem is in (it’s a mirror - our SVN is on SF and that is just now down)
beginning with line 766:

// Get info. about video.
const SDL_VideoInfo *vinfo = SDL_GetVideoInfo();
if (!vinfo) {
cout << "SDL_GetVideoInfo() failed: " << SDL_GetError()
<< endl;
return false;
// Set up SDL video flags.
int video_flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER |
(fullscreen ? SDL_FULLSCREEN : 0);
// Can surface be in video RAM?
if (vinfo->hw_available)
video_flags |= SDL_HWSURFACE;
video_flags |= SDL_SWSURFACE;
if (vinfo->blit_hw) // Hardware blits?
video_flags |= SDL_HWACCEL;
// Want double-buffering.
// Allocate surface.
int hwdepth = vinfo->vfmt->BitsPerPixel;
// +++++For now create 8-bit surface
// to avoid crashing places we
// haven’t converted yet.
if ((display_surface = inter_surface = SDL_SetVideoMode(w, h,
hwdepth, video_flags)) != 0 &&
(draw_surface = paletted_surface = SDL_CreateRGBSurface(
SDL_SWSURFACE, w / scale, h / scale,
8, 0, 0, 0, 0)) != 0) {
inter_width = w;
inter_height = h;
game_width = draw_surface->w;
game_height = draw_surface->h;
//show_scaled = &Image_window::show_scaledOpenGL;
return true;
} else {
cerr << "Couldn’t allocate surface: " << SDL_GetError() << endl;
cerr << “OpenGL not supported” << endl;


The errors I get start of course with SDL_VideoInfo etc…

Code: error: unknown type name 'SDL_VideoInfo’
const SDL_VideoInfo *vinfo = SDL_GetVideoInfo();
^ error: use of undeclared identifier 'SDL_GetVideoInfo’
const SDL_VideoInfo *vinfo = SDL_GetVideoInfo();
^ error: use of undeclared identifier 'SDL_OPENGL’
int video_flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER |
^ error: use of undeclared identifier 'SDL_RESIZABLE’
^ error: use of undeclared identifier 'SDL_HWSURFACE’
video_flags |= SDL_HWSURFACE;
^ error: use of undeclared identifier 'SDL_HWACCEL’
video_flags |= SDL_HWACCEL;
^ error: use of undeclared identifier 'SDL_SetVideoMode’
if ((display_surface = inter_surface = SDL_SetVideoMode(w, h

I saw the migration guide but my limited coding skills left me without any clue.

Can anyone help me out there?
Thanks and take care!

Thanks a lot. With this it at least compiled.
Crashes now with a segmentation fault when I choose the OpenGL scaler :slight_smile:

I’ll see if I can find out more. Your post gave me a big starting point!

Your game is 2D? That makes some of what I saw make more sense now.

SDL does OpenGL for you using its renderer. And Direct3D too. You
don’t have to touch OpenGL for it to work.

JosephOn Sat, Jan 10, 2015 at 10:10:08AM +0000, Dominus wrote:

hmm, with your changes it tries to create a new window instead of using the existing one.
The big problem is how we did the OpenGL thing. We implemented it as a scaler, instead of as a renderer and that’s probably just biting us in the behind now :slight_smile:


If you were using OpenGL for scaling in the way that I?m thinking, i.e.: a small resolution like 384x224 upscaled to something more modern like 768x448 (x2) or 1152x672 (x3), you might be interested in knowing that SDL_RenderSetLogicalSize and SDL_RenderSetScale can help accomplish much the same. I did so myself when moving my game from SDL1 to SDL2.

I set the logical size to the original resolution used in the game (384x224), with a scale factor of 2, 2 (x2) or 3, 3 (x3) with a window size to match whatever the result of the original resolution multiplied by the scale factor is.

In addition, I explicitly set the renderer’s scale quality to “nearest”, instead of “linear” (anti-aliasing), and load the pre-scaled images of the appropriate scale factor into memory for use by the applicable game assets. This step can be skipped or tweaked further, depending on how picky you are on preserving the original image quality. In my case, this was preserving the scale2x filtering (of which I had the option of doing at run-time, or from disk).

Jeffrey Carpenter <@Jeffrey_Carpenter>

-------------- next part --------------
A non-text attachment was scrubbed…
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1572 bytes
Desc: not available