Beispiel #1
0
/*
 =============
 R_DrawTileImage

 This repeats a 64*64 tile graphic to fill the screen around a sized down
 refresh window.
 =============
 */
void R_DrawTileImage (int32_t x, int32_t y, int32_t w, int32_t h, image_t *image)
{
    static const vec4_t color[4] = {
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0}
    };

    const vec3_t verts[4] = {
        {x, y, 0},
        {x+w, y, 0},
        {x+w, y+h, 0},
        {x, y+h, 0}
    };

    GL_Bind (image->texnum);

    rb_vertex = rb_index = 0;

    memcpy(&indexArray[rb_index], indices, sizeof(indices));
    rb_index = 6;

    VA_SetElem2(texCoordArray[0][0], (float)x/(float)image->width, (float)y/(float)image->height);
    VA_SetElem2(texCoordArray[0][1], (float)(x+w)/(float)image->width, (float)y/(float)image->height);
    VA_SetElem2(texCoordArray[0][2], (float)(x+w)/(float)image->width, (float)(y+h)/(float)image->height);
    VA_SetElem2(texCoordArray[0][3], (float)x/(float)image->width, (float)(y+h)/(float)image->height);

    memcpy(vertexArray, verts, sizeof(vec3_t) * 4);
    memcpy(colorArray, color, sizeof(vec4_t) * 4);

    rb_vertex = 4;

    RB_RenderMeshGeneric (false);
}
Beispiel #2
0
/*
 =============
 R_DrawPic
 =============
 */
void R_DrawImage (int32_t x, int32_t y, image_t *gl)
{
    int32_t		i;
    vec2_t	texCoord[4], verts[4];
    
    if (scrap_dirty)
        Scrap_Upload ();
    
    GL_Bind (gl->texnum);
    
    Vector2Set(texCoord[0], gl->sl, gl->tl);
    Vector2Set(texCoord[1], gl->sh, gl->tl);
    Vector2Set(texCoord[2], gl->sh, gl->th);
    Vector2Set(texCoord[3], gl->sl, gl->th);
    
    Vector2Set(verts[0], x, y);
    Vector2Set(verts[1], x+gl->width, y);
    Vector2Set(verts[2], x+gl->width, y+gl->height);
    Vector2Set(verts[3], x, y+gl->height);
    
    rb_vertex = rb_index = 0;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+1;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+3;
    for (i=0; i<4; i++) {
        VA_SetElem2(texCoordArray[0][rb_vertex], texCoord[i][0], texCoord[i][1]);
        VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0);
        VA_SetElem4(colorArray[rb_vertex], 1.0, 1.0, 1.0, 1.0);
        rb_vertex++;
    }
    RB_RenderMeshGeneric (false);
}
Beispiel #3
0
/*
 =============
 R_DrawPic
 =============
 */
void R_DrawImage (int32_t x, int32_t y, image_t *gl)
{
    static const vec4_t color[4] = {
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0}
    };

    if (scrap_dirty)
        Scrap_Upload ();

    GL_Bind (gl->texnum);

    rb_vertex = rb_index = 0;

    memcpy(indexArray, indices, sizeof(indices));
    rb_index = 6;

    VA_SetElem2(texCoordArray[0][0], gl->sl, gl->tl);
    VA_SetElem2(texCoordArray[0][1], gl->sh, gl->tl);
    VA_SetElem2(texCoordArray[0][2], gl->sh, gl->th);
    VA_SetElem2(texCoordArray[0][3], gl->sl, gl->th);

    VA_SetElem3(vertexArray[0], x, y, 0);
    VA_SetElem3(vertexArray[1], x+gl->width, y, 0);
    VA_SetElem3(vertexArray[2], x+gl->width, y+gl->height, 0);
    VA_SetElem3(vertexArray[3], x, y+gl->height, 0);

    memcpy(colorArray, color, sizeof(vec4_t) * 4);

    rb_vertex = 4;
    RB_RenderMeshGeneric (false);
}
Beispiel #4
0
/*
==============
R_ShadowBlend
Draws projection shadow(s)
from stenciled volume
==============
*/
void R_ShadowBlend (float shadowalpha)
{
    const vec4_t color[4] = {
        {0, 0, 0, shadowalpha},
        {0, 0, 0, shadowalpha},
        {0, 0, 0, shadowalpha},
        {0, 0, 0, shadowalpha}
    };
    
    static const vec3_t verts[4] = {
        {10, 100, 100},
        {10, -100, 100},
        {10, -100, -100},
        {10, 100, -100}
    };
    
    static const uint32_t indices[6] = {
        0, 1, 2, 0, 2, 3
    };
    
	if (r_shadows->value != 3)
		return;

	GL_PushMatrix(GL_MODELVIEW);

	GL_LoadMatrix(GL_MODELVIEW, glState.axisRotation);

	GL_Disable (GL_ALPHA_TEST);
	GL_Enable (GL_BLEND);
	GL_Disable (GL_DEPTH_TEST);
	GL_DisableTexture(0);

    GL_StencilFunc(GL_NOTEQUAL, 0, 255);
    glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
	GL_Enable(GL_STENCIL_TEST);

	rb_vertex = rb_index = 0;
    
    memcpy(indexArray, indices, sizeof(indices));
    memcpy(vertexArray, verts, sizeof(vec3_t) * 4);
    memcpy(colorArray, color, sizeof(vec4_t) * 4);

    rb_index += 6;
	rb_vertex += 4;

    RB_RenderMeshGeneric (false);

	GL_PopMatrix(GL_MODELVIEW);

	GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	GL_Disable (GL_BLEND);
	GL_EnableTexture(0);
	GL_Enable (GL_DEPTH_TEST);
	GL_Disable(GL_STENCIL_TEST);
	//GL_Enable (GL_ALPHA_TEST);

	glColor4f(1,1,1,1);
}
Beispiel #5
0
void R_DrawStretchRaw (int32_t x, int32_t y, int32_t w, int32_t h, const byte *raw, int32_t rawWidth, int32_t rawHeight) //qboolean noDraw)
{
    static const vec2_t		texCoord[4] = {
        { 0, 0},
        { 1, 0},
        { 1, 1},
        { 0, 1}
    };

    static const vec4_t color[4] = {
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0},
        {1.0, 1.0, 1.0, 1.0}
    };

    const vec3_t verts[4] = {
        {x, y, 0},
        {x+w, y, 0},
        {x+w, y+h, 0},
        {x, y+h, 0}
    };

    // Make sure everything is flushed if needed
    //if (!noDraw)
    //	RB_RenderMesh();

    // Update the texture as appropriate
    GL_Bind(glMedia.rawtexture->texnum);

    if (rawWidth == glMedia.rawtexture->upload_width && rawHeight == glMedia.rawtexture->upload_height)
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rawWidth, rawHeight, GL_RGBA, GL_UNSIGNED_BYTE, raw);
    else {
        glMedia.rawtexture->upload_width = rawWidth;
        glMedia.rawtexture->upload_height = rawHeight;
        glTexImage2D(GL_TEXTURE_2D, 0, gl_raw_tex_solid_format, rawWidth, rawHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, raw);
    }

    //if (noDraw)
    //	return;

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    rb_vertex = rb_index = 0;

    memcpy(indexArray, indices, sizeof(indices));
    rb_index = 6;

    // Draw it
    memcpy(vertexArray, verts, sizeof(vec3_t) * 4);
    memcpy(texCoordArray, texCoord, sizeof(vec2_t) * 4);
    memcpy(colorArray, color, sizeof(vec4_t) * 4);

    rb_vertex = 4;
    RB_RenderMeshGeneric (false);
}
Beispiel #6
0
/*
 =============
 R_DrawStretchImage
 =============
 */
void R_DrawStretchImage (int32_t x, int32_t y, int32_t w, int32_t h, image_t *gl, float alpha)
{
    const vec4_t color[4] = {
        {1.0, 1.0, 1.0, alpha},
        {1.0, 1.0, 1.0, alpha},
        {1.0, 1.0, 1.0, alpha},
        {1.0, 1.0, 1.0, alpha}
    };

    const vec3_t verts[4] = {
        {x, y, 0},
        {x+w, y, 0},
        {x+w, y+h, 0},
        {x, y+h, 0}
    };


    if (scrap_dirty)
        Scrap_Upload ();

    // Psychospaz's transparent console support
    if (gl->has_alpha || alpha < 1.0)
    {
        GL_Disable (GL_ALPHA_TEST);
        GL_TexEnv (GL_MODULATE);
        GL_Enable (GL_BLEND);
        GL_DepthMask (false);
    }

    GL_Bind (gl->texnum);

    rb_vertex = rb_index = 0;
    memcpy(&indexArray[rb_index], indices, sizeof(indices));

    rb_index = 6;

    Vector2Set(texCoordArray[0][0], gl->sl, gl->tl);
    Vector2Set(texCoordArray[0][1], gl->sh, gl->tl);
    Vector2Set(texCoordArray[0][2], gl->sh, gl->th);
    Vector2Set(texCoordArray[0][3], gl->sl, gl->th);

    memcpy(vertexArray, verts, sizeof(vec3_t) * 4);
    memcpy(colorArray[rb_vertex], color, sizeof(vec4_t) * 4);

    rb_vertex = 4;

    RB_RenderMeshGeneric (false);

    // Psychospaz's transparent console support
    if (gl->has_alpha || alpha < 1.0)
    {
        GL_DepthMask (true);
        GL_TexEnv (GL_REPLACE);
        GL_Disable (GL_BLEND);
        GL_Enable (GL_ALPHA_TEST);
    }
}
Beispiel #7
0
/*
 =============
 R_DrawStretchImage
 =============
 */
void R_DrawStretchImage (int32_t x, int32_t y, int32_t w, int32_t h, image_t *gl, float alpha)
{
    int32_t			i;
    vec2_t		texCoord[4], verts[4];
    
    if (scrap_dirty)
        Scrap_Upload ();
    
    // Psychospaz's transparent console support
    if (gl->has_alpha || alpha < 1.0)
    {
        GL_Disable (GL_ALPHA_TEST);
        GL_TexEnv (GL_MODULATE);
        GL_Enable (GL_BLEND);
        GL_DepthMask (false);
    }
    
    GL_Bind (gl->texnum);
    
    Vector2Set(texCoord[0], gl->sl, gl->tl);
    Vector2Set(texCoord[1], gl->sh, gl->tl);
    Vector2Set(texCoord[2], gl->sh, gl->th);
    Vector2Set(texCoord[3], gl->sl, gl->th);
    
    Vector2Set(verts[0], x, y);
    Vector2Set(verts[1], x+w, y);
    Vector2Set(verts[2], x+w, y+h);
    Vector2Set(verts[3], x, y+h);
    
    rb_vertex = rb_index = 0;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+1;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+3;
    for (i=0; i<4; i++) {
        VA_SetElem2(texCoordArray[0][rb_vertex], texCoord[i][0], texCoord[i][1]);
        VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0);
        VA_SetElem4(colorArray[rb_vertex], 1.0, 1.0, 1.0, alpha);
        rb_vertex++;
    }
    RB_RenderMeshGeneric (false);
    
    // Psychospaz's transparent console support
    if (gl->has_alpha || alpha < 1.0)
    {
        GL_DepthMask (true);
        GL_TexEnv (GL_REPLACE);
        GL_Disable (GL_BLEND);
        GL_Enable (GL_ALPHA_TEST);
    }
}
Beispiel #8
0
void R_DrawStretchRaw (int32_t x, int32_t y, int32_t w, int32_t h, const byte *raw, int32_t rawWidth, int32_t rawHeight) //qboolean noDraw)
{
	int32_t		i;
	vec2_t	texCoord[4], verts[4];

	// Make sure everything is flushed if needed
	//if (!noDraw)
	//	RB_RenderMesh();

	// Update the texture as appropriate
	GL_Bind(glMedia.rawtexture->texnum);
	
	if (rawWidth == glMedia.rawtexture->upload_width && rawHeight == glMedia.rawtexture->upload_height)
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rawWidth, rawHeight, GL_RGBA, GL_UNSIGNED_BYTE, raw);
	else {
		glMedia.rawtexture->upload_width = rawWidth;
		glMedia.rawtexture->upload_height = rawHeight;
		glTexImage2D(GL_TEXTURE_2D, 0, gl_raw_tex_solid_format, rawWidth, rawHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, raw);
	}

	//if (noDraw)
	//	return;

	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	// Draw it
	Vector2Set(texCoord[0], 0, 0);
	Vector2Set(texCoord[1], 1, 0);
	Vector2Set(texCoord[2], 1, 1);
	Vector2Set(texCoord[3], 0, 1);

	Vector2Set(verts[0], x, y);
	Vector2Set(verts[1], x+w, y);
	Vector2Set(verts[2], x+w, y+h);
	Vector2Set(verts[3], x, y+h);

	rb_vertex = rb_index = 0;
	indexArray[rb_index++] = rb_vertex+0;
	indexArray[rb_index++] = rb_vertex+1;
	indexArray[rb_index++] = rb_vertex+2;
	indexArray[rb_index++] = rb_vertex+0;
	indexArray[rb_index++] = rb_vertex+2;
	indexArray[rb_index++] = rb_vertex+3;
	for (i=0; i<4; i++) {
		VA_SetElem2(texCoordArray[0][rb_vertex], texCoord[i][0], texCoord[i][1]);
		VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0);
		VA_SetElem4(colorArray[rb_vertex], 1, 1, 1, 1);
		rb_vertex++;
	}
	RB_RenderMeshGeneric (false);
}
Beispiel #9
0
void R_DrawSkyBox (void)
{
	int		i;

	if (skyrotate)
	{	// check for no sky at all
		for (i=0 ; i<6 ; i++)
			if (skymins[0][i] < skymaxs[0][i]
			&& skymins[1][i] < skymaxs[1][i])
				break;
		if (i == 6)
			return;		// nothing visible
	}

	qglPushMatrix ();
	qglTranslatef (r_origin[0], r_origin[1], r_origin[2]);
	qglRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]);

	for (i=0; i<6; i++)
	{
		if (skyrotate)
		{	// hack, forces full sky to draw when rotating
			skymins[0][i] = -1;
			skymins[1][i] = -1;
			skymaxs[0][i] = 1;
			skymaxs[1][i] = 1;
		}

		if (skymins[0][i] >= skymaxs[0][i]
		|| skymins[1][i] >= skymaxs[1][i])
			continue;

		GL_Bind (sky_images[skytexorder[i]]->texnum);

		rb_vertex = rb_index = 0;
		indexArray[rb_index++] = rb_vertex+0;
		indexArray[rb_index++] = rb_vertex+1;
		indexArray[rb_index++] = rb_vertex+2;
		indexArray[rb_index++] = rb_vertex+0;
		indexArray[rb_index++] = rb_vertex+2;
		indexArray[rb_index++] = rb_vertex+3;
		MakeSkyVec (skymins[0][i], skymins[1][i], i);
		MakeSkyVec (skymins[0][i], skymaxs[1][i], i);
		MakeSkyVec (skymaxs[0][i], skymaxs[1][i], i);
		MakeSkyVec (skymaxs[0][i], skymins[1][i], i);
		RB_RenderMeshGeneric (true);
	}

	qglPopMatrix ();
}
Beispiel #10
0
/*
======================
R_DrawFill

Fills a box of pixels with a
24-bit color w/ alpha
===========================
*/
void R_DrawFill (int32_t x, int32_t y, int32_t w, int32_t h, int32_t red, int32_t green, int32_t blue, int32_t alpha)
{
    const vec_t r = min(red, 255)*DIV255;
    const vec_t g = min(green, 255)*DIV255;
    const vec_t b = min(blue, 255)*DIV255;
    const vec_t a = max(min(alpha, 255), 1)*DIV255;

    const vec4_t color[4] = {
        {r, g, b, a},
        {r, g, b, a},
        {r, g, b, a},
        {r, g, b, a}
    };


    const vec3_t verts[4] = {
        {x, y, 0},
        {x+w, y, 0},
        {x+w, y+h, 0},
        {x, y+h, 0}
    };

//	GL_DisableTexture (0);
    GL_Disable (GL_ALPHA_TEST);
    GL_TexEnv (GL_MODULATE);
    GL_Enable (GL_BLEND);
    GL_DepthMask   (false);

    GL_Bind (glMedia.whitetexture->texnum);

    rb_vertex = rb_index = 0;

    memcpy(&indexArray[rb_index], indices, sizeof(indices));
    rb_index = 6;

    memcpy(vertexArray, verts, sizeof(vec3_t) * 4);
    memcpy(colorArray, color, sizeof(vec4_t) * 4);

    rb_vertex = 4;

    RB_RenderMeshGeneric (false);

    GL_DepthMask (true);
    GL_Disable (GL_BLEND);
    GL_TexEnv (GL_REPLACE);
    GL_Enable (GL_ALPHA_TEST);
//	GL_EnableTexture (0);
}
Beispiel #11
0
/*
================
R_FlushChars
================
*/
void R_FlushChars (void)
{
	if (rb_vertex == 0 || rb_index == 0) // nothing to flush
		return;

	GL_Disable (GL_ALPHA_TEST);
	GL_TexEnv (GL_MODULATE);
	GL_Enable (GL_BLEND);
	GL_DepthMask (false);
	GL_Bind(draw_chars->texnum);

	RB_RenderMeshGeneric (false);
	char_count = 0;

	GL_DepthMask (true);
	GL_Disable (GL_BLEND);
	GL_TexEnv (GL_REPLACE);
	GL_Enable (GL_ALPHA_TEST);
}
Beispiel #12
0
/*
======================
R_DrawFill

Fills a box of pixels with a
24-bit color w/ alpha
===========================
*/
void R_DrawFill (int32_t x, int32_t y, int32_t w, int32_t h, int32_t red, int32_t green, int32_t blue, int32_t alpha)
{
	int32_t		i;
	vec2_t	verts[4];

	red = min(red, 255);
	green = min(green, 255);
	blue = min(blue, 255);
	alpha = max(min(alpha, 255), 1);

//	GL_DisableTexture (0);
	GL_Disable (GL_ALPHA_TEST);
	GL_TexEnv (GL_MODULATE);
	GL_Enable (GL_BLEND);
	GL_DepthMask   (false);

	GL_Bind (glMedia.whitetexture->texnum);

	Vector2Set(verts[0], x, y);
	Vector2Set(verts[1], x+w, y);
	Vector2Set(verts[2], x+w, y+h);
	Vector2Set(verts[3], x, y+h);

	rb_vertex = rb_index = 0;
	indexArray[rb_index++] = rb_vertex+0;
	indexArray[rb_index++] = rb_vertex+1;
	indexArray[rb_index++] = rb_vertex+2;
	indexArray[rb_index++] = rb_vertex+0;
	indexArray[rb_index++] = rb_vertex+2;
	indexArray[rb_index++] = rb_vertex+3;
	for (i=0; i<4; i++) {
		VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0);
		VA_SetElem4(colorArray[rb_vertex], red*DIV255, green*DIV255, blue*DIV255, alpha*DIV255);
		rb_vertex++;
	}
	RB_RenderMeshGeneric (false);

	GL_DepthMask (true);
	GL_Disable (GL_BLEND);
	GL_TexEnv (GL_REPLACE);
	GL_Enable (GL_ALPHA_TEST);
//	GL_EnableTexture (0);
}
Beispiel #13
0
/*
 =============
 R_DrawTileImage
 
 This repeats a 64*64 tile graphic to fill the screen around a sized down
 refresh window.
 =============
 */
void R_DrawTileImage (int32_t x, int32_t y, int32_t w, int32_t h, image_t *image)
{
    int32_t		i;
    vec2_t	texCoord[4], verts[4];
    
    GL_Bind (image->texnum);
    /*
     Vector2Set(texCoord[0], x/64.0, y/64.0);
     Vector2Set(texCoord[1], (x+w)/64.0, y/64.0);
     Vector2Set(texCoord[2], (x+w)/64.0, (y+h)/64.0);
     Vector2Set(texCoord[3], x/64.0, (y+h)/64.0);
     */
    Vector2Set(texCoord[0], (float)x/(float)image->width, (float)y/(float)image->height);
    Vector2Set(texCoord[1], (float)(x+w)/(float)image->width, (float)y/(float)image->height);
    Vector2Set(texCoord[2], (float)(x+w)/(float)image->width, (float)(y+h)/(float)image->height);
    Vector2Set(texCoord[3], (float)x/(float)image->width, (float)(y+h)/(float)image->height);
    
    Vector2Set(verts[0], x, y);
    Vector2Set(verts[1], x+w, y);
    Vector2Set(verts[2], x+w, y+h);
    Vector2Set(verts[3], x, y+h);
    
    rb_vertex = rb_index = 0;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+1;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+3;
    for (i=0; i<4; i++) {
        VA_SetElem2(texCoordArray[0][rb_vertex], texCoord[i][0], texCoord[i][1]);
        VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0);
        VA_SetElem4(colorArray[rb_vertex], 1.0, 1.0, 1.0, 1.0);
        rb_vertex++;
    }
    RB_RenderMeshGeneric (false);
}
Beispiel #14
0
/*
 =============
 R_DrawScaledImage
 Psychospaz's code for drawing stretched crosshairs
 =============
 */
void R_DrawScaledImage (int32_t x, int32_t y, float scale, float alpha, image_t *gl)
{
    float	xoff, yoff;
    float	scale_x, scale_y;
    int32_t		i;
    vec2_t	texCoord[4], verts[4];
    
    if (scrap_dirty)
        Scrap_Upload ();
    
    // add alpha support
    if (gl->has_alpha || alpha < 1.0)
    {
        GL_Disable (GL_ALPHA_TEST);
        GL_TexEnv (GL_MODULATE);
        GL_Enable (GL_BLEND);
        GL_DepthMask (false);
    }
    
    GL_Bind (gl->texnum);
    
    scale_x = scale_y = scale;
    scale_x *= gl->replace_scale_w; // scale down if replacing a pcx image
    scale_y *= gl->replace_scale_h; // scale down if replacing a pcx image
    
    Vector2Set(texCoord[0], gl->sl, gl->tl);
    Vector2Set(texCoord[1], gl->sh, gl->tl);
    Vector2Set(texCoord[2], gl->sh, gl->th);
    Vector2Set(texCoord[3], gl->sl, gl->th);
    
    xoff = gl->width*scale_x-gl->width;
    yoff = gl->height*scale_y-gl->height;
    
    Vector2Set(verts[0], x, y);
    Vector2Set(verts[1], x+gl->width+xoff, y);
    Vector2Set(verts[2], x+gl->width+xoff, y+gl->height+yoff);
    Vector2Set(verts[3], x, y+gl->height+yoff);
    
    rb_vertex = rb_index = 0;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+1;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+0;
    indexArray[rb_index++] = rb_vertex+2;
    indexArray[rb_index++] = rb_vertex+3;
    for (i=0; i<4; i++) {
        VA_SetElem2(texCoordArray[0][rb_vertex], texCoord[i][0], texCoord[i][1]);
        VA_SetElem3(vertexArray[rb_vertex], verts[i][0], verts[i][1], 0);
        VA_SetElem4(colorArray[rb_vertex], 1.0, 1.0, 1.0, alpha);
        rb_vertex++;
    }
    RB_RenderMeshGeneric (false);
    
    if (gl->has_alpha || alpha < 1.0)
    {
        GL_DepthMask (true);
        GL_TexEnv (GL_REPLACE);
        GL_Disable (GL_BLEND);
        GL_Enable (GL_ALPHA_TEST); // add alpha support
    }
}
Beispiel #15
0
/*
 =============
 R_DrawScaledImage
 Psychospaz's code for drawing stretched crosshairs
 =============
 */
void R_DrawScaledImage (int32_t x, int32_t y, float scale, float alpha, image_t *gl)
{
    float	xoff, yoff;
    float	scale_x, scale_y;

    const vec4_t color[4] = {
        {1.0, 1.0, 1.0, alpha},
        {1.0, 1.0, 1.0, alpha},
        {1.0, 1.0, 1.0, alpha},
        {1.0, 1.0, 1.0, alpha}
    };

    if (scrap_dirty)
        Scrap_Upload ();

    // add alpha support
    if (gl->has_alpha || alpha < 1.0)
    {
        GL_Disable (GL_ALPHA_TEST);
        GL_TexEnv (GL_MODULATE);
        GL_Enable (GL_BLEND);
        GL_DepthMask (false);
    }

    GL_Bind (gl->texnum);

    scale_x = scale_y = scale;
    scale_x *= gl->replace_scale_w; // scale down if replacing a pcx image
    scale_y *= gl->replace_scale_h; // scale down if replacing a pcx image


    xoff = gl->width*scale_x-gl->width;
    yoff = gl->height*scale_y-gl->height;

    rb_vertex = rb_index = 0;

    memcpy(indexArray, indices, sizeof(indices));
    rb_index = 6;

    VA_SetElem2(texCoordArray[0][0], gl->sl, gl->tl);
    VA_SetElem2(texCoordArray[0][1], gl->sh, gl->tl);
    VA_SetElem2(texCoordArray[0][2], gl->sh, gl->th);
    VA_SetElem2(texCoordArray[0][3], gl->sl, gl->th);


    VA_SetElem3(vertexArray[0], x, y, 0);
    VA_SetElem3(vertexArray[1], x+gl->width+xoff, y, 0);
    VA_SetElem3(vertexArray[2], x+gl->width+xoff, y+gl->height+yoff, 0);
    VA_SetElem3(vertexArray[3], x, y+gl->height+yoff, 0);

    memcpy(colorArray, color, sizeof(vec4_t) * 4);

    rb_vertex = 4;


    RB_RenderMeshGeneric (false);

    if (gl->has_alpha || alpha < 1.0)
    {
        GL_DepthMask (true);
        GL_TexEnv (GL_REPLACE);
        GL_Disable (GL_BLEND);
        GL_Enable (GL_ALPHA_TEST); // add alpha support
    }
}