Inside3D!
     

hud translucent

 
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 5:56 pm    Post subject: hud translucent Reply with quote

does standard glquake have support for translucent textures for the hud?

if so, how would I make it draw a translucent picture?

if not, does anyone know how to add it and could try to help me with it?
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Aug 03, 2010 1:47 am    Post subject: Reply with quote

Yes it does.

Something like Draw_AlphaPic and if it doesn't, you can easily make one by turning on whatever r_wateralpha does on, presumably, the PSP.

In OpenGL, it something like GLBlendEnable and glColor4f (might be slightly off, not looking @ the engine code). I can't remember the PSPGU equivalent.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Tue Aug 03, 2010 4:32 am    Post subject: Reply with quote

Draw_TransPic draws images with TRANSPARENT pixels (palette index 255). But "translucent" means fadey-alpha. I don't think GLQuake supports that out of the box.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Tue Aug 03, 2010 6:07 am    Post subject: Reply with quote

Code:

void Sbar_DrawPicAlpha (int x, int y, mpic_t *pic)
{   
   Draw_AlphaPic (x + sbar_xofs, y + (vid.height-SBAR_HEIGHT), pic, scr_sbaralpha.value);
}


Code:

/*
=============
Draw_AlphaPic
=============
*/
void Draw_AlphaPic (int x, int y, mpic_t *pic, float alpha)
{
   if (scrap_dirty)
      Scrap_Upload ();

   glDisable(GL_ALPHA_TEST);
   glEnable (GL_BLEND);
   glCullFace (GL_FRONT);
   glColor4f (1, 1, 1, alpha);
   GL_Bind (pic->texnum);
   
   glBegin (GL_QUADS);
   glTexCoord2f (pic->sl, pic->tl);
   glVertex2f (x, y);
   glTexCoord2f (pic->sh, pic->tl);
   glVertex2f (x+pic->width, y);
   glTexCoord2f (pic->sh, pic->th);
   glVertex2f (x+pic->width, y+pic->height);
   glTexCoord2f (pic->sl, pic->th);
   glVertex2f (x, y+pic->height);
   glEnd ();

   glColor3f (1, 1, 1);
   glEnable(GL_ALPHA_TEST);
   glDisable (GL_BLEND);
}
Back to top
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Tue Aug 03, 2010 6:54 am    Post subject: Reply with quote

I stand corrected. I've never spent much time in the GLQuake source but I should have looked before I posted.

Anyway, it's still not clear what the original poster wanted. Constant alpha over the whole image (Draw_AlphaPic) or an image with an alpha channel... Probably the former. I'll go now...
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Aug 03, 2010 8:04 am    Post subject: Reply with quote

I wasn't 100% sure it was in GLQuake for sure either, then again I think I recall one version having a translucent console or something?

Since it is in GLQuake, PSP engines have equivalent, of course:

Code:
/*
=============
Draw_AlphaPic
=============
*/
static void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
{
   if (alpha != 1.0f)
   {
      sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGBA);
   }

   glpic_t         *gl;

#if 0
   if (scrap_dirty)
      Scrap_Upload ();
#endif
   gl = (glpic_t *)pic->data;
   GL_Bind (gl->index);

   const gltexture_t& glt = gltextures[gl->index];

   struct vertex
   {
      short         u, v;
      short         x, y, z;
   };

   int start, end;
   int slice = 32;

   // blit maximizing the use of the texture-cache

   for (start = 0, end = glt.original_width; start < end; start += slice, x += slice)
   {
        vertex* const vertices = static_cast<vertex*>(sceGuGetMemory(sizeof(vertex) * 2));
        int width = (start + slice) < end ? slice : end-start;

        vertices[0].u      = start;
        vertices[0].v      = 0;
        vertices[0].x      = x;
        vertices[0].y      = y;
        vertices[0].z      = 0;

        vertices[1].u      = start + width;//glt.original_width;
        vertices[1].v      = glt.original_height;
        vertices[1].x      = x + width;//pic->width;
        vertices[1].y      = y + pic->height;
        vertices[1].z      = 0;

        sceGuColor(GU_RGBA(0xff, 0xff, 0xff, static_cast<unsigned int>(alpha * 255.0f)));
        sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
   }
   if (alpha != 1.0f)
      sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
}

_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Thu Aug 05, 2010 6:51 am    Post subject: Reply with quote

draw_alpha pic available but i dont think glQuake used it for the sbar.
Back to top
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Thu Aug 05, 2010 7:38 am    Post subject: Reply with quote

Probably only for the conback.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
leileilol



Joined: 15 Oct 2004
Posts: 1321

PostPosted: Thu Aug 05, 2010 8:40 am    Post subject: Reply with quote

Sajt wrote:
Probably only for the conback.

indeed since the conback fades.

FUN FACT: the rage pro is stupid with alphas and TRIES TO SOFTWARE RENDER THEM WITHIN THE 3D BUFFER, maybe that's why it's hardly used.
_________________
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