This is fantastic, there's a lot of stuff in there I had no idea was even possible. Just one question, are the DirectX runtime fuinctions (D3DDeviceLost, etc) supposed to work with the DBP command "Set Display Mode"?
I have a plugin to put 1000 images on screen per call, but after a call to "Set Display Mode" my custom sprites disappear:
Sync On
Sync Rate 0
// Uncomment and the DG Sprite command fails
//Set Display Mode 1024, 768, 32
//Sync
CLS RGB(128,128,128)
Get Image 1, 0, 0, 50, 50
Backdrop On
Do
DG Sprite Draw 1, 0, 0
Text 50, 50, Str$(Screen FPS())
Sync
Loop
I've modified my plugin code to produce error messages but these are never seen (except, as you say, when fullscreen is Alt-Tabbed out)
// DarkGUI.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "globstruct.h"
#include "DBProFunc.h"
#define EXPORT __declspec(dllexport)
// Initialise Startup Global
GlobStruct* g_pGlob = 0;
LPDIRECT3DDEVICE9 g_pD3D = NULL;
LPD3DXSPRITE g_pSprite = NULL;
LPDIRECT3DTEXTURE9 Texture;
LPDIRECT3DSURFACE9 Surface;
D3DSURFACE_DESC SurfaceDesc;
HMODULE m_DBP_Core = 0;
HMODULE m_DBP_Image = 0;
HMODULE m_DBP_Setup = 0;
const char* Dependencies[] =
{
"DBProSetupDebug.dll",
"DBProImageDebug.dll",
};
EXPORT int GetNumDependencies( void )
{ return sizeof(Dependencies) / sizeof(const char*); }
EXPORT char const* GetDependencyID(int ID)
{ return Dependencies[ID]; }
EXPORT void ReceiveCoreDataPtr(LPVOID CorePtr)
{
// Grab the core data pointer
g_pGlob = (GlobStruct*)CorePtr;
// Load Libraries
m_DBP_Setup = LoadLibrary("DBProSetupDebug.dll");
m_DBP_Image = LoadLibrary("DBProImageDebug.dll");
DBPro::Setup::GetD3DDevice = (rD3DDevpV_t) GetProcAddress(m_DBP_Setup, "?GetDirect3DDevice@@YAPAUIDirect3DDevice9@@XZ");
DBPro::Image::GetImagePointer = (rD3DTEXpL_t) GetProcAddress(m_DBP_Image, "?GetPointer@@YAPAUIDirect3DTexture9@@H@Z");
// Create the DX9 Sprrite Object
g_pD3D = DBPro::Setup::GetD3DDevice();
D3DXCreateSprite(g_pD3D, &g_pSprite);
}
EXPORT void Destructor()
{
FreeLibrary(m_DBP_Setup);
FreeLibrary(m_DBP_Image);
}
// DBPro Device Reset
EXPORT void D3DDeviceLost(void)
{
MessageBox(NULL, "DeviceLost", "DarkGUI Error!", MB_OK);
}
EXPORT void D3DDeviceNotReset(void)
{
MessageBox(NULL, "DeviceNotReset", "DarkGUI Error!", MB_OK);
}
EXPORT void D3DDeviceReset(void)
{
MessageBox(NULL, "DeviceReset", "DarkGUI Error!", MB_OK);
}
EXPORT void DGSpriteDraw(int ImgID, int X, int Y)
{
// Set Render States (removed loads of these for clarity)
g_pD3D->SetRenderTarget(0, g_pGlob->pCurrentBitmapSurface);
D3DXVECTOR3 pos; pos.x = 0.0; pos.y = 0.0; pos.z = 0.0;
g_pSprite->Begin(0);
for (int t = 0; t < 1000; t++)
{
Texture = DBPro::Image::GetImagePointer(ImgID);
g_pD3D->SetRenderState ( D3DRS_ALPHABLENDENABLE, TRUE );
g_pSprite->Draw(Texture, NULL, NULL, &pos, 0xFFFFFFFF);
pos.x = rand()%1024;
pos.y = rand()%768;
}
g_pSprite->End();
}
Is there a reason for this? I know I could just create a D3D sprite object at the start of DGSpriteDraw and release at the end, but that seems a waste of time to me. Any ideas how I could get this working?
We spend our lives chasing dreams. Dark Basic lets us catch some of them.