diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index a911ab4af..b472e4c1d 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -816,9 +816,9 @@ void OpenGLRenderer::ConvertFramebuffer(const u32 *__restrict srcBuffer, u32 *ds // to the DS Y-coordinate. for(int i = 0, y = 191; y >= 0; y--) { - u32 *__restrict dst = dstBuffer + (y << 8); // Same as dstBuffer + (y * 256) + u32 *__restrict dst = dstBuffer + (y * GFX3D_FRAMEBUFFER_WIDTH); - for(unsigned int x = 0; x < 256; x++, i++) + for(unsigned int x = 0; x < GFX3D_FRAMEBUFFER_WIDTH; x++, i++) { // Use the correct endian format since OpenGL uses the native endian of // the architecture it is running on. @@ -1067,7 +1067,7 @@ Render3DError OpenGLRenderer_1_2::CreatePBOs() for (unsigned int i = 0; i < 2; i++) { glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, this->ref->pboRenderDataID[i]); - glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, 256 * 192 * sizeof(u32), NULL, GL_STREAM_READ_ARB); + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, GFX3D_FRAMEBUFFER_WIDTH * GFX3D_FRAMEBUFFER_HEIGHT * sizeof(u32), NULL, GL_STREAM_READ_ARB); } glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); @@ -1336,9 +1336,9 @@ Render3DError OpenGLRenderer_1_2::CreateMultisampledFBO() glGenRenderbuffersEXT(1, &OGLRef.rboMultisampleDepthStencilID); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMultisampleColorID); - glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, maxSamples, GL_RGBA, 256, 192); + glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, maxSamples, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, OGLRef.rboMultisampleDepthStencilID); - glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, maxSamples, GL_DEPTH24_STENCIL8_EXT, 256, 192); + glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, maxSamples, GL_DEPTH24_STENCIL8_EXT, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT); // Set up multisampled rendering FBO glGenFramebuffersEXT(1, &OGLRef.fboMultisampleRenderID); @@ -1505,7 +1505,7 @@ Render3DError OpenGLRenderer_1_2::CreateClearImage() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 192, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); glBindTexture(GL_TEXTURE_2D, OGLRef.texClearImageDepthStencilID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -1513,7 +1513,7 @@ Render3DError OpenGLRenderer_1_2::CreateClearImage() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, 256, 192, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); glActiveTextureARB(GL_TEXTURE0_ARB); @@ -1540,9 +1540,9 @@ Render3DError OpenGLRenderer_1_2::UploadClearImage(const GLushort *clearImageCol glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_ClearImage); glBindTexture(GL_TEXTURE_2D, OGLRef.texClearImageColorID); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, clearImageColorBuffer); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, clearImageColorBuffer); glBindTexture(GL_TEXTURE_2D, OGLRef.texClearImageDepthStencilID); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, clearImageDepthBuffer); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, clearImageDepthBuffer); glBindTexture(GL_TEXTURE_2D, 0); glActiveTextureARB(GL_TEXTURE0_ARB); @@ -1785,7 +1785,7 @@ Render3DError OpenGLRenderer_1_2::DownsampleFBO() glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, OGLRef.selectedRenderingFBO); glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, OGLRef.fboFinalOutputID); - glBlitFramebufferEXT(0, 0, 256, 192, 0, 0, 256, 192, GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBlitFramebufferEXT(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboFinalOutputID); return OGLERROR_NOERR; @@ -1800,7 +1800,7 @@ Render3DError OpenGLRenderer_1_2::ReadBackPixels() this->DownsampleFBO(); glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, this->ref->pboRenderDataID[i]); - glReadPixels(0, 0, 256, 192, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glReadPixels(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, 0); glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); } @@ -1959,8 +1959,8 @@ Render3DError OpenGLRenderer_1_2::EndRender(const u64 frameCount) Render3DError OpenGLRenderer_1_2::UpdateClearImage(const u16 *__restrict colorBuffer, const u16 *__restrict depthBuffer, const u8 clearStencil, const u8 xScroll, const u8 yScroll) { - static const size_t pixelsPerLine = 256; - static const size_t lineCount = 192; + static const size_t pixelsPerLine = GFX3D_FRAMEBUFFER_WIDTH; + static const size_t lineCount = GFX3D_FRAMEBUFFER_HEIGHT; static const size_t totalPixelCount = pixelsPerLine * lineCount; static const size_t bufferSize = totalPixelCount * sizeof(u16); @@ -2039,7 +2039,7 @@ Render3DError OpenGLRenderer_1_2::ClearUsingImage() const glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, OGLRef.fboClearImageID); glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, OGLRef.selectedRenderingFBO); - glBlitFramebufferEXT(0, 0, 256, 192, 0, 0, 256, 192, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); + glBlitFramebufferEXT(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.selectedRenderingFBO); // It might seem wasteful to be doing a separate glClear(GL_STENCIL_BUFFER_BIT) instead @@ -2388,7 +2388,7 @@ Render3DError OpenGLRenderer_1_2::RenderFinish() this->DownsampleFBO(); u32 *__restrict workingBuffer = this->GPU_screen3D[i]; - glReadPixels(0, 0, 256, 192, GL_BGRA, GL_UNSIGNED_BYTE, workingBuffer); + glReadPixels(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, workingBuffer); this->ConvertFramebuffer(workingBuffer, (u32 *)gfx3d_convertedScreen); } @@ -2451,7 +2451,7 @@ Render3DError OpenGLRenderer_1_3::CreateClearImage() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 192, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); glBindTexture(GL_TEXTURE_2D, OGLRef.texClearImageDepthStencilID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -2459,7 +2459,7 @@ Render3DError OpenGLRenderer_1_3::CreateClearImage() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, 256, 192, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); glActiveTexture(GL_TEXTURE0); @@ -2486,9 +2486,9 @@ Render3DError OpenGLRenderer_1_3::UploadClearImage(const GLushort *clearImageCol glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_ClearImage); glBindTexture(GL_TEXTURE_2D, OGLRef.texClearImageColorID); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, clearImageColorBuffer); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, clearImageColorBuffer); glBindTexture(GL_TEXTURE_2D, OGLRef.texClearImageDepthStencilID); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, clearImageDepthBuffer); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, clearImageDepthBuffer); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); @@ -2582,7 +2582,7 @@ Render3DError OpenGLRenderer_1_5::CreatePBOs() for (unsigned int i = 0; i < 2; i++) { glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, OGLRef.pboRenderDataID[i]); - glBufferData(GL_PIXEL_PACK_BUFFER_ARB, 256 * 192 * sizeof(u32), NULL, GL_STREAM_READ); + glBufferData(GL_PIXEL_PACK_BUFFER_ARB, GFX3D_FRAMEBUFFER_WIDTH * GFX3D_FRAMEBUFFER_HEIGHT * sizeof(u32), NULL, GL_STREAM_READ); } glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); @@ -2713,7 +2713,7 @@ Render3DError OpenGLRenderer_1_5::ReadBackPixels() this->DownsampleFBO(); glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, this->ref->pboRenderDataID[i]); - glReadPixels(0, 0, 256, 192, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glReadPixels(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, 0); glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); } @@ -2751,7 +2751,7 @@ Render3DError OpenGLRenderer_1_5::RenderFinish() this->DownsampleFBO(); u32 *__restrict workingBuffer = this->GPU_screen3D[i]; - glReadPixels(0, 0, 256, 192, GL_BGRA, GL_UNSIGNED_BYTE, workingBuffer); + glReadPixels(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, workingBuffer); this->ConvertFramebuffer(workingBuffer, (u32 *)gfx3d_convertedScreen); } @@ -3203,7 +3203,7 @@ Render3DError OpenGLRenderer_2_1::ReadBackPixels() this->DownsampleFBO(); glBindBuffer(GL_PIXEL_PACK_BUFFER, this->ref->pboRenderDataID[i]); - glReadPixels(0, 0, 256, 192, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glReadPixels(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, 0); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); this->gpuScreen3DHasNewData[i] = true; diff --git a/desmume/src/OGLRender.h b/desmume/src/OGLRender.h index 1e967fbf7..422e371fc 100644 --- a/desmume/src/OGLRender.h +++ b/desmume/src/OGLRender.h @@ -418,7 +418,7 @@ protected: u16 currentToonTable16[32]; bool toonTableNeedsUpdate; - DS_ALIGN(16) u32 GPU_screen3D[2][256 * 192 * sizeof(u32)]; + DS_ALIGN(16) u32 GPU_screen3D[2][GFX3D_FRAMEBUFFER_WIDTH * GFX3D_FRAMEBUFFER_HEIGHT * sizeof(u32)]; bool gpuScreen3DHasNewData[2]; unsigned int doubleBufferIndex; u8 clearImageStencilValue; diff --git a/desmume/src/OGLRender_3_2.cpp b/desmume/src/OGLRender_3_2.cpp index be8188e08..c211a985c 100644 --- a/desmume/src/OGLRender_3_2.cpp +++ b/desmume/src/OGLRender_3_2.cpp @@ -297,9 +297,9 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs() glGenRenderbuffers(1, &OGLRef.rboFinalOutputDepthStencilID); glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboFinalOutputColorID); - glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, 256, 192); + glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT); glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboFinalOutputDepthStencilID); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 256, 192); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT); // Set up FBOs glGenFramebuffers(1, &OGLRef.fboClearImageID); @@ -400,9 +400,9 @@ Render3DError OpenGLRenderer_3_2::CreateMultisampledFBO() glGenRenderbuffers(1, &OGLRef.rboMultisampleDepthStencilID); glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMultisampleColorID); - glRenderbufferStorageMultisample(GL_RENDERBUFFER, maxSamples, GL_RGBA, 256, 192); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, maxSamples, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT); glBindRenderbuffer(GL_RENDERBUFFER, OGLRef.rboMultisampleDepthStencilID); - glRenderbufferStorageMultisample(GL_RENDERBUFFER, maxSamples, GL_DEPTH24_STENCIL8, 256, 192); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, maxSamples, GL_DEPTH24_STENCIL8, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT); // Set up multisampled rendering FBO glGenFramebuffers(1, &OGLRef.fboMultisampleRenderID); @@ -557,7 +557,7 @@ Render3DError OpenGLRenderer_3_2::DownsampleFBO() glBindFramebuffer(GL_READ_FRAMEBUFFER, OGLRef.selectedRenderingFBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, OGLRef.fboFinalOutputID); - glBlitFramebuffer(0, 0, 256, 192, 0, 0, 256, 192, GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.fboFinalOutputID); return OGLERROR_NOERR; @@ -569,7 +569,7 @@ Render3DError OpenGLRenderer_3_2::ClearUsingImage() const glBindFramebuffer(GL_READ_FRAMEBUFFER, OGLRef.fboClearImageID); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, OGLRef.selectedRenderingFBO); - glBlitFramebuffer(0, 0, 256, 192, 0, 0, 256, 192, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.selectedRenderingFBO); return OGLERROR_NOERR; diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 99dc4b233..4b5d8af1f 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -304,7 +304,7 @@ static float normalTable[1024]; #define fix2float(v) (((float)((s32)(v))) / (float)(1<<12)) #define fix10_2float(v) (((float)((s32)(v))) / (float)(1<<9)) -CACHE_ALIGN u8 gfx3d_convertedScreen[256*192*4]; +CACHE_ALIGN u8 gfx3d_convertedScreen[GFX3D_FRAMEBUFFER_WIDTH*GFX3D_FRAMEBUFFER_HEIGHT*4]; // Matrix stack handling CACHE_ALIGN MatrixStack mtxStack[4] = { @@ -2313,12 +2313,12 @@ void gfx3d_GetLineData(int line, u8** dst) void gfx3d_GetLineData15bpp(int line, u16** dst) { //TODO - this is not very thread safe!!! - static u16 buf[256]; + static u16 buf[GFX3D_FRAMEBUFFER_WIDTH]; *dst = buf; u8* lineData; gfx3d_GetLineData(line, &lineData); - for(int i=0;i<256;i++) + for(int i=0; i (RENDERER?256:engine->width)) + if(x+width > (RENDERER?GFX3D_FRAMEBUFFER_WIDTH:engine->width)) { if(RENDERER && !lineHack) { printf("rasterizer rendering at x=%d! oops!\n",x+width-1); return; } - width = (RENDERER?256:engine->width)-x; + width = (RENDERER?GFX3D_FRAMEBUFFER_WIDTH:engine->width)-x; } while(width-- > 0) @@ -854,7 +854,7 @@ public: bool first=true; //HACK: special handling for horizontal line poly - if (lineHack && left->Height == 0 && right->Height == 0 && left->Y<192 && left->Y>=0) + if (lineHack && left->Height == 0 && right->Height == 0 && left->YY>=0) { bool draw = (!SLI || (left->Y & SLI_MASK) == SLI_VALUE); if(draw) drawscanline(left,right,lineHack); @@ -1217,7 +1217,7 @@ static void SoftRastVramReconfigureSignal() static void SoftRastConvertFramebuffer() { - memcpy(gfx3d_convertedScreen,_screenColor,256*192*4); + memcpy(gfx3d_convertedScreen, _screenColor, GFX3D_FRAMEBUFFER_WIDTH*GFX3D_FRAMEBUFFER_HEIGHT*4); } void SoftRasterizerEngine::initFramebuffer(const int width, const int height, const bool clearImage) @@ -1246,7 +1246,7 @@ void SoftRasterizerEngine::initFramebuffer(const int width, const int height, co if(clearImage) { //need to handle this somehow.. - assert(width==256 && height==192); + assert(width==GFX3D_FRAMEBUFFER_WIDTH && height==GFX3D_FRAMEBUFFER_HEIGHT); u16* clearImage = (u16*)MMU.texInfo.textureSlotAddr[2]; u16* clearDepth = (u16*)MMU.texInfo.textureSlotAddr[3]; @@ -1260,9 +1260,9 @@ void SoftRasterizerEngine::initFramebuffer(const int width, const int height, co FragmentColor *dstColor = screenColor; Fragment *dst = screen; - for(int iy=0;iy<192;iy++) { + for(int iy=0; iy>3]; -#define PIXOFFSET(dx,dy) ((dx)+(256*(dy))) -#define ISEDGE(dx,dy) ((x+(dx)!=256) && (x+(dx)!=-1) && (y+(dy)!=192) && (y+(dy)!=-1) && self > screen[i+PIXOFFSET(dx,dy)].polyid.opaque) +#define PIXOFFSET(dx,dy) ((dx)+(GFX3D_FRAMEBUFFER_WIDTH*(dy))) +#define ISEDGE(dx,dy) ((x+(dx)!=GFX3D_FRAMEBUFFER_WIDTH) && (x+(dx)!=-1) && (y+(dy)!=GFX3D_FRAMEBUFFER_HEIGHT) && (y+(dy)!=-1) && self > screen[i+PIXOFFSET(dx,dy)].polyid.opaque) #define DRAWEDGE(dx,dy) alphaBlend(screenColor[i+PIXOFFSET(dx,dy)], edgeColor) bool upleft = ISEDGE(-1,-1); @@ -1457,7 +1457,7 @@ void SoftRasterizerEngine::framebufferProcess() u32 g = GFX3D_5TO6((gfx3d.renderState.fogColor>>5)&0x1F); u32 b = GFX3D_5TO6((gfx3d.renderState.fogColor>>10)&0x1F); u32 a = (gfx3d.renderState.fogColor>>16)&0x1F; - for(int i=0;i<256*192;i++) + for(int i=0; i void SoftRasterizerEngine::performViewportTransforms(int width, int height) { - const float xfactor = width/256.0f; - const float yfactor = height/192.0f; - const float xmax = 256.0f*xfactor-(CUSTOM?0.001f:0); //fudge factor to keep from overrunning render buffers - const float ymax = 192.0f*yfactor-(CUSTOM?0.001f:0); + const float xfactor = (float)width/GFX3D_FRAMEBUFFER_WIDTH; + const float yfactor = (float)height/GFX3D_FRAMEBUFFER_HEIGHT; + const float xmax = GFX3D_FRAMEBUFFER_WIDTH*xfactor-(CUSTOM?0.001f:0); //fudge factor to keep from overrunning render buffers + const float ymax = GFX3D_FRAMEBUFFER_HEIGHT*yfactor-(CUSTOM?0.001f:0); //viewport transforms @@ -1668,18 +1668,18 @@ static void SoftRastRender() mainSoftRasterizer.indexlist = &gfx3d.indexlist; mainSoftRasterizer.screen = _screen; mainSoftRasterizer.screenColor = _screenColor; - mainSoftRasterizer.width = 256; - mainSoftRasterizer.height = 192; + mainSoftRasterizer.width = GFX3D_FRAMEBUFFER_WIDTH; + mainSoftRasterizer.height = GFX3D_FRAMEBUFFER_HEIGHT; //setup fog variables (but only if fog is enabled) if(gfx3d.renderState.enableFog) mainSoftRasterizer.updateFogTable(); - mainSoftRasterizer.initFramebuffer(256,192,gfx3d.renderState.enableClearImage?true:false); + mainSoftRasterizer.initFramebuffer(GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, gfx3d.renderState.enableClearImage?true:false); mainSoftRasterizer.updateToonTable(); mainSoftRasterizer.updateFloatColors(); mainSoftRasterizer.performClipping(CommonSettings.GFX3D_HighResolutionInterpolateColor); - mainSoftRasterizer.performViewportTransforms(256,192); + mainSoftRasterizer.performViewportTransforms(GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT); mainSoftRasterizer.performBackfaceTests(); mainSoftRasterizer.performCoordAdjustment(true); mainSoftRasterizer.setupTextures(true);