hud translucent
Moderator: InsideQC Admins
62 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
hud translucent
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?
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?
-

Hazematman - Posts: 54
- Joined: Thu Jul 15, 2010 1:58 am
- Location: Canada
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.
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.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
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.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
- Code: Select all
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: Select all
/*
=============
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);
}
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
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...
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.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
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:
Since it is in GLQuake, PSP engines have equivalent, of course:
- Code: Select all
/*
=============
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);
}
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Where the heck is Sbar_DrawPicAlpha located? Which file? I did a complete search in psp Kurok, and I fail to find it using textpad5/.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
You've got the name wrong - it's Draw_AlphaPic.
Another fun fact: GLQuake's Draw_AlphaPic is actually broken and won't draw with alpha at all on most (all?) modern 3D cards.
Another fun fact: GLQuake's Draw_AlphaPic is actually broken and won't draw with alpha at all on most (all?) modern 3D cards.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
You will have to copy Sbar_DrawPic and make your own Sbar_DrawAlphaPic.
It is a trivial change, just add one more field called alpha to the end of the function declaration (i.e. float alpha).
Then in Sbar_DrawAlphaPic make it use Draw_AlphaPic if the alpha value is less than 1.
if (alpha < 1)
Draw_AlphaPic (...., alpha);
else
Draw_Pic (....);
Post back if you need help, unfortunately these next several days I may only be around 15 minutes twice per day but any other engine coder can help you with this because it is a very basic modification.
It is a trivial change, just add one more field called alpha to the end of the function declaration (i.e. float alpha).
Then in Sbar_DrawAlphaPic make it use Draw_AlphaPic if the alpha value is less than 1.
if (alpha < 1)
Draw_AlphaPic (...., alpha);
else
Draw_Pic (....);
Post back if you need help, unfortunately these next several days I may only be around 15 minutes twice per day but any other engine coder can help you with this because it is a very basic modification.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
found it.
/*=============
Draw_Pic
=============*/
void Draw_Pic (int x, int y, qpic_t *pic, float alpha)
{
byte *dest, *source;
unsigned short *pusdest;
int v, u;
glpic_t *gl;
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
glEnable (GL_BLEND);
glColor4f (1,1,1,alpha);
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 ();
glColor4f (1,1,1,1);
glDisable (GL_BLEND);
}[/code]
/*=============
Draw_Pic
=============*/
void Draw_Pic (int x, int y, qpic_t *pic, float alpha)
{
byte *dest, *source;
unsigned short *pusdest;
int v, u;
glpic_t *gl;
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
glEnable (GL_BLEND);
glColor4f (1,1,1,alpha);
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 ();
glColor4f (1,1,1,1);
glDisable (GL_BLEND);
}[/code]
Last edited by revelator on Sun Oct 03, 2010 7:51 pm, edited 1 time in total.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
62 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 1 guest