[SDL] Fbled equivalent for SDL?

IMU ivynhood at gmail.com
Wed Jan 26 22:57:25 PST 2005


On Thu, 2005-01-13 at 23:35 +0000, Michael Wyrzykowski wrote:
> 
> > > > > If your code is not handling the SDL_VIDEORESIZE event then your        > > program is not doing the right things when the window changes size. 
> > > > >
> > > > > 		Bob Pendleton
> > > > I am handling the SDL_VIDEORESIZE event like:
> > > > ------
> > > > if(event.type == SDL_VIDEORESIZE)
> > > > {
> > > >     int width = event.resize.w;
> > > >     int height = event.resize.h;
> > > >     float scale_width = float(width)/800; //game logic set for
> > > >     float scale_height = float(height)/600;// 800x600 resolution
> > > > 
> > > >     glViewport( 0, 0, width, height);
> > > >     glMatrixMode(GL_PROJECTION);
> > > >     glLoadIdentity();
> > > >     glOrtho( 0, width, height, 0, -1, 1);
> > > >     glMatrixMode(GL_MODELVIEW);
> > > >     glLoadIdentity();
> > > >     glScalef( scale_width, scale_height, 1.0f );
> > > > }
> > 
> > > Yeah, you really are supposed to call SDL_SetVideoMode to make the SDL
> > > view of the window match the windowing systems view of the window.    > What happens when you make the window larger than the original window?
> > > 
> > > 		Bob Pendleton
> > When I make the window larger my using the mouse, the call to glScalef > simply scales everything that it draws so that whatever size the      > window is, then images will be scaled appropriately to fit. Nothing is > cut off. For example, the size of my background image is 800x600 (also > the default size to the window). If the user changes the window size   > with the mouse to 400x600, then glScalef() will be called to scale all > images by 0.5 on the x-axis, 1.0 on the y-axis, and 1.0 on the z-axis.
> > 
> > When resizing the window with the mouse, I do not need to reload in   > > any textures, and everything displays properly. However, I wanted to > > be able to specify the sizes the user could choose, so the graphics > > do not looked distorted from changing a 800x600 window to something > > like 600x800 (making all graphics look taller and less wide).
> > 
> > > I'm thinking that the proper thing to do would be to actually call    > > SetVideoMode again to request the correct resolution. It may be that > > I am developing a laptop that I did not notice any difference (an   > > LCD display  scales images because it only has one true resolution).
> > 
> 
> > > Very interesting. I would not have expected it to work that way. Are > > you using using any back buffers? That is, are you using double     > > buffering or using a Z buffer? What is happening only makes sense   > > (at least to me) if you are only using the front buffer. Normally   > > the back buffers have to be resized to match the size of the window. 
> 
> > 			Bob Pendleton
> 
> Yes, I am using Double-Buffering. My window setup code looks like:
> -----
>   //Set Window Attributes	
>   SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
>   SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
>   SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
>   SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
>   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
> 
>   //create the window
>   SDL_Surface *s;
>   s = SDL_SetVideoMode(800, 600, 0, SDL_OPENGL | SDL_RESIZABLE);
> -----
> Also, I was just playing a non-commercial game that uses SDL and OpenGL and it also allows the user to resize the window to whatever size they want, all in real time on my laptop, so I would doubt that the game reloads in all the textures either. 
> 
> What I am trying to figure out is: since it is possible to resize the window using the mouse without calling SetVideoMode() again or reloading all the textures again, is there any way to do this using code? Using glScalef() seems to work just find, but I do not know if it is possible without getting Win32-specific to resize the window without using the mouse.
> 

As far as I know there is currently know way to do what you want to do
without reloading the textures. What is going on here is out side my
expertise and violates what I thought I knew about SDL and OpenGL. I
have a couple of more questions for you. I have assumed that you are
using Windows, is that correct? Whose OpenGL drivers are you using? Have
you tried this using other OpenGL drivers? At this point I am trying to
extend my understanding of the problem.

		Bob Pendleton

> ___________________________________________________________________
> Speed up your surfing with Juno SpeedBand.
> Now includes pop-up blocker!
> Only $14.95/month -visit http://www.juno.com/surf to sign up today!
> 
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
> 





More information about the SDL mailing list