Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -----------------------------------------
- * Game hacking QTS ( Quickie Tip Series )
- * no. 14 - Create texture from resource
- -----------------------------------------
- * Author: SEGnosis - GHAnon.net
- * Thanks to:
- * bitterbanana - No known site
- * Drunken Cheetah - No known site
- * fatboy88 - No known site
- * Geek4Ever - No known site
- * learn_more - www.uc-forum.com
- * Novocaine - http://ilsken.net/blog/?page_id=64
- * Philly0494 - No known site
- * Roverturbo - www.uc-forum.com
- * SilentKarma - www.halocoders.com - offline
- * Strife - www.uc-forum.com
- * Wieter20 - No known site
- */
- //----------------------------------//
- // resource.h
- #ifndef IDC_STATIC
- #define IDC_STATIC (-1)
- #endif
- #define ID_PNG_BASE 107 // ID for png custom resource
- // Res.rc
- #include <windows.h>
- #include <commctrl.h>
- #include <richedit.h>
- #include "resource.h"
- ID_PNG_BASE ID_PNG ".\\MyTexture.png" // reletive
- // dll main
- HMODULE g_hModule;
- BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved )
- {
- switch( dwReason )
- {
- case DLL_THREAD_ATTACH:
- break;
- case DLL_PROCESS_ATTACH:
- g_hModule = hModule;
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
- // function
- void LoadCustomTextureFromResource( LPDIRECT3DTEXTURE9& m_Texture, char* szType, LPSTR szResource )
- {
- HRSRC hRes = FindResource( g_hModule, szResource, szType );
- HGLOBAL hResource = LoadResource( g_hModule, hRes );
- DWORD iResSize = SizeofResource( g_hModule, hRes );
- BYTE* pData = ( BYTE* )LockResource( hResource );
- D3DXCreateTextureFromFileInMemory( m_pDevice, pData, iResSize, &m_Texture );
- FreeResource( hResource );
- }
- // How to use
- LPDIRECT3DTEXTURE9 g_TexBackground;
- LoadCustomTextureFromResource( g_TexBackground, "ID_PNG", MAKEINTRESOURCE( ID_PNG_BASE ) );
- //----------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement