Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textures Manager #729

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
09093ae
resman: Implement texture methods stubs
vklachkov Jan 13, 2022
28bd6b9
resman: Minimal implementation of texture loading
vklachkov Jan 13, 2022
406dbe2
resman: Pass ref_interface_t to resource manager, save texture in mem
vklachkov Jan 13, 2022
f25ae90
resman: Check texture name
vklachkov Jan 13, 2022
b55c92a
resman: Implement cache
vklachkov Jan 13, 2022
bcbfb7c
resman: Generate stub entries for internal textures
vklachkov Jan 13, 2022
378aa88
resman: Implement RM_FindTexture
vklachkov Jan 13, 2022
067c534
resman: Set correct names for first six textures
vklachkov Jan 13, 2022
812af16
resman: Restore strange flags code
vklachkov Jan 13, 2022
697f3b3
resman: Stab more methods
vklachkov Jan 13, 2022
c0e7394
refgl: Dirty hack for get backtrace at texture n 121
vklachkov Jan 14, 2022
5074761
Checkout mainui t master branch
vklachkov Jan 14, 2022
1edd2f7
ref_gl: Remove dirty debug hack
vklachkov Jan 15, 2022
ee6669b
ref: Add RM_LoadTexture to ref_api_t
vklachkov Jan 15, 2022
6a1e1c3
ref_gl: Load some textures via engine, fix sprite glitches
vklachkov Jan 15, 2022
3c65550
resman: Implement RM_LoadTextureFromBuffer, fix more glitches
vklachkov Jan 15, 2022
54fc8a0
ref_gl: Load texture for sky via engine
vklachkov Jan 16, 2022
eea92a4
ref_api: Remove part of texture's methods, pass RM_* to RenderAPI
vklachkov Jan 16, 2022
d50edac
ref_soft: Load all textures via engine
vklachkov Jan 16, 2022
bde20c5
engine: Use remaining RM_* methods in render api
vklachkov Jan 16, 2022
61aa8e2
ref_api: Remove remaining texture tools from ref_interface_t
vklachkov Jan 16, 2022
e47c902
ref_gl: Use engine's RM_FreeTexture
vklachkov Jan 18, 2022
bbbc3e0
ref_gl: Remove unused methods
vklachkov Jan 18, 2022
8b2e6f3
Totally rework memory layout everywhere
vklachkov Apr 23, 2022
b14d5d7
resman: Subtract from textures_count on texture remove
vklachkov Apr 23, 2022
f3af112
resman: Restore internal textures
vklachkov Apr 25, 2022
4177fab
resman: Disable very noisy logs in RM_LoadTexture
vklachkov Apr 25, 2022
8648ce6
client: fix random crashes
vklachkov Apr 25, 2022
f72164d
resman: Implement ReuploadTextures, move CreateInternalTextures into …
vklachkov May 3, 2022
35ca0a4
ref_gl: Minor patch
vklachkov May 3, 2022
14bbe5c
ref_gl: Found standard textures in engine during initialization
vklachkov May 3, 2022
01eed00
resman: Rewrite FakeImage without static buffer
vklachkov May 3, 2022
e91d8db
resman: Create dlight textures, fix a lot of glitches
vklachkov May 4, 2022
3e6ade4
Fix ref_soft for new api
vklachkov May 5, 2022
3bb872b
resman: Minor clean up
vklachkov May 5, 2022
2c55163
Merge branch 'master' into resman_texture
vklachkov Jul 12, 2022
57de05c
resman: Implement RM_TextureName
vklachkov Jul 12, 2022
d7f2c47
resman: Minor changes
vklachkov Jul 12, 2022
d515c8a
resman: Implement RM_TextureData
vklachkov Jul 13, 2022
bcdb8b1
resman: Implement RM_CreateTexture and RM_CreateTextureArray
vklachkov Jul 13, 2022
cf5f074
resman: Implement ProcessFlags, replacement for GL_ProcessImage
vklachkov Jul 13, 2022
6aab155
resman: Implement RM_LoadTextureArray
vklachkov Jul 13, 2022
f78d7b3
Rename resman to texturelib and move to common
vklachkov Aug 7, 2022
f466496
texturelib: Code style fixes
vklachkov Aug 7, 2022
7bbc1da
texturelib: Use engine's Mem_Malloc instead of libc's malloc
vklachkov Aug 7, 2022
24c9474
texturelib: Set MAX_TEXTURES to 1024 when XASH_LOW_MEMORY
vklachkov Aug 7, 2022
d564c92
texturelib: Minor methods renames
vklachkov Aug 7, 2022
fd4d218
client: Remove useless macroses GL_*TextureInternal
vklachkov Aug 8, 2022
783538f
texturelib: Use string type from xash instead of chars array
vklachkov Aug 8, 2022
b94a08e
texturelib: Remove noisy logs
vklachkov Aug 8, 2022
269685d
reg_gl: Implement R_ShutdownImages
vklachkov Aug 8, 2022
374fc98
ref_gl: Restore comments
vklachkov Aug 8, 2022
5553d8a
ref_gl: Remove gl_numTextures
vklachkov Aug 8, 2022
1a23dac
ref_gl: Restore R_TextureList_f
vklachkov Aug 8, 2022
8b4562d
ref_gl: Restore some changes after bad merge
vklachkov Aug 8, 2022
d15ab39
texturelib: Remove texture after freeing in render
vklachkov Aug 8, 2022
d981fe7
ref_soft: Minor changes, restore most of comments
vklachkov Aug 8, 2022
4ce3d59
ref_soft: Restore R_TextureList_f
vklachkov Aug 8, 2022
b2d1283
ref_soft: Find standard textures in the engine
vklachkov Aug 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GNU General Public License for more details.
#include "vgui_draw.h"
#include "sound.h" // SND_STOP_LOOPING
#include "platform/platform.h"
#include "resman/resman.h"

#define MAX_LINELENGTH 80
#define MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels)
Expand Down
5 changes: 3 additions & 2 deletions engine/client/cl_gameui.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GNU General Public License for more details.
#include "input.h"
#include "server.h" // !!svgame.hInstance
#include "vid_common.h"
#include "resman/texture.h"

static void UI_UpdateUserinfo( void );

Expand Down Expand Up @@ -545,7 +546,7 @@ static HIMAGE GAME_EXPORT pfnPIC_Load( const char *szPicName, const byte *image_
SetBits( flags, TF_IMAGE );

Image_SetForceFlags( IL_LOAD_DECAL ); // allow decal images for menu
tx = ref.dllFuncs.GL_LoadTexture( szPicName, image_buf, image_size, flags );
tx = RM_LoadTexture( szPicName, image_buf, image_size, flags );
Image_ClearForceFlags();

return tx;
Expand Down Expand Up @@ -1091,7 +1092,7 @@ static void GAME_EXPORT pfnStartBackgroundTrack( const char *introTrack, const c

static void GAME_EXPORT GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
{
ref.dllFuncs.GL_ProcessTexture( texnum, gamma, topColor, bottomColor );
ref.dllFuncs.R_ProcessTexture( texnum, gamma, topColor, bottomColor );
}


Expand Down
2 changes: 2 additions & 0 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3063,6 +3063,8 @@ void CL_Init( void )

CL_InitLocal();

RM_Init(); // init resource manager

VID_Init(); // init video
S_Init(); // init sound

Expand Down
14 changes: 7 additions & 7 deletions engine/client/cl_remap.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t

// save off the real texture index
index = ptexture->index;
name = ref.dllFuncs.GL_TextureName( index );
name = RM_TextureName( index );
Q_snprintf( texname, sizeof( texname ), "#%i_%s", entity->curstate.number, name + 1 );

// search for pixels
Expand All @@ -128,7 +128,7 @@ void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotexture_t
memcpy( paletteBackup, pal, 768 );

raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor );
ptexture->index = ref.dllFuncs.GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy
ptexture->index = RM_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy

// restore original palette
memcpy( pal, paletteBackup, 768 );
Expand All @@ -153,15 +153,15 @@ void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, in
byte *raw, *pal;

// save off the real texture index
origtexname = ref.dllFuncs.GL_TextureName( ptexture->index );
origtexname = RM_TextureName( ptexture->index );

// build name of original texture
Q_strncpy( mdlname, entity->model->name, sizeof( mdlname ));
COM_FileBase( ptexture->name, name );
COM_StripExtension( mdlname );

Q_snprintf( texname, sizeof( texname ), "#%s/%s.mdl", mdlname, name );
index = ref.dllFuncs.GL_FindTexture( texname );
index = RM_LoadTexture( texname );
if( !index ) return; // couldn't find texture

// search for pixels
Expand Down Expand Up @@ -231,7 +231,7 @@ void CL_UpdateAliasTexture( cl_entity_t *entity, unsigned short *texture, int sk
}

// and now we can remap with internal routines
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
ref.dllFuncs.R_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
}

/*
Expand Down Expand Up @@ -402,11 +402,11 @@ void CL_FreeRemapInfo( remap_info_t *info )
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
RM_FreeTexture( info->ptexture[i].index );
}

if( info->textures[i] != 0 )
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
RM_FreeTexture( info->textures[i] );
}

Mem_Free( info ); // release struct
Expand Down
17 changes: 9 additions & 8 deletions engine/client/cl_render.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GNU General Public License for more details.
#include "client.h"
#include "library.h"
#include "platform/platform.h"
#include "resman/resman.h"

int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis )
{
Expand Down Expand Up @@ -285,14 +286,14 @@ static void R_FillRenderAPIFromRef( render_api_t *to, const ref_interface_t *fro
to->GetFrameTime = from->GetFrameTime;
to->R_SetCurrentEntity = from->R_SetCurrentEntity;
to->R_SetCurrentModel = from->R_SetCurrentModel;
to->GL_FindTexture = from->GL_FindTexture;
to->GL_TextureName = from->GL_TextureName;
to->GL_TextureData = from->GL_TextureData;
to->GL_LoadTexture = from->GL_LoadTexture;
to->GL_CreateTexture = from->GL_CreateTexture;
to->GL_LoadTextureArray = from->GL_LoadTextureArray;
to->GL_CreateTextureArray = from->GL_CreateTextureArray;
to->GL_FreeTexture = from->GL_FreeTexture;
to->GL_FindTexture = &RM_FindTexture;
vklachkov marked this conversation as resolved.
Show resolved Hide resolved
to->GL_TextureName = &RM_TextureName;
to->GL_TextureData = &RM_TextureData;
to->GL_LoadTexture = &RM_LoadTexture;
to->GL_CreateTexture = &RM_CreateTexture;
to->GL_LoadTextureArray = &RM_LoadTextureArray;
to->GL_CreateTextureArray = &RM_CreateTextureArray;
to->GL_FreeTexture = &RM_FreeTexture;
to->DrawSingleDecal = from->DrawSingleDecal;
to->R_DecalSetupVerts = from->R_DecalSetupVerts;
to->R_EntityRemoveDecals = from->R_EntityRemoveDecals;
Expand Down
22 changes: 12 additions & 10 deletions engine/client/cl_scrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void SCR_DrawPlaque( void )
{
if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
{
int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
int levelshot = RM_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING );
Expand Down Expand Up @@ -588,7 +588,7 @@ qboolean SCR_LoadFixedWidthFont( const char *fontname )
if( !FS_FileExists( fontname, false ))
return false;

cls.creditsFont.hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE );
cls.creditsFont.hFontTexture = RM_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE );
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
cls.creditsFont.charHeight = clgame.scrInfo.iCharHeight = fontWidth / 16;
cls.creditsFont.type = FONT_FIXED;
Expand Down Expand Up @@ -620,7 +620,7 @@ qboolean SCR_LoadVariableWidthFont( const char *fontname )
if( !FS_FileExists( fontname, false ))
return false;

cls.creditsFont.hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_IMAGE );
cls.creditsFont.hFontTexture = RM_LoadTexture( fontname, NULL, 0, TF_IMAGE );
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );

// half-life font with variable chars witdh
Expand Down Expand Up @@ -729,24 +729,26 @@ void SCR_RegisterTextures( void )
// register gfx.wad images

if( FS_FileExists( "gfx/paused.lmp", false ))
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
cls.pauseIcon = RM_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "gfx/pause.lmp", false ))
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
cls.pauseIcon = RM_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );

if( FS_FileExists( "gfx/lambda.lmp", false ))
{
if( cl_allow_levelshots->value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
cls.loadingBar = RM_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE | TF_LUMINANCE );
else
cls.loadingBar = RM_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
}
else if( FS_FileExists( "gfx/loading.lmp", false ))
{
if( cl_allow_levelshots->value )
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
cls.loadingBar = RM_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE | TF_LUMINANCE );
else
cls.loadingBar = RM_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
}

cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
cls.tileImage = RM_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
}

/*
Expand Down
2 changes: 1 addition & 1 deletion engine/client/cl_tent.c
Original file line number Diff line number Diff line change
Expand Up @@ -2969,7 +2969,7 @@ int GAME_EXPORT CL_DecalIndex( int id )
if( cl.decal_index[id] == 0 )
{
Image_SetForceFlags( IL_LOAD_DECAL );
cl.decal_index[id] = ref.dllFuncs.GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
cl.decal_index[id] = RM_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
Image_ClearForceFlags();
}

Expand Down
2 changes: 1 addition & 1 deletion engine/client/cl_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void V_PostRender( void )
SV_DrawOrthoTriangles();
CL_DrawDemoRecording();
CL_DrawHUD( CL_CHANGELEVEL );
ref.dllFuncs.R_ShowTextures();
//ref.dllFuncs.R_ShowTextures();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это планируется сделать в рамках текущего PR или оставить на потом?

R_ShowTree();
Con_DrawConsole();
UI_UpdateMenu( host.realtime );
Expand Down
21 changes: 11 additions & 10 deletions engine/client/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GNU General Public License for more details.
#include "qfont.h"
#include "wadfile.h"
#include "input.h"
#include "resman/resman.h"

convar_t *con_notifytime;
convar_t *scr_conspeed;
Expand Down Expand Up @@ -569,7 +570,7 @@ static qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font )
return false;

// keep source to print directly into conback image
font->hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE );
font->hFontTexture = RM_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE );
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );

if( font->hFontTexture && fontWidth != 0 )
Expand Down Expand Up @@ -605,7 +606,7 @@ static qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font
if( !FS_FileExists( fontname, false ))
return false;

font->hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST );
font->hFontTexture = RM_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST );
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );

// setup consolefont
Expand Down Expand Up @@ -2477,28 +2478,28 @@ void Con_VidInit( void )
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
con.background = RM_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );

if( !con.background )
{
if( FS_FileExists( "cached/conback640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
con.background = RM_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/conback", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
con.background = RM_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
}
}
else
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
con.background = RM_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );

if( !con.background )
{
if( FS_FileExists( "cached/loading640", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
con.background = RM_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/loading", false ))
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
con.background = RM_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
}
}

Expand Down Expand Up @@ -2533,13 +2534,13 @@ void Con_VidInit( void )
y = len;
for( x = 0; x < y; x++ )
Con_DrawCharToConback( ver[x], buf, dest + (x << 3));
con.background = ref.dllFuncs.GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
con.background = RM_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
}
if( cb ) Mem_Free( cb );
}

if( !con.background ) // trying the load unmodified conback
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE );
con.background = RM_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE );
}

// missed console image will be replaced as gray background like X-Ray or Crysis
Expand Down
7 changes: 4 additions & 3 deletions engine/client/in_touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GNU General Public License for more details.
#include "math.h"
#include "vgui_draw.h"
#include "mobility_int.h"
#include "resman/resman.h"

typedef enum
{
Expand Down Expand Up @@ -1138,7 +1139,7 @@ static void Touch_InitConfig( void )
else Touch_LoadDefaults_f( );

Touch_InitEditor();
touch.joytexture = ref.dllFuncs.GL_LoadTexture( touch_joy_texture->string, NULL, 0, TF_NOMIPMAP );
touch.joytexture = RM_LoadTexture( touch_joy_texture->string, NULL, 0, TF_NOMIPMAP );
touch.whitetexture = R_GetBuiltinTexture( REF_WHITE_TEXTURE );
touch.configchanged = false;
touch.config_loaded = true;
Expand Down Expand Up @@ -1319,7 +1320,7 @@ static void Touch_DrawButtons( touchbuttonlist_t *list )
{
if( button->texture == -1 )
{
button->texture = ref.dllFuncs.GL_LoadTexture( button->texturefile, NULL, 0, TF_NOMIPMAP );
button->texture = RM_LoadTexture( button->texturefile, NULL, 0, TF_NOMIPMAP );
}

if( FBitSet( B(flags), TOUCH_FL_DRAW_ADDITIVE ))
Expand Down Expand Up @@ -1454,7 +1455,7 @@ void Touch_Draw( void )
if( FBitSet( touch_joy_texture->flags, FCVAR_CHANGED ) )
{
ClearBits( touch_joy_texture->flags, FCVAR_CHANGED );
touch.joytexture = ref.dllFuncs.GL_LoadTexture( touch_joy_texture->string, NULL, 0, TF_NOMIPMAP );
touch.joytexture = RM_LoadTexture( touch_joy_texture->string, NULL, 0, TF_NOMIPMAP );
}
if( touch.move_button->type == touch_move )
{
Expand Down
18 changes: 10 additions & 8 deletions engine/client/ref_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "cl_tent.h"
#include "platform/platform.h"
#include "vid_common.h"
#include "resman/resman.h"
vklachkov marked this conversation as resolved.
Show resolved Hide resolved

struct ref_state_s ref;
ref_globals_t refState;
Expand All @@ -17,12 +18,6 @@ convar_t *gl_msaa_samples;
convar_t *gl_clear;
convar_t *r_refdll;

void R_GetTextureParms( int *w, int *h, int texnum )
{
if( w ) *w = REF_GET_PARM( PARM_TEX_WIDTH, texnum );
if( h ) *h = REF_GET_PARM( PARM_TEX_HEIGHT, texnum );
}

/*
================
GL_FreeImage
Expand All @@ -37,8 +32,8 @@ void GAME_EXPORT GL_FreeImage( const char *name )
if( !ref.initialized )
return;

if(( texnum = ref.dllFuncs.GL_FindTexture( name )) != 0 )
ref.dllFuncs.GL_FreeTexture( texnum );
if(( texnum = RM_FindTexture( name )) != 0 )
RM_FreeTexture( texnum );
}

void R_UpdateRefState( void )
Expand Down Expand Up @@ -338,6 +333,11 @@ static ref_api_t gEngfuncs =
FS_FileExists,
FS_AllowDirectPaths,

RM_LoadTexture,
RM_LoadTextureFromBuffer,
RM_FindTexture,
RM_FreeTexture,

R_Init_Video_,
R_Free_Video,

Expand Down Expand Up @@ -710,6 +710,8 @@ qboolean R_Init( void )
break;
}
}

RM_SetRender(&ref.dllFuncs);
vklachkov marked this conversation as resolved.
Show resolved Hide resolved

if( !success )
{
Expand Down
9 changes: 5 additions & 4 deletions engine/client/ref_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ extern struct ref_state_s ref;
extern ref_globals_t refState;

// handy API wrappers
void R_GetTextureParms( int *w, int *h, int texnum );
#define REF_GET_PARM( parm, arg ) ref.dllFuncs.RefGetParm( (parm), (arg) )
#define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( (name), (pic), (flags), false )
#define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( (name), (pic), (flags), true )
#define R_GetBuiltinTexture( name ) ref.dllFuncs.GL_LoadTexture( (name), 0, 0, 0 )
#define GL_LoadTextureInternal( name, pic, flags ) RM_LoadTextureFromBuffer( (name), (pic), (flags), false )
#define GL_UpdateTextureInternal( name, pic, flags ) RM_LoadTextureFromBuffer( (name), (pic), (flags), true )

#define R_GetTextureParms( WP, HP, T ) RM_GetTextureParams( WP, HP, T )
vklachkov marked this conversation as resolved.
Show resolved Hide resolved
#define R_GetBuiltinTexture( NAME ) RM_LoadTexture( NAME, 0, 0, 0 )

void GL_RenderFrame( const struct ref_viewpass_s *rvp );

Expand Down
Loading