implemented vsynch for d3d9 and glfw
This commit is contained in:
parent
3704fe8a9f
commit
b3ad490d1b
@ -356,9 +356,9 @@ Camera::clear(RGBA *col, uint32 mode)
|
||||
}
|
||||
|
||||
void
|
||||
Camera::showRaster(void)
|
||||
Camera::showRaster(uint32 flags)
|
||||
{
|
||||
engine->device.showRaster(this->frameBuffer);
|
||||
this->frameBuffer->show(flags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1034,9 +1034,15 @@ clearCamera(Camera *cam, RGBA *col, uint32 mode)
|
||||
}
|
||||
|
||||
static void
|
||||
showRaster(Raster *raster)
|
||||
showRaster(Raster *raster, uint32 flag)
|
||||
{
|
||||
// TODO: do this properly!
|
||||
UINT interval = flag & Raster::FLIPWAITVSYNCH ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
if(d3d9Globals.present.PresentationInterval != interval){
|
||||
d3d9Globals.present.PresentationInterval = interval;
|
||||
releaseVideoMemory();
|
||||
d3d::d3ddevice->Reset(&d3d9Globals.present);
|
||||
restoreVideoMemory();
|
||||
}
|
||||
|
||||
// not used but we want cameras to have rasters
|
||||
assert(raster);
|
||||
@ -1294,8 +1300,8 @@ startD3D(void)
|
||||
d3d9Globals.present.AutoDepthStencilFormat = zformat;
|
||||
d3d9Globals.present.Flags = 0;
|
||||
d3d9Globals.present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||
d3d9Globals.present.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
// d3d9Globals.present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
// d3d9Globals.present.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
d3d9Globals.present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
assert(d3d::d3ddevice == nil);
|
||||
|
||||
|
@ -405,7 +405,7 @@ namespace null {
|
||||
void beginUpdate(Camera*) { }
|
||||
void endUpdate(Camera*) { }
|
||||
void clearCamera(Camera*,RGBA*,uint32) { }
|
||||
void showRaster(Raster*) { }
|
||||
void showRaster(Raster*,uint32) { }
|
||||
|
||||
void setRenderState(int32, void*) { }
|
||||
void *getRenderState(int32) { return 0; }
|
||||
|
@ -761,12 +761,16 @@ clearCamera(Camera *cam, RGBA *col, uint32 mode)
|
||||
}
|
||||
|
||||
static void
|
||||
showRaster(Raster *raster)
|
||||
showRaster(Raster *raster, uint32 flags)
|
||||
{
|
||||
// TODO: do this properly!
|
||||
#ifdef LIBRW_SDL2
|
||||
SDL_GL_SwapWindow(glGlobals.window);
|
||||
#else
|
||||
if(flags & Raster::FLIPWAITVSYNCH)
|
||||
glfwSwapInterval(1);
|
||||
else
|
||||
glfwSwapInterval(0);
|
||||
glfwSwapBuffers(glGlobals.window);
|
||||
#endif
|
||||
}
|
||||
|
@ -182,6 +182,12 @@ Raster::toImage(void)
|
||||
return engine->driver[this->platform]->rasterToImage(this);
|
||||
}
|
||||
|
||||
void
|
||||
Raster::show(uint32 flags)
|
||||
{
|
||||
engine->device.showRaster(this, flags);
|
||||
}
|
||||
|
||||
Raster*
|
||||
Raster::pushContext(Raster *raster)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ struct Device
|
||||
void (*beginUpdate)(Camera*);
|
||||
void (*endUpdate)(Camera*);
|
||||
void (*clearCamera)(Camera*, RGBA *col, uint32 mode);
|
||||
void (*showRaster)(Raster *raster);
|
||||
void (*showRaster)(Raster *raster, uint32 flags);
|
||||
bool32 (*rasterRenderFast)(Raster *raster, int32 x, int32 y);
|
||||
void (*setRenderState)(int32 state, void *value);
|
||||
void *(*getRenderState)(int32 state);
|
||||
|
@ -179,6 +179,8 @@ struct RasterLevels
|
||||
|
||||
struct Raster
|
||||
{
|
||||
enum { FLIPWAITVSYNCH = 1 };
|
||||
|
||||
PLUGINBASE
|
||||
int32 platform;
|
||||
|
||||
@ -219,6 +221,8 @@ struct Raster
|
||||
static int32 calculateNumLevels(int32 width, int32 height);
|
||||
static bool formatHasAlpha(int32 format);
|
||||
|
||||
void show(uint32 flags);
|
||||
|
||||
static Raster *pushContext(Raster *raster);
|
||||
static Raster *popContext(void);
|
||||
static Raster *getCurrentContext(void);
|
||||
@ -698,7 +702,7 @@ struct Camera
|
||||
void beginUpdate(void) { this->beginUpdateCB(this); }
|
||||
void endUpdate(void) { this->endUpdateCB(this); }
|
||||
void clear(RGBA *col, uint32 mode);
|
||||
void showRaster(void);
|
||||
void showRaster(uint32 flags);
|
||||
void setNearPlane(float32);
|
||||
void setFarPlane(float32);
|
||||
void setViewWindow(const V2d *window);
|
||||
|
@ -112,7 +112,7 @@ Draw(float timeDelta)
|
||||
ImGui::Render();
|
||||
|
||||
Scene.camera->endUpdate();
|
||||
Scene.camera->showRaster();
|
||||
Scene.camera->showRaster(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,7 +303,7 @@ Draw(float timeDelta)
|
||||
ImGui::Render();
|
||||
|
||||
Scene.camera->endUpdate();
|
||||
Scene.camera->showRaster();
|
||||
Scene.camera->showRaster(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -338,8 +338,8 @@ im3dtest(void)
|
||||
verts[i].setV(vs[i].v);
|
||||
}
|
||||
|
||||
// rw::SetRenderStatePtr(rw::TEXTURERASTER, tex->raster);
|
||||
rw::SetRenderStatePtr(rw::TEXTURERASTER, testfont->raster);
|
||||
rw::SetRenderStatePtr(rw::TEXTURERASTER, tex->raster);
|
||||
// rw::SetRenderStatePtr(rw::TEXTURERASTER, testfont->raster);
|
||||
// rw::SetRenderStatePtr(rw::TEXTURERASTER, frontbuffer->raster);
|
||||
rw::SetRenderState(rw::TEXTUREADDRESS, rw::Texture::WRAP);
|
||||
rw::SetRenderState(rw::TEXTUREFILTER, rw::Texture::NEAREST);
|
||||
@ -408,7 +408,7 @@ extern void endSoftras(void);
|
||||
|
||||
camera->m_rwcam->endUpdate();
|
||||
|
||||
camera->m_rwcam->showRaster();
|
||||
camera->m_rwcam->showRaster(0);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user