WIPE!
This commit is contained in:
parent
05fe5270cd
commit
7413a15369
14
extern/imgui_patched/backends/imgui_impl_dx9.cpp
vendored
14
extern/imgui_patched/backends/imgui_impl_dx9.cpp
vendored
|
@ -175,6 +175,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup the DX9 state
|
// Backup the DX9 state
|
||||||
|
/*
|
||||||
IDirect3DStateBlock9* d3d9_state_block = nullptr;
|
IDirect3DStateBlock9* d3d9_state_block = nullptr;
|
||||||
if (bd->pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
|
if (bd->pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -182,26 +183,28 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
d3d9_state_block->Release();
|
d3d9_state_block->Release();
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to)
|
// Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to)
|
||||||
|
/*
|
||||||
D3DMATRIX last_world, last_view, last_projection;
|
D3DMATRIX last_world, last_view, last_projection;
|
||||||
bd->pd3dDevice->GetTransform(D3DTS_WORLD, &last_world);
|
bd->pd3dDevice->GetTransform(D3DTS_WORLD, &last_world);
|
||||||
bd->pd3dDevice->GetTransform(D3DTS_VIEW, &last_view);
|
bd->pd3dDevice->GetTransform(D3DTS_VIEW, &last_view);
|
||||||
bd->pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);
|
bd->pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);
|
||||||
|
*/
|
||||||
|
|
||||||
// Allocate buffers
|
// Allocate buffers
|
||||||
CUSTOMVERTEX* vtx_dst;
|
CUSTOMVERTEX* vtx_dst;
|
||||||
ImDrawIdx* idx_dst;
|
ImDrawIdx* idx_dst;
|
||||||
if (bd->pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
|
if (bd->pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
|
||||||
{
|
{
|
||||||
d3d9_state_block->Release();
|
//d3d9_state_block->Release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (bd->pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
|
if (bd->pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
|
||||||
{
|
{
|
||||||
bd->pVB->Unlock();
|
bd->pVB->Unlock();
|
||||||
d3d9_state_block->Release();
|
//d3d9_state_block->Release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,13 +285,18 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||||
bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, 0);
|
bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
// Restore the DX9 transform
|
// Restore the DX9 transform
|
||||||
|
// don't. I like this transform.
|
||||||
|
/*
|
||||||
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
||||||
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
||||||
bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection);
|
bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection);
|
||||||
|
*/
|
||||||
|
|
||||||
// Restore the DX9 state
|
// Restore the DX9 state
|
||||||
|
/*
|
||||||
d3d9_state_block->Apply();
|
d3d9_state_block->Apply();
|
||||||
d3d9_state_block->Release();
|
d3d9_state_block->Release();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
||||||
|
|
|
@ -271,10 +271,15 @@ void FurnaceGUIRenderDX9::clear(ImVec4 color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUIRenderDX9::present() {
|
void FurnaceGUIRenderDX9::present() {
|
||||||
|
if (inScene) {
|
||||||
|
device->EndScene();
|
||||||
|
inScene=false;
|
||||||
|
}
|
||||||
|
|
||||||
if (device->Present(NULL,NULL,NULL,NULL)==D3DERR_DEVICEREMOVED) {
|
if (device->Present(NULL,NULL,NULL,NULL)==D3DERR_DEVICEREMOVED) {
|
||||||
logI("device is gone");
|
logI("device is gone");
|
||||||
dead=true;
|
dead=true;
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mustResize) {
|
if (mustResize) {
|
||||||
|
@ -340,22 +345,32 @@ void FurnaceGUIRenderDX9::destroyFontsTexture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUIRenderDX9::renderGUI() {
|
void FurnaceGUIRenderDX9::renderGUI() {
|
||||||
|
if (!inScene) {
|
||||||
HRESULT result=device->BeginScene();
|
HRESULT result=device->BeginScene();
|
||||||
if (result==D3D_OK) {
|
if (result!=D3D_OK) {
|
||||||
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
|
||||||
device->EndScene();
|
|
||||||
} else {
|
|
||||||
logW("couldn't render GUI! %.8x",result);
|
logW("couldn't render GUI! %.8x",result);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
inScene=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUIRenderDX9::wipe(float alpha) {
|
void FurnaceGUIRenderDX9::wipe(float alpha) {
|
||||||
if (wipeBuf==NULL) return;
|
if (wipeBuf==NULL) return;
|
||||||
|
|
||||||
/*
|
logV("WIPE...");
|
||||||
|
|
||||||
|
if (!inScene) {
|
||||||
HRESULT result=device->BeginScene();
|
HRESULT result=device->BeginScene();
|
||||||
if (result==D3D_OK) {
|
if (result!=D3D_OK) {
|
||||||
|
logW("couldn't render GUI! %.8x",result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inScene=true;
|
||||||
|
}
|
||||||
|
|
||||||
D3DVIEWPORT9 view;
|
D3DVIEWPORT9 view;
|
||||||
view.X=0;
|
view.X=0;
|
||||||
view.Y=0;
|
view.Y=0;
|
||||||
|
@ -363,12 +378,13 @@ void FurnaceGUIRenderDX9::wipe(float alpha) {
|
||||||
view.Height=outH;
|
view.Height=outH;
|
||||||
view.MinZ=0.0f;
|
view.MinZ=0.0f;
|
||||||
view.MaxZ=1.0f;
|
view.MaxZ=1.0f;
|
||||||
result=device->SetViewport(&view);
|
HRESULT result=device->SetViewport(&view);
|
||||||
if (result!=D3D_OK) {
|
if (result!=D3D_OK) {
|
||||||
logW("could not set viewport! %.8x",result);
|
logW("could not set viewport! %.8x",result);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int color=alpha*255;
|
unsigned char alphaU=alpha*255.0f;
|
||||||
|
unsigned int color=alphaU<<24;
|
||||||
|
|
||||||
void* lockedData;
|
void* lockedData;
|
||||||
WipeVertex vertex[4];
|
WipeVertex vertex[4];
|
||||||
|
@ -382,14 +398,33 @@ void FurnaceGUIRenderDX9::wipe(float alpha) {
|
||||||
memcpy(lockedData,vertex,sizeof(WipeVertex)*4);
|
memcpy(lockedData,vertex,sizeof(WipeVertex)*4);
|
||||||
wipeBuf->Unlock();
|
wipeBuf->Unlock();
|
||||||
|
|
||||||
device->SetStreamSource(0,wipeBuf,0,sizeof(WipeVertex));
|
result=device->SetRenderState(D3DRS_SCISSORTESTENABLE,FALSE);
|
||||||
device->SetFVF(D3DFVF_XYZ|D3DFVF_DIFFUSE);
|
if (result!=D3D_OK) {
|
||||||
device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,1);
|
logE("SHIT! scissor, %.8x",result);
|
||||||
}
|
}
|
||||||
|
result=device->SetTexture(0,NULL);
|
||||||
device->EndScene();
|
if (result!=D3D_OK) {
|
||||||
|
logE("SHIT! set texture, %.8x",result);
|
||||||
|
}
|
||||||
|
result=device->SetStreamSource(0,wipeBuf,0,sizeof(WipeVertex));
|
||||||
|
if (result!=D3D_OK) {
|
||||||
|
logE("SHIT! set stream source, %.8x",result);
|
||||||
|
}
|
||||||
|
result=device->SetTexture(0,NULL);
|
||||||
|
if (result!=D3D_OK) {
|
||||||
|
logE("SHIT! set texture, %.8x",result);
|
||||||
|
}
|
||||||
|
result=device->SetFVF(D3DFVF_XYZ|D3DFVF_DIFFUSE);
|
||||||
|
if (result!=D3D_OK) {
|
||||||
|
logE("SHIT! set FVF, %.8x",result);
|
||||||
|
}
|
||||||
|
result=device->DrawPrimitive(D3DPT_TRIANGLEFAN,0,2);
|
||||||
|
if (result!=D3D_OK) {
|
||||||
|
logE("SHIT! draw primitive, %.8x",result);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logE("SHIT! lock, %.8x",result);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FurnaceGUIRenderDX9::getOutputSize(int& w, int& h) {
|
bool FurnaceGUIRenderDX9::getOutputSize(int& w, int& h) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ class FurnaceGUIRenderDX9: public FurnaceGUIRender {
|
||||||
|
|
||||||
int outW, outH, swapInterval;
|
int outW, outH, swapInterval;
|
||||||
|
|
||||||
bool dead, haveScene, supportsDynamicTex, supportsVSync, mustResize, squareTex;
|
bool dead, haveScene, supportsDynamicTex, supportsVSync, mustResize, squareTex, inScene;
|
||||||
|
|
||||||
// SHADERS //
|
// SHADERS //
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ class FurnaceGUIRenderDX9: public FurnaceGUIRender {
|
||||||
supportsVSync(false),
|
supportsVSync(false),
|
||||||
mustResize(false),
|
mustResize(false),
|
||||||
squareTex(false),
|
squareTex(false),
|
||||||
|
inScene(false),
|
||||||
maxWidth(8192),
|
maxWidth(8192),
|
||||||
maxHeight(8192) {
|
maxHeight(8192) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue