mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: move handling of AVI textures into the engine
This commit is contained in:
@@ -525,7 +525,6 @@ const ref_interface_t gReffuncs =
|
||||
R_SetupSky,
|
||||
|
||||
R_Set2DMode,
|
||||
R_DrawStretchRaw,
|
||||
R_DrawStretchPic,
|
||||
CL_FillRGBA,
|
||||
R_WorldToScreen,
|
||||
@@ -562,6 +561,7 @@ const ref_interface_t gReffuncs =
|
||||
R_GetDetailScaleForTexture,
|
||||
R_SetDetailScaleForTexture,
|
||||
|
||||
GL_CreateTexture,
|
||||
GL_FindTexture,
|
||||
GL_TextureName,
|
||||
GL_TextureData,
|
||||
@@ -569,7 +569,7 @@ const ref_interface_t gReffuncs =
|
||||
GL_FreeTexture,
|
||||
R_OverrideTextureSourceSize,
|
||||
|
||||
R_UploadStretchRaw,
|
||||
GL_UpdateTexture,
|
||||
|
||||
GL_Bind,
|
||||
|
||||
|
||||
129
ref/gl/gl_draw.c
129
ref/gl/gl_draw.c
@@ -55,120 +55,71 @@ void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, f
|
||||
|
||||
/*
|
||||
=============
|
||||
R_DrawStretchRaw
|
||||
GL_UpdateTexture
|
||||
|
||||
Upload raw BGRA pixel data to an existing texture
|
||||
=============
|
||||
*/
|
||||
void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty )
|
||||
void GL_UpdateTexture( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt )
|
||||
{
|
||||
byte *raw = NULL;
|
||||
gl_texture_t *tex;
|
||||
GLenum gl_format;
|
||||
|
||||
switch( fmt )
|
||||
{
|
||||
case PF_RGBA_32:
|
||||
gl_format = GL_RGBA;
|
||||
break;
|
||||
case PF_BGRA_32:
|
||||
gl_format = GL_BGRA;
|
||||
break;
|
||||
case PF_RGB_24:
|
||||
gl_format = GL_RGB;
|
||||
break;
|
||||
case PF_BGR_24:
|
||||
gl_format = GL_BGR;
|
||||
break;
|
||||
case PF_LUMINANCE:
|
||||
gl_format = GL_LUMINANCE;
|
||||
break;
|
||||
default:
|
||||
gEngfuncs.Con_DPrintf( S_ERROR "%s: unsupported pixel format %i\n", __func__, fmt );
|
||||
return;
|
||||
}
|
||||
|
||||
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 )
|
||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, cols );
|
||||
if( rows > glConfig.max_2d_texture_size )
|
||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, 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( XASH_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->size = cols * rows * 4;
|
||||
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();
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
R_UploadStretchRaw
|
||||
=============
|
||||
*/
|
||||
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data )
|
||||
{
|
||||
byte *raw = NULL;
|
||||
gl_texture_t *tex;
|
||||
|
||||
if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT ))
|
||||
{
|
||||
// check the dimensions
|
||||
width = NearestPOW( width, true );
|
||||
height = NearestPOW( height, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
width = bound( 128, width, glConfig.max_2d_texture_size );
|
||||
height = bound( 128, height, glConfig.max_2d_texture_size );
|
||||
}
|
||||
|
||||
if( cols != width || rows != height )
|
||||
{
|
||||
raw = GL_ResampleTexture( data, cols, rows, width, height, false );
|
||||
raw = GL_ResampleTexture( buffer, cols, rows, width, height, false );
|
||||
cols = width;
|
||||
rows = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
raw = (byte *)data;
|
||||
}
|
||||
raw = (byte *)buffer;
|
||||
|
||||
if( cols > glConfig.max_2d_texture_size )
|
||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, cols );
|
||||
if( rows > glConfig.max_2d_texture_size )
|
||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, rows );
|
||||
|
||||
tex = R_GetTexture( texture );
|
||||
GL_Bind( GL_KEEP_UNIT, texture );
|
||||
tex->width = cols;
|
||||
tex->height = rows;
|
||||
tex = R_GetTexture( texnum );
|
||||
GL_Bind( GL_KEEP_UNIT, texnum );
|
||||
|
||||
if( cols == tex->width && rows == tex->height )
|
||||
pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, gl_format, GL_UNSIGNED_BYTE, raw );
|
||||
else
|
||||
{
|
||||
tex->width = cols;
|
||||
tex->height = rows;
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, tex->format, cols, rows, 0, gl_format, GL_UNSIGNED_BYTE, raw );
|
||||
}
|
||||
|
||||
pglTexImage2D( GL_TEXTURE_2D, 0, tex->format, cols, rows, 0, GL_BGRA, GL_UNSIGNED_BYTE, raw );
|
||||
GL_ApplyTextureParams( tex );
|
||||
}
|
||||
|
||||
|
||||
@@ -1971,9 +1971,6 @@ static void GL_CreateInternalTextures( void )
|
||||
((uint *)pic->buffer)[x] = 0xFF000000;
|
||||
tr.blackTexture = GL_LoadTextureInternal( REF_BLACK_TEXTURE, pic, TF_COLORMAP );
|
||||
|
||||
// cinematic dummy
|
||||
pic = GL_FakeImage( 640, 100, 1, IMAGE_HAS_COLOR );
|
||||
tr.cinTexture = GL_LoadTextureInternal( "*cintexture", pic, TF_NOMIPMAP|TF_CLAMP );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -187,8 +187,6 @@ typedef struct
|
||||
int lightmapTextures[MAX_LIGHTMAPS];
|
||||
int dlightTexture; // custom dlight texture
|
||||
int skyboxTextures[SKYBOX_MAX_SIDES]; // skybox sides
|
||||
int cinTexture; // cinematic texture
|
||||
|
||||
int skytexturenum; // this not a gl_texturenum!
|
||||
int skyboxbasenum; // start with 5800
|
||||
|
||||
@@ -318,7 +316,7 @@ void R_ClearDecals( void );
|
||||
// gl_draw.c
|
||||
//
|
||||
void R_Set2DMode( qboolean enable );
|
||||
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data );
|
||||
void GL_UpdateTexture( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt );
|
||||
|
||||
//
|
||||
// gl_image.c
|
||||
@@ -459,7 +457,6 @@ void R_RenderFrame( const struct ref_viewpass_s *vp );
|
||||
void R_EndFrame( void );
|
||||
void R_ClearScene( void );
|
||||
void R_GetTextureParms( int *w, int *h, int texnum );
|
||||
void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty );
|
||||
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
||||
qboolean R_SpeedsMessage( char *out, size_t size );
|
||||
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
|
||||
|
||||
Reference in New Issue
Block a user