mirror of
https://github.com/aap/librw.git
synced 2025-12-20 09:29:49 +00:00
implemented dear imgui for librw
This commit is contained in:
@@ -28,8 +28,8 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
int lighting = !!(geo->flags & rw::Geometry::LIGHT);
|
||||
if(lighting)
|
||||
d3d::lightingCB();
|
||||
else
|
||||
return;
|
||||
// else
|
||||
// return;
|
||||
|
||||
d3d::setRenderState(D3DRS_LIGHTING, lighting);
|
||||
|
||||
@@ -45,6 +45,13 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
InstanceData *inst = header->inst;
|
||||
for(uint32 i = 0; i < header->numMeshes; i++){
|
||||
d3d::setTexture(0, inst->material->texture);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
|
||||
d3d::setMaterial(inst->material);
|
||||
|
||||
d3d::setRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
|
||||
@@ -84,6 +84,12 @@ setRenderState(uint32 state, uint32 value)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
getRenderState(uint32 state, uint32 *value)
|
||||
{
|
||||
*value = stateCache[state].value;
|
||||
}
|
||||
|
||||
void
|
||||
setTextureStageState(uint32 stage, uint32 type, uint32 value)
|
||||
{
|
||||
@@ -98,6 +104,12 @@ setTextureStageState(uint32 stage, uint32 type, uint32 value)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
getTextureStageState(uint32 stage, uint32 type, uint32 *value)
|
||||
{
|
||||
*value = textureStageStateCache[type][stage].value;
|
||||
}
|
||||
|
||||
void
|
||||
flushCache(void)
|
||||
{
|
||||
@@ -135,6 +147,12 @@ setSamplerState(uint32 stage, uint32 type, uint32 value)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
getSamplerState(uint32 stage, uint32 type, uint32 *value)
|
||||
{
|
||||
*value = d3dSamplerStates[type][stage];
|
||||
}
|
||||
|
||||
// Bring D3D device in accordance with saved render states (after a reset)
|
||||
static void
|
||||
resetD3d9Device(void)
|
||||
@@ -480,7 +498,8 @@ clearCamera(Camera *cam, RGBA *col, uint32 mode)
|
||||
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
|
||||
d3dpp.Flags = 0;
|
||||
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
// d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
// TODO: check result
|
||||
d3d::d3ddevice->Reset(&d3dpp);
|
||||
d3d9Globals.presentWidth = r.right;
|
||||
@@ -548,7 +567,8 @@ openD3D(EngineStartParams *params)
|
||||
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
|
||||
d3dpp.Flags = 0;
|
||||
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
// d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
IDirect3DDevice9 *dev;
|
||||
hr = d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, win,
|
||||
|
||||
@@ -77,6 +77,13 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
|
||||
d3ddevice->SetIndices(im2dindbuf);
|
||||
d3ddevice->SetVertexDeclaration(im2ddecl);
|
||||
d3d::setTexture(0, engine->imtexture);
|
||||
setTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
setTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
setTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
||||
setTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
setTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
setTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
|
||||
|
||||
d3d::flushCache();
|
||||
|
||||
uint32 primCount = 0;
|
||||
|
||||
@@ -143,8 +143,11 @@ void registerNativeRaster(void);
|
||||
// Rendering
|
||||
|
||||
void setRenderState(uint32 state, uint32 value);
|
||||
void getRenderState(uint32 state, uint32 *value);
|
||||
void setTextureStageState(uint32 stage, uint32 type, uint32 value);
|
||||
void getTextureStageState(uint32 stage, uint32 type, uint32 *value);
|
||||
void setSamplerState(uint32 stage, uint32 type, uint32 value);
|
||||
void getSamplerState(uint32 stage, uint32 type, uint32 *value);
|
||||
void flushCache(void);
|
||||
|
||||
void setTexture(uint32 stage, Texture *tex);
|
||||
|
||||
Reference in New Issue
Block a user