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/gmod/IMaterialSystem.hpp | 163 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 cheat/gmod/IMaterialSystem.hpp (limited to 'cheat/gmod/IMaterialSystem.hpp') diff --git a/cheat/gmod/IMaterialSystem.hpp b/cheat/gmod/IMaterialSystem.hpp new file mode 100644 index 0000000..c9b9490 --- /dev/null +++ b/cheat/gmod/IMaterialSystem.hpp @@ -0,0 +1,163 @@ +#pragma once +#include "util.hpp" +#include "ISurface.hpp" + +using MaterialHandle_t = unsigned short; + +enum MaterialVarFlags_t { + MATERIAL_VAR_DEBUG = 1 << 0, + MATERIAL_VAR_NO_DEBUG_OVERRIDE = 1 << 1, + MATERIAL_VAR_NO_DRAW = 1 << 2, + MATERIAL_VAR_USE_IN_FILLRATE_MODE = 1 << 3, + + MATERIAL_VAR_VERTEXCOLOR = 1 << 4, + MATERIAL_VAR_VERTEXALPHA = 1 << 5, + MATERIAL_VAR_SELFILLUM = 1 << 6, + MATERIAL_VAR_ADDITIVE = 1 << 7, + MATERIAL_VAR_ALPHATEST = 1 << 8, + MATERIAL_VAR_MULTIPASS = 1 << 9, + MATERIAL_VAR_ZNEARER = 1 << 10, + MATERIAL_VAR_MODEL = 1 << 11, + MATERIAL_VAR_FLAT = 1 << 12, + MATERIAL_VAR_NOCULL = 1 << 13, + MATERIAL_VAR_NOFOG = 1 << 14, + MATERIAL_VAR_IGNOREZ = 1 << 15, + MATERIAL_VAR_DECAL = 1 << 16, + MATERIAL_VAR_ENVMAPSPHERE = 1 << 17, + MATERIAL_VAR_NOALPHAMOD = 1 << 18, + MATERIAL_VAR_ENVMAPCAMERASPACE = 1 << 19, + MATERIAL_VAR_BASEALPHAENVMAPMASK = 1 << 20, + MATERIAL_VAR_TRANSLUCENT = 1 << 21, + MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = 1 << 22, + MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = 1 << 23, + MATERIAL_VAR_OPAQUETEXTURE = 1 << 24, + MATERIAL_VAR_ENVMAPMODE = 1 << 25, + MATERIAL_VAR_SUPPRESS_DECALS = 1 << 26, + MATERIAL_VAR_HALFLAMBERT = 1 << 27, + MATERIAL_VAR_WIREFRAME = 1 << 28, +}; + +class ITexture { +public: + int GetActualWidth( ) { + return util::get_vfunc< 3, int >( this ); + } + + int GetActualHeight( ) { + return util::get_vfunc< 4, int >( this ); + } +}; + +class IMaterial { +public: + auto GetName( ) { + return util::get_vfunc< 0, const char* >( this ); + } + + auto GetTextureGroupName( ) { + return util::get_vfunc< 1, const char* >( this ); + } + + void IncrementReferenceCount( ) { + return util::get_vfunc< 14, void >( this ); + } + + void AlphaModulate( float alpha ) { + return util::get_vfunc< 27, void >( this, alpha ); + } + + void ColorModulate( float r, float g, float b ) { + return util::get_vfunc< 28, void >( this, r, g, b ); + } + + void SetMaterialVarFlag( MaterialVarFlags_t flag, bool on ) { + return util::get_vfunc< 29, void >( this, flag, on ); + } + + bool GetMaterialVarFlag( MaterialVarFlags_t flag ) { + return util::get_vfunc< 30, bool >( this, flag ); + } + + auto GetAlphaModulation( ) { + return util::get_vfunc< 44, float >( this ); + } + + void GetColorModulate( float* r, float* g, float* b ) { + return util::get_vfunc< 45, void >( this, r, g, b ); + } + + void Refresh( ) { + return util::get_vfunc< 37, void >( this ); + } +}; + +class IMaterialSystem +{ +public: + enum RenderTargetSizeMode_t { + RT_SIZE_NO_CHANGE = 0, // Only allowed for render targets that don't want a depth buffer + // (because if they have a depth buffer, the render target must be less than or equal to the size of the framebuffer). + RT_SIZE_DEFAULT = 1, // Don't play with the specified width and height other than making sure it fits in the framebuffer. + RT_SIZE_PICMIP = 2, // Apply picmip to the render target's width and height. + RT_SIZE_HDR = 3, // frame_buffer_width / 4 + RT_SIZE_FULL_FRAME_BUFFER = 4, // Same size as frame buffer, or next lower power of 2 if we can't do that. + RT_SIZE_OFFSCREEN = 5, // Target of specified size, don't mess with dimensions + RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP = 6 // Same size as the frame buffer, rounded up if necessary for systems that can't do non-power of two textures. + }; + + enum MaterialRenderTargetDepth_t { + MATERIAL_RT_DEPTH_SHARED = 0x0, + MATERIAL_RT_DEPTH_SEPARATE = 0x1, + MATERIAL_RT_DEPTH_NONE = 0x2, + MATERIAL_RT_DEPTH_ONLY = 0x3, + }; + + ImageFormat GetBackBufferFormat( ) { + return util::get_vfunc< 36, ImageFormat >( this ); + } + + IMaterial* CreateMaterial( const char* pMaterialName, void* pVMTKeyValues ) { + return util::get_vfunc< 83, IMaterial* >( this, pMaterialName, pVMTKeyValues ); + } + + IMaterial* FindMaterial( const char* pMaterialName, const char* pTextureGroupName = "Model textures", bool complain = true, const char* pComplainPrefix = nullptr ) { + return util::get_vfunc< 84, IMaterial* >( this, pMaterialName, pTextureGroupName, complain, pComplainPrefix ); + } + + MaterialHandle_t FirstMaterial( ) { + return util::get_vfunc< 86, MaterialHandle_t >( this ); + } + + MaterialHandle_t NextMaterial( MaterialHandle_t h ) { + return util::get_vfunc< 87, MaterialHandle_t >( this, h ); + } + + MaterialHandle_t InvalidMaterial( ) { + return util::get_vfunc< 88, MaterialHandle_t >( this ); + } + + IMaterial* GetMaterial( MaterialHandle_t h ) { + return util::get_vfunc< 89, IMaterial* >( this, h ); + } + + void BeginRenderTargetAllocation( ) { + return util::get_vfunc< 94, void >( this ); + } + + void EndRenderTargetAllocation( ) { + return util::get_vfunc< 95, void >( this ); + } + + ITexture* CreateNamedRenderTargetTextureEx( const char* name, int w, int h, RenderTargetSizeMode_t sizeMode, + ImageFormat format, MaterialRenderTargetDepth_t depth ) + { + const int textureFlags = 0x4 | 0x8; //TEXTUREFLAGS_CLAMPS, TEXTUREFLAGS_CLAMPT + const int renderTargetFlags = 0x1; //CREATERENDERTARGETFLAGS_HDR + return util::get_vfunc< 97, ITexture* >( this, name, w, h, sizeMode, format, depth, textureFlags, renderTargetFlags ); + } + + /*void* GetRenderContext( ) { + typedef IMatRenderContext*( __thiscall* GetRenderContextFn )( void* ); + return CallVFunction( this, 115 )( this ); + }*/ +}; \ No newline at end of file -- cgit v1.2.3