The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
resizable opengl window on mac os x
Xecutor


Joined: 07 Oct 2010
Posts: 3
Hello there.

Right now I'm trying to make a small library to be used in utility applications with fancy UI and little games.
I'm making it using OpenGL on top of SDL.
On windows there are no problems with resizable window.
I'm just updating viewport and it works fine.
On mac os x it's broken.
When I resize window, picture is moved in some random way, new space is flickering with garbage and updating viewport do not help at all.
After digging for some time in SDL sources and various OpenGL samples for mac os x,
I've found out that after window resize you need to call 'update' method on opengl context.
As a quick hack I've added:
Code:

[ gl_context update];

to setFrame method at src/video/quartz/SDL_QuartzWindow.m:129
and it seems to fix the problem.
Probably it is valid solution.

I've heard that 1.2 was frozen... Is there a chance that fixed version will come out,
or should I ship patched libsdl binary with my applications?
resizable opengl window on mac os x
John Magnotti
Guest

My info on this may be out of date, but...

I think standard practice is to have a resize handler that calls necessary functions to reset glContext (including rebuilding textures). From what I understand it's not a bug, just a side effect of the GL context being trashed after a window resize. 


John

On Thu, Oct 7, 2010 at 11:21 PM, Xecutor wrote:
Quote:
Hello there.

Right now I'm trying to make a small library to be used in utility applications with fancy UI and little games.
I'm making it using OpenGL on top of SDL.
On windows there are no problems with resizable window.
I'm just updating viewport and it works fine.
On mac os x it's broken.
When I resize window, picture is moved in some random way, new space is flickering with garbage and updating viewport do not help at all.
After digging for some time in SDL sources and various OpenGL samples for mac os x,
I've found out that after window resize you need to call 'update' method on opengl context.
As a quick hack I've added:



Code:


[ gl_context update];




to setFrame method at src/video/quartz/SDL_QuartzWindow.m:129
and it seems to fix the problem.
Probably it is valid solution.

I've heard that 1.2 was frozen... Is there a chance that fixed version will come out,
or should I ship patched libsdl binary with my applications?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

resizable opengl window on mac os x
Ian Mallett
Guest

On Sun, Oct 10, 2010 at 4:17 PM, John Magnotti wrote:
Quote:
My info on this may be out of date, but...

I think standard practice is to have a resize handler that calls necessary functions to reset glContext (including rebuilding textures). From what I understand it's not a bug, just a side effect of the GL context being trashed after a window resize. 
Indeed, the context is remade.  Textures, and I'm fairly sure display lists are among the major things affected. 

I've always been annoyed by this.  Are there plans to fix it in future versions of SDL?

Ian



#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}
resizable opengl window on mac os x
Vittorio G.
Guest

Umh, would this guide be helpful?
http://www.gamedev.net/community/forums/topic.asp?topic_id=428022

Vittorio

On Mon, Oct 11, 2010 at 12:43 AM, Ian Mallett wrote:
Quote:
On Sun, Oct 10, 2010 at 4:17 PM, John Magnotti
wrote:
Quote:

My info on this may be out of date, but...
I think standard practice is to have a resize handler that calls necessary
functions to reset glContext (including rebuilding textures). From what I
understand it's not a bug, just a side effect of the GL context being
trashed after a window resize.

Indeed, the context is remade.  Textures, and I'm fairly sure display lists
are among the major things affected.

I've always been annoyed by this.  Are there plans to fix it in future
versions of SDL?

Ian

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Xecutor


Joined: 07 Oct 2010
Posts: 3
Why would resizing window ruing opengl context?
It is not.
As I said earlier, with glcontext update it works just fine.
And it works just fine without any fixes on windows and linux.
I'm not calling setvideomode after resize.
There is no need to do this.

The link is about generic sdl functions. Not about opengl.
Xecutor


Joined: 07 Oct 2010
Posts: 3
Here is quote from apple's documentation:
Quote:

The routine that you call for updating determines how events related to renderer and geometry changes are handled. For applications that use or subclass NSOpenGLView, Cocoa calls the update method automatically. Applications that create an NSOpenGLContext object manually must call the update method of NSOpenGLContext directly.


SDL creates context manually, so it MUST call update!
VernJensen


Joined: 09 Dec 2009
Posts: 159
Xecutor -- any idea how to fix this same problem in SDL 1.3? (The source code is quite different, and I can't find where to do an OpenGL context update.)
resizable opengl window on mac os x
Ian Mallett
Guest

On Mon, Oct 11, 2010 at 11:10 PM, Xecutor wrote:
Quote:
Why would resizing window ruing opengl context?


Because the accessors are rebound.  It's complicated, and I shan't presume great knowledge about exactly why this happens.  It is true that (sometimes) the data remains valid, just as (sometimes) overwriting the bounds of an array will be perfectly harmless.

The fact remains that problems can, and often do occur.  I have experienced this effect first hand, where the color channels of textures get changed or deleted, and display lists throw vertex garbage.  There's a possibility you won't get such problems, but assuming they won't happen is just wrong.

Some things that should remain valid are the viewport coordinates, the context's state (enable/disable).  Bound objects might stay valid too, but I'd have to check.  So, reinitializing your renderer is not necessary.  Reloading your content is.  I've experienced these problems on all three major platforms.

Quote:
It is not.
As I said earlier, with glcontext update it works just fine.
And it works just fine without any fixes on windows and linux.
I'm not calling setvideomode after resize.
There is no need to do this.

The link is about generic sdl functions. Not about opengl.


Ian



#avg_ls_inline_popup{position: absolute;z-index: 9999;padding: 0px 0px;margin-left: 0px;margin-top: 0px;overflow: hidden;word-wrap: break-word;color: black;font-size: 10px;text-align: left;line-height: 130%;}