SDL 1.2x to SDL2 - need some help with OpenGL |
Dominus
|
Hi,
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 https://github.com/rofl0r/exult/blob/master/imagewin/imagewin.cc (it's a mirror - our SVN is on SF and that is just now down) beginning with line 766:
The errors I get start of course with SDL_VideoInfo etc...
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! |
|||||||||||||||
|
SDL 1.2x to SDL2 - need some help with OpenGL |
Joseph Carter
|
On Fri, Jan 09, 2015 at 11:21:47PM +0000, Dominus wrote:
Email's a poor compiler, but I'll see if I can give you a push in the right direction…
This you can keep. :D
Obviously this function no longer exists. It's been replaced by something that is only relevant to using SDL's 2D renderer. Which is to say what you're doing with it below here isn't really how you were supposed to be using it.
int window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; if (fullscreen) { window_flags |= SDL_WINDOW_FULLSCREEN; } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
// Allocate window and context. SDL_Window *window = SDL_CreateWindow("Exult", 0, 0, w, h, window_flags); if (window != NULL) { SDL_GLContext glcontext = SDL_GL_CreateContext(window); if (glcontext != NULL) { // Set those width/height vars if you // need them return true; } else { cerr << "Couldn't allocate OpenGL " "context: " << SDL_GetError() << endl; SDL_DestroyWindow(window); } } else { cerr << "Couldn't allocate a window: " << SDL_GetError() << endl; }
Again, this part is fine. ;)
See if the above helps give you a starting place. Basically you never really needed a surface for the OpenGL screen in SDL 1.2, but you kind of got one anyway. In SDL 2.0, you don't. And there's a lot less need for querying the video hardware because a window is now a proper window and not just a box trying to pretend to be a screen. This may not provide exactly what you intend in all cases and there could be a gaping syntax error in the above given that I'm typing bleary-eyed into an email and not a source code file. Joseph _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||||||||||||
|
Dominus
|
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 |
|||||||||||
|
SDL 1.2x to SDL2 - need some help with OpenGL |
Joseph Carter
|
On Sat, Jan 10, 2015 at 10:10:08AM +0000, Dominus wrote:
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. Joseph _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Dominus
|
thanks again, so I guess we'll need to deactivate this for SDL2
|
|||||||||||
|