Disappearing Textures when resizing OpenGL windows

Hi All,
I have implmented Resiable Windows in the OpenGL demos for the
JEDI-SDL bindings and find that when the demo starts everything appears
to work great. The moment I resize the window the objects/models resize,
but the textures applied to them disappear so every thing looks white.

When I trap the SDL_VIDEORESIZE event, my code looks like this…
if (event.resize.h = 0) then // prevent divide by zero exception
event.resize.h := 1;
// Set new width and height with old flags
SDL_SetVideoMode( event.resize.w, event.resize.h, flags );
// Set the viewport for the OpenGL window
glViewport(0, 0, event.resize.w, event.resize.h);

glMatrixMode(GL_PROJECTION); // Change Matrix Mode to Projection
glLoadIdentity; // Reset View

// Do the perspective calculations. Last value = max clipping depth
gluPerspective(45.0,event.resize.w/event.resize.h, 1.0, 500.0);

glMatrixMode(GL_MODELVIEW); // Return to the modelview matrix
glLoadIdentity; // Reset View

I am extremely new to SDL and OpenGL, so could someone point me in the
right direction. Is there something else I should be doing so that the
textures remain stuck to the models. These demos, are conversions to
Object Pascal of the SDL Nehe demos, and all I have tried to do is
implement window resizing.

Thanks in advance,

Dominique Louis
http://www.DelphiGamer.com := for all your Delphi/Kylix game development
needs;

mmhh… i wonder if call to SDL_SetVideoMode do not recreate any
underlying handle, including, but not mimted to, HGLRC: the OpenGL
context.

and if you recreate a new one, of course, it wouldn’t know other
texture…
you have either to reload them or maybe it exist some way to share
texture amongst context, i will eventually investigate (a bit) when i be
back home, in the red book, if you need it…

Hi Lloyd,
I tried just reloading the texture but that did not work. Maybe I
should try calling IniiGL again.

Thanks,

Dominique Louis
http://www.DelphiGamer.com := for all your Delphi/Kylix game development
needs;

Lloyd Dupont wrote:> mmhh… i wonder if call to SDL_SetVideoMode do not recreate any

underlying handle, including, but not mimted to, HGLRC: the OpenGL context.

and if you recreate a new one, of course, it wouldn’t know other texture…
you have either to reload them or maybe it exist some way to share
texture amongst context, i will eventually investigate (a bit) when i be
back home, in the red book, if you need it…


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi
It would seem that I do need to call InitGL with the new dimensions
after the call to SDL_SetVideoMode with
InitGL(event.resize.w, event.resize.h);
So it appears to be working now.

Now if I could just get my SDL port of a Quake 2 Model Viewer/Animator
to work, I would indeed be a happy boy.

Thanks for getting me thinking,

Dominique Louis
http://www.DelphiGamer.com := for all your Delphi/Kylix game development
needs;

Lloyd Dupont wrote:> mmhh… i wonder if call to SDL_SetVideoMode do not recreate any

underlying handle, including, but not mimted to, HGLRC: the OpenGL context.

and if you recreate a new one, of course, it wouldn’t know other texture…
you have either to reload them or maybe it exist some way to share
texture amongst context, i will eventually investigate (a bit) when i be
back home, in the red book, if you need it…


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi
It would seem that I do need to call InitGL with the new dimensions
after the call to SDL_SetVideoMode with
InitGL(event.resize.w, event.resize.h);
So it appears to be working now.
Cool…

Now if I could just get my SDL port of a Quake 2 Model Viewer/Animator
to work, I would indeed be a happy boy.
mmhh… BTW you have an SDL port of Quake2 like game ?
is it working right now ?
i am curious, could it be getted somewhere ?
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: text/enriched
Size: 523 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010905/4f187bfb/attachment.bin

Hi Lloyd,

Lloyd Dupont wrote:

Now if I could just get my SDL port of a Quake 2 Model
Viewer/Animator to work, I would indeed be a happy boy.

mmhh… BTW you have an SDL port of Quake2 like game ?
is it working right now ?
i am curious, could it be getted somewhere ?

I think you may have misunderstood me. I have ported an OpenGL Quake 2
Model Viewer/Animator that bascially loads a Quake 2 Model ( .md2 ),
applies an appropriate texture and displays all the animation sequences
the Model is supposed to contain. That is what it is supposed to do. The
reality is, I have it loading the model and displaying the animation
sequences, but somewhere along the line the texture is not getting
applied to the model. So at the moment it is just a white outline that
jumps around on the screen and does it’s animation stuff. I will try and
debug it a little more this evening as I would like to include it as
part of the Beta 4 release of JEDI-SDL.

So to answer your question, it is not a port of a Quake 2 like game ( don’t I wish ),

it is only a model viewer at the moment.

After doing my port to Object Pascal and JEDI-SDL, I have found that
there is a C++ OpenGL Quake 2 Model viewer ( with Full source Code )
available from http://www.jawed.com/jawmd2/. I think it would make a
really nice SDL demo, if anyone can spare half an hour to port it for
the C/C++ developers out there.

Dominique Louis
http://www.DelphiGamer.com := for all your Delphi/Kylix game development
needs;

There’s an SDL Quake which is vastly improved over Sam’s original SDLQuake
port using OpenGL at http://twilight.sf.net/ if you’re interested. It
still has many Quake-isms which need to die before I can declare it a true
SDL-native application, but they are planned. Will post a proper announce
when we have something other than just development snaps for download.On Wed, Sep 05, 2001 at 04:43:38PM +0200, Lloyd Dupont wrote:

Now if I could just get my SDL port of a Quake 2 Model
Viewer/Animator to work, I would indeed be a happy boy.

mmhh… BTW you have an SDL port of Quake2 like game ?
is it working right now ?
i am curious, could it be getted somewhere ?


Joseph Carter Free software developer

but, then I used an Atari, I was more likely to win the lottery in ten
countries simultaneously than get accelerated X

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010905/7f9afd33/attachment.pgp

thanks for yours links.
i will take a deep look at them soon…

Hi Joseph,

Joseph Carter wrote:

There’s an SDL Quake which is vastly improved over Sam’s original SDLQuake
port using OpenGL at http://twilight.sf.net/ if you’re interested. It
still has many Quake-isms which need to die before I can declare it a true
SDL-native application, but they are planned. Will post a proper announce
when we have something other than just development snaps for download.

Looks like a really good project.
This is probably a silly question, but I will ask anyway. Is this a port
of the Quake 1 or Quake 2 engine? Or will you takle them in order?

Thanks,

Dominique Louis
http://www.DelphiGamer.com := for all your Delphi/Kylix game development
needs;

Looks like a really good project.
This is probably a silly question, but I will ask anyway. Is this a port
of the Quake 1 or Quake 2 engine? Or will you takle them in order?

I think it would be hard to port the Quake 2 engine, having to start from a
disassembled executable… The Quake 1 source however has been released
under LGPL, so…

:slight_smile:

----- Original Message -----
From: Dominique Louis [mailto:Dominique@SavageSoftware.com.au]

No, I was going to do an SDL port of Quake 2 for Zoid once upon a time but
when he left Id he stopped having time to think about it and I haven’t had
the time either. I may help with such an SDL port for a time when (if)
the code gets released to the public, but probably only in an advisory
capacity on some of the nits people will hit with Quake and SDL and the
Quake filesystem code, etc.

I hate to sound a bit megalomanic, but I don’t NEED Quake 2. A list of
improvements:

  • Marginally better network code
    I could do much better now.

  • Ability to restart the renderer
    No Quake 1 engine has this feature yet, but Zeph and I do know how to
    do it–it’s just not an overnight task. Suffice it to say that what
    is needed to toggle fullscreen/windowed in OpenGL using SDL is half
    the battle right there.

  • Skyboxes instead of 2 layer "Quake sky"
    It’s been done. Many times.

  • Colored lighting in OpenGL
    It’s been done. Even more times than skyboxes.

  • Cinematic files (easier to create than demo movies)
    A series of PCX files (8bpp) at 14 fps with a wav file. The files are
    huge, lerping the images so they look good in software is probably
    best done with some carefully tuned asm (I don’t know if Id did it
    this way or not…) I’d rather support JNG or MNG or at least MPEG.

  • Renderer plus half the OS code (video, input) are modular
    I used to think this was a good thing, but then on my box Quake 2 does
    not work out of the box. Due to a bug in the video code (which
    existed in Quake 1 as well), X can only be used at 8 or 16 bit. Since
    svgalib on NVidia GeForce cards at best a sad joke, my only option is
    to set up OpenGL and run the game with commandline parameters that
    attempt to set it up right… ref_glx.so is needed, but due to a bug
    in ref_glx.so, you must put a symlink opengl32.dll pointing to
    libGL.so someplace. (Oh stop snickering, like you’ve never had a bug
    like that before…)

  • Dynamic OpenGL loading
    As mentioned above, it almost works even. :wink: But then, we have this
    nice code written by Zeph which does that for SDL. It would also do
    it for non-SDL with about 20 minutes of modification and works great
    if you don’t mind about 3 dozen function pointers or so. Talk to me
    off-list if you are having trouble getting this most useful feature of
    SDL to work, I’ll send you the code.

[Attempting to steer this offtopic discussion back ON topic] SDL could
drastically improve Quake 2, to be sure. I’ll offer some sagely advice to
anyone considering working on it, since the source was originally to be
released in October, but rumors are that it’s been pushed back a bit.

Sound code need not be touched if you want to keep the port simple, but I
really think you’ll find that you’re better moving to SDL. I have a
drop-in snd_sdl.c which replaces snd_linux.c in Quake 1 outright. I do
not know for certain that it will replace snd_win.c, but it’d be trivial
to make it do that if need be. Quake 2’s sound code is either virtually
or actually identical to Quake 1.

SDL video and input are obvious, and my CURRENT vid_sdl.c would probably
replace gl_vid{linuxglx,nt}.c without much pain, but software rendering
will take more work and you might want to go back to Sam’s SDLQuake stuff
and just redo the input to not suck. :wink: Sam didn’t recall for certain
last time I asked him, but he believes the input code in SDLQuake may
predate SDL 1.0, if that’s an indication of how bad it was. Window tends
to lose the mouse, etc.

I would recommend dumping ref_.{so,dll} entirely. Compile the SDL-using
stuff right in to the renderer and create a Cvar vid_renderer which inits
to “stub”. Then write a stub renderer which is also compiled-in and
provides software menu and console, but that’s about it. This way if all
else fails, you at least have a method by which you can configure things
without resorting to trying to track down a commandline param which may or
may not be listed in some README file. Keep the code that loads ref_
and
use it to load r_soft.so and r_opengl.so as needed. Renderer plugins, no
pain for the user.

If anyone is serious about working on this, I can probably offer a dozen
more suggestions and chunks of code once there is source. I can only
offer so much based on info I’m probably not supposed to have (Zoid’s
fault) and a set of stripped binaries. Inquire off-list please, I seem to
have a bad habit of getting off-topic around here lately.On Thu, Sep 06, 2001 at 09:40:34AM +0100, Dominique Louis wrote:

There’s an SDL Quake which is vastly improved over Sam’s original SDLQuake
port using OpenGL at http://twilight.sf.net/ if you’re interested. It
still has many Quake-isms which need to die before I can declare it a true
SDL-native application, but they are planned. Will post a proper announce
when we have something other than just development snaps for download.

Looks like a really good project.
This is probably a silly question, but I will ask anyway. Is this a port
of the Quake 1 or Quake 2 engine? Or will you takle them in order?


Joseph Carter Free software developer

taniwha: Quote material :slight_smile:
Endy: :slight_smile:
Endy: I already snipped it

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010906/7ac629d2/attachment.pgp