Add enable/disable dithering. Respect chosen framebuffer color depth.

This commit is contained in:
Henrik Rydgard 2013-01-23 23:02:49 +01:00
parent cb7f803866
commit b1bbbc44fc
4 changed files with 21 additions and 3 deletions

View file

@ -376,7 +376,7 @@ void GLES_GPU::SetRenderFrameBuffer() {
VirtualFramebuffer *vfb = 0;
for (auto iter = vfbs_.begin(); iter != vfbs_.end(); ++iter) {
VirtualFramebuffer *v = *iter;
if (v->fb_address == fb_address && v->width == drawing_width && v->height == drawing_height) {
if (v->fb_address == fb_address && v->width == drawing_width && v->height == drawing_height && v->format == fmt) {
// Let's not be so picky for now. Let's say this is the one.
vfb = v;
// Update fb stride in case it changed
@ -397,10 +397,24 @@ void GLES_GPU::SetRenderFrameBuffer() {
vfb->width = drawing_width;
vfb->height = drawing_height;
vfb->format = fmt;
vfb->fbo = fbo_create(vfb->width * renderWidthFactor_, vfb->height * renderHeightFactor_, 1, true);
//vfb->colorDepth = FBO_8888;
switch (gstate.framebufpixformat & 0x3) {
case GE_FORMAT_4444: vfb->colorDepth = FBO_4444;
case GE_FORMAT_5551: vfb->colorDepth = FBO_5551;
case GE_FORMAT_565: vfb->colorDepth = FBO_565;
case GE_FORMAT_8888: vfb->colorDepth = FBO_8888;
}
//#ifdef ANDROID
// vfb->colorDepth = FBO_5551;
//#endif
vfb->fbo = fbo_create(vfb->width * renderWidthFactor_, vfb->height * renderHeightFactor_, 1, true, vfb->colorDepth);
vfb->last_frame_used = gpuStats.numFrames;
vfbs_.push_back(vfb);
fbo_bind_as_render_target(vfb->fbo);
glEnable(GL_DITHER);
glstate.viewport.set(0, 0, renderWidth_, renderHeight_);
currentRenderVfb_ = vfb;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

View file

@ -103,6 +103,7 @@ private:
int height;
int format; // virtual, right now they are all RGBA8888
FBOColorDepth colorDepth;
FBO *fbo;
};

View file

@ -202,6 +202,9 @@ void ApplyDrawState(int prim) {
glstate.stencilTest.disable();
}
// Dither
glstate.dither.set(gstate.ditherEnable & 1);
bool wantDepthWrite = gstate.isModeClear() || gstate.isDepthWriteEnabled();
glstate.depthWrite.set(wantDepthWrite ? GL_TRUE : GL_FALSE);

2
native

@ -1 +1 @@
Subproject commit 464240f7034b8defe5a60513c1e88bf6dc1c94c2
Subproject commit f315424c42b1fa5a8d08a702b435c0c7deb5dd00