mirror of
https://github.com/aap/librw.git
synced 2025-12-18 16:39:51 +00:00
implemented dear imgui for librw
This commit is contained in:
@@ -479,11 +479,27 @@ Camera::streamGetSize(void)
|
||||
s_plglist.streamGetSize(this);
|
||||
}
|
||||
|
||||
// Assumes horizontal FOV for 4:3, but we convert to vertical FOV
|
||||
void
|
||||
Camera::setFOV(float32 fov, float32 ratio)
|
||||
Camera::setFOV(float32 hfov, float32 ratio)
|
||||
{
|
||||
V2d v;
|
||||
float32 a = tan(fov*3.14159f/360.0f);
|
||||
float w, h;
|
||||
|
||||
w = this->frameBuffer->width;
|
||||
h = this->frameBuffer->height;
|
||||
if(w < 1 || h < 1){
|
||||
w = 1;
|
||||
h = 1;
|
||||
}
|
||||
hfov = hfov*3.14159f/360.0f; // deg to rad
|
||||
|
||||
float ar1 = 4.0/3.0;
|
||||
float ar2 = w/h;
|
||||
float vfov = atan(tan(hfov/2) / ar1) *2;
|
||||
hfov = atan(tan(vfov/2) * ar2) *2;
|
||||
|
||||
float32 a = tan(hfov);
|
||||
v.set(a, a/ratio);
|
||||
this->setViewWindow(&v);
|
||||
v.set(0.0f, 0.0f);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1595,6 +1595,7 @@ readNativeTexture(Stream *stream)
|
||||
goto fail;
|
||||
}
|
||||
stream->read(&streamExt, 0x40);
|
||||
/*
|
||||
printf("%X %X %X %X %X %016llX %X %X %016llX %016llX %X %X %X %X\n",
|
||||
streamExt.width,
|
||||
streamExt.height,
|
||||
@@ -1610,7 +1611,7 @@ streamExt.pixelSize,
|
||||
streamExt.paletteSize,
|
||||
streamExt.totalSize,
|
||||
streamExt.mipmapVal);
|
||||
|
||||
*/
|
||||
noNewStyleRasters = streamExt.type < 2;
|
||||
rw::version = version;
|
||||
raster = Raster::create(streamExt.width, streamExt.height,
|
||||
|
||||
@@ -683,6 +683,7 @@ struct TexDictionary
|
||||
void destroy(void);
|
||||
int32 count(void) { return this->textures.count(); }
|
||||
void add(Texture *t);
|
||||
void addFront(Texture *t);
|
||||
Texture *find(const char *name);
|
||||
static TexDictionary *streamRead(Stream *stream);
|
||||
void streamWrite(Stream *stream);
|
||||
|
||||
@@ -113,6 +113,15 @@ TexDictionary::add(Texture *t)
|
||||
this->textures.append(&t->inDict);
|
||||
}
|
||||
|
||||
void
|
||||
TexDictionary::addFront(Texture *t)
|
||||
{
|
||||
if(t->dict)
|
||||
t->inDict.remove();
|
||||
t->dict = this;
|
||||
this->textures.add(&t->inDict);
|
||||
}
|
||||
|
||||
Texture*
|
||||
TexDictionary::find(const char *name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user