Browse Source

game(client): fix touch drawing problems

pull/133/head
nillerusr 2 years ago
parent
commit
5c5d990c87
  1. 14
      game/client/touch.cpp

14
game/client/touch.cpp

@ -11,6 +11,7 @@
#include "filesystem.h" #include "filesystem.h"
#include "tier0/icommandline.h" #include "tier0/icommandline.h"
#include "vgui_controls/Button.h" #include "vgui_controls/Button.h"
#include "viewrender.h"
#define STB_RECT_PACK_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION
#include "stb_rect_pack.h" #include "stb_rect_pack.h"
@ -629,7 +630,6 @@ void CTouchControls::Paint( )
return; return;
CUtlLinkedList<CTouchButton*>::iterator it; CUtlLinkedList<CTouchButton*>::iterator it;
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
if( state == state_edit ) if( state == state_edit )
{ {
@ -663,9 +663,10 @@ void CTouchControls::Paint( )
} }
} }
m_pMesh = pRenderContext->GetDynamicMesh(); CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
int meshCount = 0; int meshCount = 0;
// Draw non-atlas touch textures
for( it = btns.begin(); it != btns.end(); it++ ) for( it = btns.begin(); it != btns.end(); it++ )
{ {
CTouchButton *btn = *it; CTouchButton *btn = *it;
@ -676,9 +677,9 @@ void CTouchControls::Paint( )
if( t->textureID ) if( t->textureID )
{ {
pRenderContext->Bind( g_pMatSystemSurface->DrawGetTextureMaterial(t->textureID) ); m_pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, g_pMatSystemSurface->DrawGetTextureMaterial(t->textureID) );
meshBuilder.Begin( m_pMesh, MATERIAL_QUADS, meshCount );
meshBuilder.Begin( m_pMesh, MATERIAL_QUADS, 1 );
rgba_t color(btn->color.r, btn->color.g, btn->color.b, btn->color.a); rgba_t color(btn->color.r, btn->color.g, btn->color.b, btn->color.a);
meshBuilder.Position3f( btn->x1*screen_w, btn->y1*screen_h, 0 ); meshBuilder.Position3f( btn->x1*screen_w, btn->y1*screen_h, 0 );
meshBuilder.Color4ubv( color ); meshBuilder.Color4ubv( color );
@ -701,6 +702,7 @@ void CTouchControls::Paint( )
meshBuilder.AdvanceVertexF<VTX_HAVEPOS | VTX_HAVECOLOR, 1>(); meshBuilder.AdvanceVertexF<VTX_HAVEPOS | VTX_HAVECOLOR, 1>();
meshBuilder.End(); meshBuilder.End();
m_pMesh->Draw(); m_pMesh->Draw();
} }
else if( !btn->texture->isInAtlas ) else if( !btn->texture->isInAtlas )
@ -711,7 +713,7 @@ void CTouchControls::Paint( )
} }
} }
pRenderContext->Bind( g_pMatSystemSurface->DrawGetTextureMaterial(touchTextureID) ); m_pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, g_pMatSystemSurface->DrawGetTextureMaterial(touchTextureID) );
meshBuilder.Begin( m_pMesh, MATERIAL_QUADS, meshCount ); meshBuilder.Begin( m_pMesh, MATERIAL_QUADS, meshCount );
for( it = btns.begin(); it != btns.end(); it++ ) for( it = btns.begin(); it != btns.end(); it++ )

Loading…
Cancel
Save