From 3d412a4b30a9f7c7f51ea6562e694315948bd3da Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 28 Nov 2018 16:00:02 +1300 Subject: cleaned up in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever. i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64 --- cheat/internal_rewrite/renderer.cpp | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 cheat/internal_rewrite/renderer.cpp (limited to 'cheat/internal_rewrite/renderer.cpp') diff --git a/cheat/internal_rewrite/renderer.cpp b/cheat/internal_rewrite/renderer.cpp new file mode 100644 index 0000000..3d22805 --- /dev/null +++ b/cheat/internal_rewrite/renderer.cpp @@ -0,0 +1,93 @@ +#include "renderer.hpp" +#include "interface.hpp" + +#undef CreateFont + + +drawings::c_fonts g_fonts; +drawings::c_drawings g_renderer; + +NAMESPACE_REGION( drawings ) + +c_fonts::font_t::font_t( std::string name, int size, + int weight, ulong_t flags ) : + m_name( name ), m_size( size ), + m_weight( weight ), m_flags( flags ) { + g_fonts.m_container.push_back( this ); +}; + +void c_fonts::font_t::initialize( ) { + m_font = g_csgo.m_surface( )->CreateFont( ); + g_csgo.m_surface( )->SetFontGlyphSet( + m_font, m_name.c_str( ), m_size, + m_weight, 0, 0, + m_flags + ); +} + +void c_fonts::initialize( ) { + for( auto& it : m_container ) { + it->initialize( ); + } +} + +void c_drawings::draw_string( const wchar_t* text, HFont font, int x, int y, const clr_t& color ) { + g_csgo.m_surface( )->DrawSetTextPos( x, y ); + g_csgo.m_surface( )->DrawSetTextFont( font ); + g_csgo.m_surface( )->DrawSetTextColor( color ); + g_csgo.m_surface( )->DrawPrintText( text, wcslen( text ) ); +} + +void c_drawings::draw_rect( int x, int y, int w, int h, const clr_t& color ) { + g_csgo.m_surface( )->DrawSetColor( color ); + g_csgo.m_surface( )->DrawFilledRect( x, y, x + w, y + h ); +} + +void c_drawings::draw_line( int x, int y, int x1, int y1, const clr_t& clr ) { + g_csgo.m_surface( )->DrawSetColor( clr ); + g_csgo.m_surface( )->DrawLine( x, y, x1, y1 ); +} + +void c_drawings::draw_box( int x, int y, int w, int h, const clr_t& clr ) { + draw_line( x, y, x + w, y, clr ); + draw_line( x + w, y, x + w, y + h, clr ); + draw_line( x, y + h, x + w + 1, y + h, clr ); + draw_line( x, y, x, y + h, clr ); +} + +void c_drawings::draw_circle( int x, int y, int r, const clr_t& col, int res ) { + g_csgo.m_surface( )->DrawSetColor( col ); + g_csgo.m_surface( )->DrawOutlinedCircle( x, y, r, res ); +} + +void c_drawings::draw_filled_circle( int x, int y, int r, const clr_t& col, int res ) { + vertex_t* v = ( vertex_t* )( _alloca( res * sizeof( vertex_t ) ) ); + const float step = M_PI * 2.0f / res; + + for( size_t i{ }; i < res; ++i ) { + float theta = i * step; + float x_off = r * cos( theta ); + float y_off = r * sin( theta ); + v[ i ].init( x + x_off, y + y_off ); + } + + draw_polygon( res, v, col ); +} + +void c_drawings::draw_line( const vec2_t& begin, const vec2_t& end, const clr_t& clr ) { + draw_line( ( int )begin.x, ( int )begin.y, ( int )end.x, ( int )end.y, clr ); +} + +void c_drawings::draw_polygon( int count, vertex_t* vertices, const clr_t& col ) { + static int texture = g_csgo.m_surface( )->CreateNewTextureID( true ); + + clr_t buf( 255, 255, 255 ); + + g_csgo.m_surface( )->DrawSetTextureRGBA( texture, ( byte* )( &buf ), 1, 1 ); + g_csgo.m_surface( )->DrawSetColor( col ); + g_csgo.m_surface( )->DrawSetTexture( texture ); + + g_csgo.m_surface( )->DrawTexturedPolygon( count, vertices ); +} + +END_REGION \ No newline at end of file -- cgit v1.2.3