Пример #1
0
PDGL_API void pdglVertex2f(float x, float y)
{
	if(pglVertex2f)
		{ pglVertex2f(x, y); return; }
	pglVertex2f=pdglGetProcAddress("glVertex2f");
	pglVertex2f(x, y);
}
Пример #2
0
/*
==========
NetGraph_DrawRect

==========
*/
static void NetGraph_DrawRect( wrect_t *rect, byte colors[4] )
{
	pglColor4ubv( colors );	// color for this quad

	pglVertex2f( rect->left, rect->top );
	pglVertex2f( rect->left + rect->right, rect->top );
	pglVertex2f( rect->left + rect->right, rect->top + rect->bottom );
	pglVertex2f( rect->left, rect->top + rect->bottom );
}
Пример #3
0
/*
=================
R_Bloom_Quad
=================
*/
inline static void R_Bloom_Quad( int x, int y, int w, int h, float texwidth, float texheight )
{
    pglBegin( GL_QUADS );
    pglTexCoord2f( 0, texheight );
    pglVertex2f( x, y );
    pglTexCoord2f( 0, 0 );
    pglVertex2f( x, y+h );
    pglTexCoord2f( texwidth, 0 );
    pglVertex2f( x+w, y+h );
    pglTexCoord2f( texwidth, texheight );
    pglVertex2f( x+w, y );
    pglEnd();
}
Пример #4
0
/*
=================
R_Bloom_SamplePass
=================
*/
inline static void R_Bloom_SamplePass( int xpos, int ypos )
{
    pglBegin( GL_QUADS );
    pglTexCoord2f( 0, sampleText_tch );
    pglVertex2f( xpos, ypos );
    pglTexCoord2f( 0, 0 );
    pglVertex2f( xpos, ypos+sample_height );
    pglTexCoord2f( sampleText_tcw, 0 );
    pglVertex2f( xpos+sample_width, ypos+sample_height );
    pglTexCoord2f( sampleText_tcw, sampleText_tch );
    pglVertex2f( xpos+sample_width, ypos );
    pglEnd();
}
Пример #5
0
/*
=============
R_DrawStretchPic
=============
*/
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum )
{
	GL_Bind( GL_TEXTURE0, texnum );

	pglBegin( GL_QUADS );
		pglTexCoord2f( s1, t1 );
		pglVertex2f( x, y );

		pglTexCoord2f( s2, t1 );
		pglVertex2f( x + w, y );

		pglTexCoord2f( s2, t2 );
		pglVertex2f( x + w, y + h );

		pglTexCoord2f( s1, t2 );
		pglVertex2f( x, y + h );
	pglEnd();
}
Пример #6
0
/*
================
VGUI_DrawQuad

generic method to fill rectangle
================
*/
void VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr )
{
	ASSERT( ul != NULL && lr != NULL );

	pglBegin( GL_QUADS );
		pglTexCoord2f( ul->coord[0], ul->coord[1] );
		pglVertex2f( ul->point[0], ul->point[1] );

		pglTexCoord2f( lr->coord[0], ul->coord[1] );
		pglVertex2f( lr->point[0], ul->point[1] );

		pglTexCoord2f( lr->coord[0], lr->coord[1] );
		pglVertex2f( lr->point[0], lr->point[1] );

		pglTexCoord2f( ul->coord[0], lr->coord[1] );
		pglVertex2f( ul->point[0], lr->point[1] );
	pglEnd();
}
Пример #7
0
/*
=================
R_Bloom_DrawEffect
=================
*/
static void R_Bloom_DrawEffect( void )
{
    GL_Bind( GL_TEXTURE0, r_bloomeffecttexture );
    pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
    pglColor4f( r_bloom_alpha->value, r_bloom_alpha->value, r_bloom_alpha->value, 1.0f );
    pglBlendFunc( GL_ONE, GL_ONE );
    pglEnable( GL_BLEND );

    pglBegin( GL_QUADS );
    pglTexCoord2f( 0, sampleText_tch );
    pglVertex2f( curView_x, curView_y );
    pglTexCoord2f( 0, 0 );
    pglVertex2f( curView_x, curView_y+curView_height );
    pglTexCoord2f( sampleText_tcw, 0 );
    pglVertex2f( curView_x+curView_width, curView_y+curView_height );
    pglTexCoord2f( sampleText_tcw, sampleText_tch );
    pglVertex2f( curView_x+curView_width, curView_y );
    pglEnd();

    pglDisable( GL_BLEND );
}
Пример #8
0
/*
=============
Draw_TileClear

This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
void R_DrawTileClear( int x, int y, int w, int h )
{
	float		tw, th;
	gltexture_t	*glt;

	GL_SetRenderMode( kRenderNormal );
	pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
	GL_Bind( GL_TEXTURE0, cls.tileImage );

	glt = R_GetTexture( cls.tileImage );
	tw = glt->srcWidth;
	th = glt->srcHeight;

	pglBegin( GL_QUADS );
		pglTexCoord2f( x / tw, y / th );
		pglVertex2f( x, y );
		pglTexCoord2f((x + w) / tw, y / th );
		pglVertex2f( x + w, y );
		pglTexCoord2f((x + w) / tw, (y + h) / th );
		pglVertex2f( x + w, y + h );
		pglTexCoord2f( x / tw, (y + h) / th );
		pglVertex2f( x, y + h );
	pglEnd ();
}
Пример #9
0
/*
=============
R_DrawStretchRaw
=============
*/
void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty )
{
	byte		*raw = NULL;
	gltexture_t	*tex;

	if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT ))
	{
		int	width = 1, height = 1;
	
		// check the dimensions
		width = NearestPOW( cols, true );
		height = NearestPOW( rows, false );

		if( cols != width || rows != height )
		{
			raw = GL_ResampleTexture( data, cols, rows, width, height, false );
			cols = width;
			rows = height;
		}
	}
	else
	{
		raw = (byte *)data;
	}

	if( cols > glConfig.max_2d_texture_size )
		Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", cols );
	if( rows > glConfig.max_2d_texture_size )
		Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", rows );

	pglDisable( GL_BLEND );
	pglDisable( GL_ALPHA_TEST );
	pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );

	tex = R_GetTexture( tr.cinTexture );
	GL_Bind( GL_TEXTURE0, tr.cinTexture );

	if( cols == tex->width && rows == tex->height )
	{
		if( dirty )
		{
			pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_BGRA, GL_UNSIGNED_BYTE, raw );
		}
	}
	else
	{
		tex->width = cols;
		tex->height = rows;
		if( dirty )
		{
			pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, cols, rows, 0, GL_BGRA, GL_UNSIGNED_BYTE, raw );
		}
	}

	pglBegin( GL_QUADS );
	pglTexCoord2f( 0, 0 );
	pglVertex2f( x, y );
	pglTexCoord2f( 1, 0 );
	pglVertex2f( x + w, y );
	pglTexCoord2f( 1, 1 );
	pglVertex2f( x + w, y + h );
	pglTexCoord2f( 0, 1 );
	pglVertex2f( x, y + h );
	pglEnd();
}
Пример #10
0
/*
===============
R_ShowTextures

Draw all the images to the screen, on top of whatever
was there.  This is used to test for texture thrashing.
===============
*/
void R_ShowTextures( void )
{
	gltexture_t	*image;
	float		x, y, w, h;
	int		i, j, k, base_w, base_h;
	int		total, start, end;
	rgba_t		color = { 192, 192, 192, 255 };
	int		charHeight, numTries = 0;
	static qboolean	showHelp = true;
	string		shortname;

	if( !gl_showtextures->integer )
		return;

	if( showHelp )
	{
		CL_CenterPrint( "use '<-' and '->' keys to view all the textures", 0.25f );
		showHelp = false;
	}

	pglClear( GL_COLOR_BUFFER_BIT );
	pglFinish();

	base_w = 8;
	base_h = 6;

rebuild_page:
	total = base_w * base_h;
	start = total * (gl_showtextures->integer - 1);
	end = total * gl_showtextures->integer;
	if( end > MAX_TEXTURES ) end = MAX_TEXTURES;

	w = glState.width / (float)base_w;
	h = glState.height / (float)base_h;

	Con_DrawStringLen( NULL, NULL, &charHeight );

	for( i = j = 0; i < MAX_TEXTURES; i++ )
	{
		image = R_GetTexture( i );
		if( j == start ) break; // found start
		if( pglIsTexture( image->texnum )) j++;
	}

	if( i == MAX_TEXTURES && gl_showtextures->integer != 1 )
	{
		// bad case, rewind to one and try again
		Cvar_SetFloat( "r_showtextures", max( 1, gl_showtextures->integer - 1 ));
		if( ++numTries < 2 ) goto rebuild_page;	// to prevent infinite loop
	}

	for( k = 0; i < MAX_TEXTURES; i++ )
	{
		if( j == end ) break; // page is full

		image = R_GetTexture( i );
		if( !pglIsTexture( image->texnum ))
			continue;

		x = k % base_w * w;
		y = k / base_w * h;

		pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
		GL_Bind( XASH_TEXTURE0, i ); // NOTE: don't use image->texnum here, because skybox has a 'wrong' indexes

		if(( image->flags & TF_DEPTHMAP ) && !( image->flags & TF_NOCOMPARE ))
			pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE );

		pglBegin( GL_QUADS );
		pglTexCoord2f( 0, 0 );
		pglVertex2f( x, y );
		if( image->flags & TF_TEXTURE_RECTANGLE )
			pglTexCoord2f( image->width, 0 );
		else pglTexCoord2f( 1, 0 );
		pglVertex2f( x + w, y );
		if( image->flags & TF_TEXTURE_RECTANGLE )
			pglTexCoord2f( image->width, image->height );
		else pglTexCoord2f( 1, 1 );
		pglVertex2f( x + w, y + h );
		if( image->flags & TF_TEXTURE_RECTANGLE )
			pglTexCoord2f( 0, image->height );
		else pglTexCoord2f( 0, 1 );
		pglVertex2f( x, y + h );
		pglEnd();

		if(( image->flags & TF_DEPTHMAP ) && !( image->flags & TF_NOCOMPARE ))
			pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB );

		FS_FileBase( image->name, shortname );
		if( Q_strlen( shortname ) > 18 )
		{
			// cutoff too long names, it looks ugly
			shortname[16] = '.';
			shortname[17] = '.';
			shortname[18] = '\0';
		}
		Con_DrawString( x + 1, y + h - charHeight, shortname, color );
		j++, k++;
	}

	CL_DrawCenterPrint ();
	pglFinish();
}
Пример #11
0
void 
blitter_opengl_update()
{
    float VALA=512/(float)visible_area.w-1.0; /* 240.0f*2.0f/304.0f - 1.0f */
    int VALB=.0625; /* 16.0f/256.0f  */
    int VALC=.9375; /* 240.0f/256.0f */
//int VALD .25   /* 64.0f/256.0f */
    int VALD=1.0;

    if (neffect == 0) {
#ifndef USE_GL2

	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer->pixels + (visible_area.x<<1));
	pglBegin(GL_QUADS);
	//pglTexCoord2f(16.0f/256.0f, 16.0f/256.0f);
	//pglVertex2f	(-1.0f, 1.0f);
	pglTexCoord2f(0.0f, 16.0f/256.0f);
	pglVertex2f  (-1.0f, 1.0f);

	pglTexCoord2f(1.0f, 16.0f/256.0f);
	pglVertex2f  (VALA, 1.0f);
			
	pglTexCoord2f(1.0f, 1.0f-16.0f/256.0f);
	pglVertex2f  (VALA, -1.0f);
			
	pglTexCoord2f(0.0f, 1.0f-16.0f/256.0f);
	pglVertex2f	(-1.0f, -1.0f);
	pglEnd();
				
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 64, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer->pixels + 512+ (visible_area.x<<1));
	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 16.0f/256.0f);
	pglVertex2f	(VALA, 1.0f);
			
	pglTexCoord2f(1.0, 16.0f/256.0f);
	pglVertex2f	(1.0f, 1.0f);
			
	pglTexCoord2f(1.0, 1.0f-16.0f/256.0f);
	pglVertex2f	(1.0f, -1.0f);
			
	pglTexCoord2f(0.0f, 1.0f-16.0f/256.0f);
	pglVertex2f	(VALA, -1.0f);
	pglEnd();

#else
	SDL_BlitSurface(buffer, &visible_area, tex_opengl, NULL);
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, tex_opengl->pixels);

	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f  (-1.0f, 1.0f);
	
	pglTexCoord2f((float)visible_area.w/512.0f, 0.0f);
	pglVertex2f  (1.0f, 1.0f);
			
	pglTexCoord2f((float)visible_area.w/512.0f, 1.0f-32.0f/256.0f);
	pglVertex2f  (1.0f, -1.0f);
			
	pglTexCoord2f(0.0f, 1.0f-32.0f/256.0f);
	pglVertex2f	(-1.0f, -1.0f);
	pglEnd();
		
#endif

    } 
    else
    {		
#ifndef USE_GL2
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels );
	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f	(-1.0f, 1.0f);
			
	pglTexCoord2f(1.0f, 0.0f);
	pglVertex2f	(a, 1.0f);
			
	pglTexCoord2f(1.0f, c);
	pglVertex2f	(a, 0.0f);
			
	pglTexCoord2f(0.0f, c);
	pglVertex2f	(-1.0f, 0.0f);
	pglEnd();
		
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + 512 );
	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f	(a, 1.0f);
			
	pglTexCoord2f(1.0f, 0.0f);
	pglVertex2f	(b, 1.0f);
			
	pglTexCoord2f(1.0f, c);
	pglVertex2f	(b, 0.0f);
			
	pglTexCoord2f(0.0f, c);
	pglVertex2f	(a, 0.0f);
	pglEnd();
				
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + 1024 );
	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f	(b, 1.0f);
			
	pglTexCoord2f(d, 0.0f);
	pglVertex2f	(1.0f, 1.0f);
			
	pglTexCoord2f(d, c);
	pglVertex2f	(1.0f, 0.0f);
			
	pglTexCoord2f(0.0f, c);
	pglVertex2f	(b, 0.0f);
	pglEnd();	
				
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + (visible_area.w<<2) * 224 );
	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f	(-1.0f, 0.0f);
			
	pglTexCoord2f(1.0f, 0.0f);
	pglVertex2f	(a, 0.0f);
			
	pglTexCoord2f(1.0f, c);
	pglVertex2f	(a, -1.0f);
			
	pglTexCoord2f(0.0f, c);
	pglVertex2f	(-1.0f, -1.0f);
	pglEnd();
				
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + (visible_area.w<<2) * 224 + 512 );
	pglBegin(GL_QUADS);		
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f	(a, 0.0f);
			
	pglTexCoord2f(1.0f, 0.0f);
	pglVertex2f	(b, 0.0f);
			
	pglTexCoord2f(1.0f, c);
	pglVertex2f	(b, -1.0f);
			
	pglTexCoord2f(0.0f, c);
	pglVertex2f	(a, -1.0f);
	pglEnd();
		
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + (visible_area.w<<2) * 224 + 1024 );
	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f	(b, 0.0f);
			
	pglTexCoord2f(d, 0.0f);
	pglVertex2f	(1.0f, 0.0f);
			
	pglTexCoord2f(d, c);
	pglVertex2f	(1.0f, -1.0f);
			
	pglTexCoord2f(0.0f, c);
	pglVertex2f	(b, -1.0f);
	pglEnd();
#else
	SDL_BlitSurface(screen, &glrectef, tex_opengl, NULL);
	pglTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 512, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, tex_opengl->pixels);

	pglBegin(GL_QUADS);
	pglTexCoord2f(0.0f, 0.0f);
	pglVertex2f  (-1.0f, 1.0f);
	
	pglTexCoord2f((float)visible_area.w*2/1024.0f, 0.0f);
	pglVertex2f  (1.0f, 1.0f);
			
	pglTexCoord2f((float)visible_area.w*2/1024.0f, 448.0f/512.0f);
	pglVertex2f  (1.0f, -1.0f);
			
	pglTexCoord2f(0.0f, 448.0f/512.0f);
	pglVertex2f	(-1.0f, -1.0f);
	pglEnd();
#endif
    }
	
    SDL_GL_SwapBuffers();	
}