Merge pull request #64 from nullifiedcat/porting-hl2dm

Porting hl2dm
This commit is contained in:
nullifiedcat 2017-04-19 17:01:57 +03:00 committed by GitHub
commit c1ce57664a
9 changed files with 273 additions and 44 deletions

View File

@ -58,12 +58,12 @@ void EffectChams::Init() {
void EffectChams::BeginRenderChams() {
drawing = true;
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
}
void EffectChams::EndRenderChams() {
drawing = false;
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
g_IVModelRender->ForcedMaterialOverride(nullptr);
}
@ -141,7 +141,7 @@ bool EffectChams::ShouldRenderChams(IClientEntity* entity) {
}
void EffectChams::RenderChams(int idx) {
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
IClientEntity* entity = g_IEntityList->GetClientEntity(idx);
if (entity && !entity->IsDormant()) {
if (ShouldRenderChams(entity)) {
@ -170,7 +170,7 @@ void EffectChams::Render(int x, int y, int w, int h) {
if (!init) Init();
if (!cathook || (g_IEngine->IsTakingScreenshot() && clean_screenshots)) return;
if (!enable) return;
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
BeginRenderChams();
for (int i = 1; i < HIGHEST_ENTITY; i++) {
IClientEntity* ent = g_IEntityList->GetClientEntity(i);

View File

@ -71,7 +71,11 @@ static CTextureReference buffers[4] {};
ITexture* GetBuffer(int i) {
if (!buffers[i]) {
ITexture* fullframe = g_IMaterialSystem->FindTexture("_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET);
ITexture* fullframe;
if (TF2)
fullframe = g_IMaterialSystem->FindTexture("_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET);
else
fullframe = g_IMaterialSystemHL->FindTexture("_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET);
char* newname = new char[32];
std::string name = format("_cathook_buff", i);
strncpy(newname, name.c_str(), 30);
@ -80,8 +84,15 @@ ITexture* GetBuffer(int i) {
int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT | TEXTUREFLAGS_EIGHTBITALPHA;
int renderTargetFlags = CREATERENDERTARGETFLAGS_HDR;
ITexture* texture = g_IMaterialSystem->CreateNamedRenderTargetTextureEx( newname, fullframe->GetActualWidth(), fullframe->GetActualHeight(), RT_SIZE_LITERAL, IMAGE_FORMAT_RGBA8888,
MATERIAL_RT_DEPTH_SEPARATE, textureFlags, renderTargetFlags );
ITexture* texture;
if (TF2) {
texture = g_IMaterialSystem->CreateNamedRenderTargetTextureEx( newname, fullframe->GetActualWidth(), fullframe->GetActualHeight(), RT_SIZE_LITERAL, IMAGE_FORMAT_RGBA8888,
MATERIAL_RT_DEPTH_SEPARATE, textureFlags, renderTargetFlags );
} else {
texture = g_IMaterialSystemHL->CreateNamedRenderTargetTextureEx( newname, fullframe->GetActualWidth(), fullframe->GetActualHeight(), RT_SIZE_LITERAL, IMAGE_FORMAT_RGBA8888,
MATERIAL_RT_DEPTH_SEPARATE, textureFlags, renderTargetFlags );
}
buffers[i].Init(texture);
}
return buffers[i];
@ -243,7 +254,7 @@ bool EffectGlow::ShouldRenderGlow(IClientEntity* entity) {
void EffectGlow::BeginRenderGlow() {
drawing = true;
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
ptr->ClearColor4ub(0, 0, 0, 0);
ptr->PushRenderTargetAndViewport();
ptr->SetRenderTarget(GetBuffer(1));
@ -256,7 +267,7 @@ void EffectGlow::BeginRenderGlow() {
void EffectGlow::EndRenderGlow() {
drawing = false;
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
ptr->DepthRange(0.0f, 1.0f);
g_IVModelRender->ForcedMaterialOverride(nullptr);
ptr->PopRenderTargetAndViewport();
@ -270,7 +281,7 @@ static CatVar solid_when(solid_when_enum, "glow_solid_when", "0", "Solid when",
void EffectGlow::StartStenciling() {
ShaderStencilState_t state;
state.m_bEnable = true;
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
switch ((int)solid_when) {
case 0:
SS_NeverSolid.SetStencilState(ptr);
@ -292,7 +303,7 @@ void EffectGlow::StartStenciling() {
void EffectGlow::EndStenciling() {
g_IVModelRender->ForcedMaterialOverride(nullptr);
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
ShaderStencilState_t state {};
state.SetStencilState(ptr);
ptr->DepthRange(0.0f, 1.0f);
@ -308,7 +319,6 @@ void EffectGlow::DrawToBuffer(IClientEntity* entity) {
}
void EffectGlow::DrawEntity(IClientEntity* entity) {
g_IVModelRender->ForcedMaterialOverride(mat_unlit_z);
entity->DrawModel(1);
IClientEntity* attach = g_IEntityList->GetClientEntity(*(int*)((uintptr_t)entity + netvar.m_Collision - 24) & 0xFFF);
int passes = 0;
@ -321,13 +331,14 @@ void EffectGlow::DrawEntity(IClientEntity* entity) {
}
void EffectGlow::RenderGlow(IClientEntity* entity) {
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
int color = GlowColor(entity);
unsigned char _b = (color >> 16) & 0xFF;
unsigned char _g = (color >> 8) & 0xFF;
unsigned char _r = (color) & 0xFF;
float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f };
g_IVRenderView->SetColorModulation(color_1);
g_IVModelRender->ForcedMaterialOverride(mat_unlit_z);
DrawEntity(entity);
}
@ -335,7 +346,7 @@ void EffectGlow::Render(int x, int y, int w, int h) {
if (!init) Init();
if (!cathook || (g_IEngine->IsTakingScreenshot() && clean_screenshots) || g_Settings.bInvalid) return;
if (!enable) return;
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
ITexture* orig = ptr->GetRenderTarget();
BeginRenderGlow();
for (int i = 1; i < HIGHEST_ENTITY; i++) {

View File

@ -129,6 +129,8 @@ constexpr T _clamp(T _min, T _max, T _val) {
#endif
#define GET_RENDER_CONTEXT (TF2 ? g_IMaterialSystem->GetRenderContext() : g_IMaterialSystemHL->GetRenderContext())
/*#define ADD_HACK(x) \
hack::AddHack(g_ph##x = new x());

View File

@ -78,8 +78,200 @@ void Init() {
MainList().AddChild(new ItemSublist("Cheat Settings", nullptr));*/
}
List& MainList() {
static List* main = List::FromString(R"(
static const std::string list_hl2dm = R"(
"Cat Hook"
"Aim Bot" [
"Aim Bot Menu"
"aimbot_enabled"
"aimbot_aimkey"
"aimbot_aimkey_mode"
"aimbot_autoshoot"
"aimbot_silent"
"aimbot_hitboxmode"
"aimbot_fov"
"aimbot_prioritymode"
"aimbot_projectile"
"aimbot_proj_fovpred"
"aimbot_proj_vispred"
"aimbot_interp"
"Preferences" [
"Aim Bot Preferences"
"aimbot_only_when_can_shoot"
"aimbot_enable_attack_only"
"aimbot_maxrange"
"aimbot_teammates"
"aimbot_zoomed"
"aimbot_hitbox"
"Projectile Aimbot" [
"Projectile Aimbot Tweaks"
"aimbot_proj_gravity"
"aimbot_proj_speed"
]
]
]
"Trigger Bot" [
"Trigger Bot Menu"
"trigger_enabled"
"trigger_accuracy"
"trigger_range"
"trigger_hitbox"
]
"Chams" [
"Chams Menu"
"chams_enable"
"chams_health"
"chams_players"
"chams_teammates"
"chams_flat"
"chams_weapons"
"chams_medkits"
"chams_ammo"
]
"Glow" [
"Glow Menu"
"glow_enable"
"glow_solid_when"
"glow_blur_scale"
"glow_health"
"glow_players"
"glow_teammates"
"glow_medkits"
"glow_ammo"
"glow_stickies"
]
"ESP" [
"ESP Menu"
"esp_enabled"
"font_esp_family"
"font_esp_height"
"esp_name"
"esp_distance"
"esp_box"
"esp_box_text_position"
"esp_box_nodraw"
"esp_box_expand"
"3D Box" [
"3D Box Settings"
"esp_3d_box"
"esp_3d_box_thick"
"esp_3d_box_health"
"esp_3d_box_expand"
"esp_3d_box_smoothing"
"esp_3d_box_expand_size"
"esp_3d_box_healthbar"
]
"esp_legit"
"esp_health_num"
"esp_model_name"
"esp_weapon"
"esp_vischeck"
"esp_entity_id"
"esp_followbot_id"
"esp_teammates"
"esp_entity"
"esp_buildings"
"esp_local"
"Items" [
"Item ESP Menu"
"esp_item"
"esp_item_health"
"esp_item_ammo"
"esp_item_weapons"
"esp_money_red"
"esp_money"
]
]
"Anti-Aim" [
"Anti-Aim Menu"
"aa_enabled"
"aa_pitch"
"aa_pitch_mode"
"aa_yaw"
"aa_yaw_mode"
"aa_spin"
"aa_roll"
"aa_no_clamp"
"Anti-Anti-AA" [
"Anti-Anti-Anti-Aim Menu"
"aa_aaaa_enabled"
"aa_aaaa_interval"
"aa_aaaa_interval_low"
"aa_aaaa_interval_high"
"aa_aaaa_mode"
"aa_aaaa_flip_key"
]
]
"Airstuck" [
"Airstuck Menu"
"airstuck"
"airstuck_toggle"
]
"Chat" [
"Chat Options Menu"
"killsay"
"spam"
"spam_newlines"
"clean_chat"
]
"Miscellaneous" [
"Miscellaneous Settings"
"enabled"
"fast_outline"
"no_arms"
"bhop_enabled"
"fov"
"rollspeedhack"
"fast_vischeck"
"anti_afk"
"flashlight"
"no_visuals"
"clean_screenshots"
"logo"
"debug_info"
"log"
]
"Follow Bot" [
"Follow Bot Settings"
"fb_bot"
"fb_mimic_slot"
"fb_always_medigun"
"fb_autoclass"
]
"GUI" [
"GUI Settings"
"gui_color_b"
"gui_color_g"
"gui_color_r"
"gui_rainbow"
"gui_bounds"
"gui_nullcore"
"gui_visible"
]
"Radar" [
"Radar Menu"
"radar"
"radar_size"
"radar_zoom"
"radar_health"
"radar_enemies_top"
"radar_icon_size"
"radar_x"
"radar_y"
]
)";
static const std::string list_tf2 = R"(
"Cat Hook"
"Aim Bot" [
"Aim Bot Menu"
@ -377,7 +569,10 @@ List& MainList() {
"radar_x"
"radar_y"
]
)");
)";
List& MainList() {
static List* main = List::FromString(TF2 ? list_tf2 : list_hl2dm);
return *main;
}

View File

@ -179,14 +179,16 @@ void hack::Initialize() {
hack::command_stack().push("cat_spam_reload");
logging::Info("Hooked!");
playerlist::Load();
effect_chams::g_pEffectChams = new CScreenSpaceEffectRegistration("_cathook_chams", &effect_chams::g_EffectChams);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_chams");
effect_chams::g_EffectChams.Init();
effect_glow::g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &effect_glow::g_EffectGlow);
if (TF2 || HL2DM) {
effect_chams::g_pEffectChams = new CScreenSpaceEffectRegistration("_cathook_chams", &effect_chams::g_EffectChams);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_chams");
effect_chams::g_EffectChams.Init();
effect_glow::g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &effect_glow::g_EffectGlow);
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow");
}
//for (CScreenSpaceEffectRegistration* reg = *g_ppScreenSpaceRegistrationHead; reg; reg = reg->m_pNext) {
// logging::Info("%s", reg->m_pEffectName);
//}
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow");
logging::Info("SSE enabled..");
}

View File

@ -28,7 +28,6 @@ IVEngineClient013* g_IEngine = nullptr;
vgui::ISurface* g_ISurface = nullptr;
vgui::IPanel* g_IPanel = nullptr;
IClientEntityList* g_IEntityList = nullptr;
ICenterPrint* g_ICenterPrint = nullptr;
ICvar* g_ICvar = nullptr;
IGameEventManager2* g_IEventManager2 = nullptr;
IBaseClientDLL* g_IBaseClient = nullptr;
@ -39,7 +38,6 @@ CGlobalVarsBase* g_GlobalVars = nullptr;
IPrediction* g_IPrediction = nullptr;
IGameMovement* g_IGameMovement = nullptr;
IInput* g_IInput = nullptr;
IMatSystemSurface* g_IMatSystemSurface = nullptr;
ISteamUser* g_ISteamUser = nullptr;
IAchievementMgr* g_IAchievementMgr = nullptr;
ISteamUserStats* g_ISteamUserStats = nullptr;
@ -47,6 +45,7 @@ IStudioRender* g_IStudioRender = nullptr;
IVDebugOverlay* g_IVDebugOverlay = nullptr;
IMaterialSystemFixed* g_IMaterialSystem = nullptr;
IVRenderView* g_IVRenderView = nullptr;
IMaterialSystem* g_IMaterialSystemHL = nullptr;
template<typename T>
T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int start) {
@ -69,7 +68,6 @@ T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int st
}
void CreateInterfaces() {
g_ICenterPrint = BruteforceInterface<ICenterPrint>("VCENTERPRINT", sharedobj::client);
g_ICvar = BruteforceInterface<ICvar>("VEngineCvar", sharedobj::vstdlib);
g_IEngine = BruteforceInterface<IVEngineClient013>("VEngineClient", sharedobj::engine);
g_AppID = g_IEngine->GetAppID();
@ -92,19 +90,22 @@ void CreateInterfaces() {
g_IPrediction = BruteforceInterface<IPrediction>("VClientPrediction", sharedobj::client);
g_IGameMovement = BruteforceInterface<IGameMovement>("GameMovement", sharedobj::client);
g_IVRenderView = BruteforceInterface<IVRenderView>("VEngineRenderView", sharedobj::engine);
g_IMaterialSystem = BruteforceInterface<IMaterialSystemFixed>("VMaterialSystem", sharedobj::materialsystem, 81);
g_IMaterialSystem = BruteforceInterface<IMaterialSystemFixed>("VMaterialSystem", sharedobj::materialsystem);
g_IMaterialSystemHL = (IMaterialSystem*)g_IMaterialSystem;
if (TF2) {
// FIXME static offset FIXME FIXME FIXME FIXME IMPORTANT!
g_pScreenSpaceEffects = **(IScreenSpaceEffectManager***)(gSignatures.GetClientSignature("F3 0F 10 83 40 05 00 00 C7 44 24 04 ? ? ? ? 89 34 24 F3 0F 11 44 24 08 E8 ? ? ? ? A1 ? ? ? ? 8B 10 89 04 24 89 74 24 08 C7 44 24 04 ? ? ? ? FF 52 0C A1 ? ? ? ? 8B 10 C7 44 24 04 ? ? ? ? 89 04 24 FF 52 14") + 31);
g_ppScreenSpaceRegistrationHead = *(CScreenSpaceEffectRegistration***)(gSignatures.GetClientSignature("55 89 E5 53 83 EC 14 8B 1D ? ? ? ? 85 DB 74 25 8D B4 26 00 00 00 00 8B 43 04 85 C0 74 10") + 9);
} else if (TF2C) {
logging::Info("FATAL: Signatures not defined for TF2C - Screen Space Effects");
g_pScreenSpaceEffects = nullptr;
g_ppScreenSpaceRegistrationHead = nullptr;
} else if (HL2DM) {
g_pScreenSpaceEffects = **(IScreenSpaceEffectManager***)(gSignatures.GetClientSignature("FF 52 14 E9 E0 FE FF FF 8D 76 00 A1 ? ? ? ? 8B 5D F4 8B 75 F8 8B 7D FC 8B 10 C7 45 0C ? ? ? ? 89 45 08 8B 42 1C 89 EC 5D FF E0") + 12);
g_ppScreenSpaceRegistrationHead = *(CScreenSpaceEffectRegistration***)(gSignatures.GetClientSignature("E8 ? ? ? ? 8B 10 C7 44 24 04 ? ? ? ? 89 04 24 FF 52 28 85 C0 75 4B 8B 35 ? ? ? ? 85 F6 74 31 90 8B 5E 04 85 DB 74 22 8B 03 89 1C 24") + 27);
}
if (TF2) g_IInput = **(reinterpret_cast<IInput***>((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 B4 00 00 00 A1 ? ? ? ? 8B 10")));
else if (TF2C) g_IInput = **(reinterpret_cast<IInput***>((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 A8 00 00 00 A1 ? ? ? ? 8B 10")));
else if (HL2DM) g_IInput = **(reinterpret_cast<IInput***>((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? 8B 10 89 04 24 FF 52 78 A1 ? ? ? ? 8B 10")));
//if (TF2 || HL2DM)
//g_IMatSystemSurface = **reinterpret_cast<IMatSystemSurface***>((uintptr_t)19 + gSignatures.GetClientSignature("FF 92 94 02 00 00 8B 8D C4 FE FF FF 89 85 B0 FE FF FF A1 ? ? ? ? 8B 10 89 4C 24 0C"));
//else if (TF2C)
//g_IMatSystemSurface = **reinterpret_cast<IMatSystemSurface***>((uintptr_t)53 + gSignatures.GetClientSignature("C7 44 24 1C FF 00 00 00 C7 44 24 18 FF 00 00 00 C7 44 24 14 FF 00 00 00 C7 44 24 10 00 00 00 00 89 74 24 08 8B 83 D0 E1 00 00 89 95 A4 FE FF FF 89 44 24 04 A1 ? ? ? ? 89 04 24 FF 91 88 02 00 00 8B 95 A4 FE FF FF A1 ? ? ? ? 29 FA 8B 08 89 54 24 0C"));
g_ISteamUser = g_ISteamClient->GetISteamUser(su, sp, "SteamUser018");
g_IAchievementMgr = g_IEngine->GetAchievementMgr();
g_ISteamUserStats = g_ISteamClient->GetISteamUserStats(su, sp, "STEAMUSERSTATS_INTERFACE_VERSION011");

View File

@ -53,7 +53,6 @@ extern IVEngineClient013* g_IEngine;
extern vgui::ISurface* g_ISurface;
extern vgui::IPanel* g_IPanel;
extern IClientEntityList* g_IEntityList;
extern ICenterPrint* g_ICenterPrint;
extern ICvar* g_ICvar;
extern IGameEventManager2* g_IEventManager2;
extern IBaseClientDLL* g_IBaseClient;
@ -64,13 +63,13 @@ extern CGlobalVarsBase* g_GlobalVars;
extern IPrediction* g_IPrediction;
extern IGameMovement* g_IGameMovement;
extern IInput* g_IInput;
extern IMatSystemSurface* g_IMatSystemSurface;
extern ISteamUser* g_ISteamUser;
extern IAchievementMgr* g_IAchievementMgr;
extern ISteamUserStats* g_ISteamUserStats;
extern IStudioRender* g_IStudioRender;
extern IVDebugOverlay* g_IVDebugOverlay;
extern IMaterialSystemFixed* g_IMaterialSystem;
extern IMaterialSystem* g_IMaterialSystemHL;
extern IVModelRender* g_IVModelRender;
extern IVRenderView* g_IVRenderView;

View File

@ -12,8 +12,7 @@
#include "materialsystem/imaterialsystem.h"
#include "tier1/KeyValues.h"
#include "imaterialsystemfixed.h"
#include "../interfaces.h"
#include "../common.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@ -44,7 +43,12 @@ CMaterialReference::~CMaterialReference()
//-----------------------------------------------------------------------------
void CMaterialReference::Init( char const* pMaterialName, const char *pTextureGroupName, bool bComplain )
{
IMaterial *pMaterial = g_IMaterialSystem->FindMaterial( pMaterialName, pTextureGroupName, bComplain);
IMaterial *pMaterial;
if (TF2) {
pMaterial = g_IMaterialSystem->FindMaterial( pMaterialName, pTextureGroupName, bComplain);
} else {
pMaterial = g_IMaterialSystemHL->FindMaterial( pMaterialName, pTextureGroupName, bComplain);
}
if( IsErrorMaterial( pMaterial ) )
{
if (IsOSX())
@ -61,12 +65,19 @@ void CMaterialReference::Init( const char *pMaterialName, KeyValues *pVMTKeyValu
{
// CreateMaterial has a refcount of 1
Shutdown();
m_pMaterial = g_IMaterialSystem->CreateMaterial( pMaterialName, pVMTKeyValues );
if (TF2)
m_pMaterial = g_IMaterialSystem->CreateMaterial( pMaterialName, pVMTKeyValues );
else
m_pMaterial = g_IMaterialSystemHL->CreateMaterial( pMaterialName, pVMTKeyValues );
}
void CMaterialReference::Init( const char *pMaterialName, const char *pTextureGroupName, KeyValues *pVMTKeyValues )
{
IMaterial *pMaterial = g_IMaterialSystem->FindProceduralMaterial( pMaterialName, pTextureGroupName, pVMTKeyValues );
IMaterial *pMaterial;
if (TF2)
pMaterial = g_IMaterialSystem->FindProceduralMaterial( pMaterialName, pTextureGroupName, pVMTKeyValues );
else
pMaterial = g_IMaterialSystemHL->FindProceduralMaterial( pMaterialName, pTextureGroupName, pVMTKeyValues );
Assert( pMaterial );
Init( pMaterial );
}
@ -150,7 +161,10 @@ CTextureReference::~CTextureReference( )
void CTextureReference::Init( char const* pTextureName, const char *pTextureGroupName, bool bComplain )
{
Shutdown();
m_pTexture = g_IMaterialSystem->FindTexture( pTextureName, pTextureGroupName, bComplain );
if (TF2)
m_pTexture = g_IMaterialSystem->FindTexture( pTextureName, pTextureGroupName, bComplain );
else
m_pTexture = g_IMaterialSystemHL->FindTexture( pTextureName, pTextureGroupName, bComplain );
if ( m_pTexture )
{
m_pTexture->IncrementReferenceCount();
@ -172,8 +186,10 @@ void CTextureReference::InitProceduralTexture( const char *pTextureName, const c
{
Shutdown();
m_pTexture = g_IMaterialSystem->CreateProceduralTexture( pTextureName, pTextureGroupName, w, h, fmt, nFlags );
if (TF2)
m_pTexture = g_IMaterialSystem->CreateProceduralTexture( pTextureName, pTextureGroupName, w, h, fmt, nFlags );
else
m_pTexture = g_IMaterialSystemHL->CreateProceduralTexture( pTextureName, pTextureGroupName, w, h, fmt, nFlags );
// NOTE: The texture reference is already incremented internally above!
/*
if ( m_pTexture )
@ -196,8 +212,12 @@ void CTextureReference::InitRenderTarget( int w, int h, RenderTargetSizeMode_t s
// NOTE: Refcount returned by CreateRenderTargetTexture is 1
//m_pTexture = vfunc<ITexture*(*)(IMaterialSystem*, char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,uint,uint)>(materials, 87, 0)(materials, pStrOptionalName, w, h, sizeMode, fmt,
// depth, textureFlags, renderTargetFlags);
m_pTexture = g_IMaterialSystem->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt,
depth, textureFlags, renderTargetFlags );
if (TF2) {
m_pTexture = g_IMaterialSystem->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt, depth, textureFlags, renderTargetFlags );
} else {
m_pTexture = g_IMaterialSystemHL->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt, depth, textureFlags, renderTargetFlags );
}
Assert( m_pTexture );
}

View File

@ -571,5 +571,4 @@ public:
virtual ITexture* CreateNamedTextureFromBitsEx( const char* pName, const char *pTextureGroupName, int w, int h, int mips, ImageFormat fmt, int srcBufferSize, byte* srcBits, int nFlags ) = 0;
};
#endif // IMATERIALSYSTEMFIXED_H