Inside3D!
     

hud image scaling

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
Hazematman



Joined: 15 Jul 2010
Posts: 31

PostPosted: Mon Aug 02, 2010 4:13 am    Post subject: hud image scaling Reply with quote

when I run my game in 640x400 it looks like this:



but when I run my game in 1024x768 the hud looks like this:



the image size is 640x400.

is there someway I can tell it to scale the image to the screen size or will I have to make several images and tell it to use that one if the screen size is set to x?
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Mon Aug 02, 2010 8:56 am    Post subject: Reply with quote

make your own Draw_pic. Scale to vid.width+vid.height.

or just enforce -conwidth on the commandline, but that's evil
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Hazematman



Joined: 15 Jul 2010
Posts: 31

PostPosted: Mon Aug 02, 2010 2:40 pm    Post subject: Reply with quote

how exactly would I do the scaling? for my draw pic I have this
Code:
Draw_TransPic(0, 0, Draw_CachePic("gfx/hud.lmp"));


so I'm guessing I would have to do something like this:
Code:
Draw_TransPic(0, 0, Draw_CachePic("gfx/hud.lmp"));
Scale("gfx/hud.imp")vid.width+vid.height;


but that is not working.
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Mon Aug 02, 2010 2:59 pm    Post subject: Reply with quote

Draw_ScaleTransPic(0, 0, vid.width, vid.height, Draw_CachePic("gfx/hud.lmp"));

And then write a Draw_ScaleTransPic function - you will need to modify gl_draw.c, obviously...
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Mon Aug 02, 2010 3:15 pm    Post subject: Reply with quote

Alternatively set pic.width = vid.vidth and pic.height = vid.height before drawing it. But both methods work fine.

I see you're getting a case of the pink fringe attack too so you might want to set palette index 255 to all 0.

Finally, using image sizes that aren't powers of 2 is not really healthy for GLQuake. It will kind of resample them, but you'll get better quality resizing it yourself in an image editor. 512x512 should be perfectly good enough for this pic.
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Hazematman



Joined: 15 Jul 2010
Posts: 31

PostPosted: Mon Aug 02, 2010 3:33 pm    Post subject: Reply with quote

I'm no expert at the quake source code but to make a scale_pic function I would copy the draw_pic function in gl_draw.c:


Code:
/*
=============
Draw_Pic
=============
*/
void Draw_Pic (int x, int y, qpic_t *pic)
{
   byte         *dest, *source;
   unsigned short   *pusdest;
   int            v, u;
   glpic_t         *gl;

   if (scrap_dirty)
      Scrap_Upload ();
   gl = (glpic_t *)pic->data;
   glColor4f (1,1,1,1);
   GL_Bind (gl->texnum);
   glBegin (GL_QUADS);
   glTexCoord2f (gl->sl, gl->tl);
   glVertex2f (x, y);
   glTexCoord2f (gl->sh, gl->tl);
   glVertex2f (x+pic->width, y);
   glTexCoord2f (gl->sh, gl->th);
   glVertex2f (x+pic->width, y+pic->height);
   glTexCoord2f (gl->sl, gl->th);
   glVertex2f (x, y+pic->height);
   glEnd ();
}


but what would I add to it, to make it scale?
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Mon Aug 02, 2010 10:42 pm    Post subject: Reply with quote

replace the x+pic->width and y+pic->height
with x+width and y+height and create the variables
int width and int height in your parameters like

Draw_Scale_Pic (int x, int y, int width, int height, qpic_t *pic)

OR

If you really wanna get cut and pastey

Code:

void GL_FullscreenQuad(int texture, float alpha)
{
   int vwidth = 1, vheight = 1;
   float vs, vt;

   while (vwidth < glwidth)
   {
      vwidth *= 2;
   }
   while (vheight < glheight)
   {
      vheight *= 2;
   }

   glViewport (glx, gly, glwidth, glheight);

   GL_Bind(texture);

   // go 2d
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity ();
   glOrtho  (0, glwidth, 0, glheight, -99999, 99999);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity ();

   vs = ((float)glwidth / vwidth);
   vt = ((float)glheight / vheight) ;

   glDisable (GL_DEPTH_TEST);
   glDisable (GL_CULL_FACE);
   glDisable (GL_ALPHA_TEST);
   glEnable (GL_BLEND);
   
   glAlphaFunc(GL_GREATER,0.000f);
   glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   glDepthMask(0);

   glColor4f(1, 1, 1, alpha);

   glBegin(GL_QUADS);
      glTexCoord2f(0, 0);
      glVertex2f(0, 0);
      glTexCoord2f(vs , 0);
      glVertex2f(glwidth, 0);
      glTexCoord2f(vs , vt);
      glVertex2f(glwidth, glheight);
      glTexCoord2f(0, vt);
      glVertex2f(0, glheight);
   glEnd();

   glEnable(GL_DEPTH_TEST);
   glDepthMask(1);
   glDisable(GL_ALPHA_TEST);
   glAlphaFunc(GL_GREATER,0.666f);
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
   glColor3f (1,1,1);   
    glDisable (GL_BLEND);   
    glEnable (GL_TEXTURE_2D);   
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);   
   //?glEnable(GL_CULL_FACE);
   glMatrixMode(GL_PROJECTION);
   glPopMatrix();      
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();      
}
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Aug 03, 2010 2:23 am    Post subject: Reply with quote

Do it the "right" way and open up gfx.wad with something like fimg and create a 320x200 compatible quake paletted version of your "replacement" image.

Then it will scale properly at any resolution.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group