From c781296ba772f97924aa04ff5cd4f3f7230e3d82 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 13 Mar 2017 20:34:51 +1100 Subject: [PATCH] [Glide64] Rename viewport_offset to g_viewport_offset; --- Source/Glide64/Main.cpp | 19 ++++----- Source/Glitch64/OGLESgeometry.cpp | 12 +++--- Source/Glitch64/OGLESglitchmain.cpp | 64 ++++++++++++++--------------- Source/Glitch64/OGLgeometry.cpp | 12 +++--- Source/Glitch64/OGLglitchmain.cpp | 56 ++++++++++++------------- Source/Glitch64/glitchmain.h | 2 +- 6 files changed, 81 insertions(+), 84 deletions(-) diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 68d241dc2..18332c0d5 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -81,7 +81,7 @@ int exception = FALSE; int evoodoo = 0; int ev_fullscreen = 0; -extern int viewport_offset; +extern int g_viewport_offset; extern int g_width, g_height; @@ -207,12 +207,6 @@ void ConfigWrapper() grConfigWrapperExt(g_settings->wrpVRAM() * 1024 * 1024, g_settings->wrpFBO(), g_settings->wrpAnisotropic()); } -void UseUnregisteredSetting(int /*SettingID*/) -{ -#ifdef _WIN32 - DebugBreak(); -#endif -} extern int g_width, g_height; int GetTexAddrUMA(int /*tmu*/, int texsize) @@ -380,9 +374,12 @@ void DisplayLoadProgress(const wchar_t *format, ...) #ifdef _WIN32 void SetWindowDisplaySize(HWND hWnd) { - if ((HWND)hWnd == NULL) hWnd = GetActiveWindow(); + if (hWnd == NULL) + { + hWnd = GetActiveWindow(); + } g_hwnd_win = (HWND)hWnd; - + if (ev_fullscreen) { ZeroMemory(&g_windowedRect, sizeof(RECT)); @@ -407,7 +404,7 @@ void SetWindowDisplaySize(HWND hWnd) SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); SetWindowPos(hWnd, NULL, 0, 0, g_width, g_height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW); - viewport_offset = 0; + g_viewport_offset = 0; g_fullscreen = true; } else @@ -427,7 +424,7 @@ void SetWindowDisplaySize(HWND hWnd) { GetWindowRect(hStatusBar, &statusbarRect); } - viewport_offset = statusbarRect.bottom - statusbarRect.top; + g_viewport_offset = statusbarRect.bottom - statusbarRect.top; GetWindowRect(hWnd, &g_windowedRect); GetClientRect(hWnd, &clientRect); g_windowedRect.right += (g_width - (clientRect.right - clientRect.left)); diff --git a/Source/Glitch64/OGLESgeometry.cpp b/Source/Glitch64/OGLESgeometry.cpp index 6133ee593..ad6eb3220 100644 --- a/Source/Glitch64/OGLESgeometry.cpp +++ b/Source/Glitch64/OGLESgeometry.cpp @@ -350,7 +350,7 @@ void FindBestDepthBias() glVertex3f(float(x + 4 - widtho) / (width / 2), float(4 - heighto) / (height / 2), 0.5); glVertex3f(float(x - widtho) / (width / 2), float(4 - heighto) / (height / 2), 0.5); glEnd(); - glReadPixels(x + 2, 2 + viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); + glReadPixels(x + 2, 2 + g_viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); z -= 0.75f + 8e-6f; if (z < 0.0f) z = -z; if (z > 0.01f) continue; @@ -397,7 +397,7 @@ grDrawTriangle(const void *a, const void *b, const void *c) vbo_enable(); if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -436,7 +436,7 @@ grDrawPoint(const void *pt) if(nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -506,7 +506,7 @@ grDrawLine(const void *a, const void *b) if(nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -579,7 +579,7 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -603,7 +603,7 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } diff --git a/Source/Glitch64/OGLESglitchmain.cpp b/Source/Glitch64/OGLESglitchmain.cpp index d35e2b97f..15c1e7a3f 100644 --- a/Source/Glitch64/OGLESglitchmain.cpp +++ b/Source/Glitch64/OGLESglitchmain.cpp @@ -71,8 +71,8 @@ if (x+width >= screen_width) { width = screen_width - x; //printf("resizing w --> %d\n", width); } -if (y+height >= screen_height+viewport_offset) { -height = screen_height+viewport_offset - y; +if (y+height >= screen_height+g_viewport_offset) { +height = screen_height+g_viewport_offset - y; //printf("resizing h --> %d\n", height); } glCopyTexSubImage2D(target, level, 0, 0, x, y, width, height); @@ -161,7 +161,7 @@ int default_texture; // the infamous "32*1024*1024" is now configurable int current_texture; int depth_texture, color_texture; int glsl_support = 1; -int viewport_width, viewport_height, viewport_offset = 0, nvidia_viewport_hack = 0; +int viewport_width, viewport_height, g_viewport_offset = 0, nvidia_viewport_hack = 0; int save_w, save_h; int lfb_color_fmt; float invtex[2]; @@ -280,11 +280,11 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy) if (int(miny) < 0) miny = 0; if (maxx < minx) maxx = minx; if (maxy < miny) maxy = miny; - glScissor(minx, miny + viewport_offset, maxx - minx, maxy - miny); + glScissor(minx, miny + g_viewport_offset, maxx - minx, maxy - miny); //printf("gl scissor %d %d %d %d\n", minx, miny, maxx, maxy); } else { - glScissor(minx, (viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); + glScissor(minx, (g_viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); } glEnable(GL_SCISSOR_TEST); } @@ -395,13 +395,13 @@ FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrColorFormat_t color_format, GrOrigi WriteTrace(TraceGlitch, TraceDebug, "color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", color_format, origin_location, nColBuffers, nAuxBuffers); WriteTrace(TraceGlitch, TraceDebug, "g_width: %d, g_height: %d fullscreen: %d", g_width, g_height, fullscreen); - //viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20; - // ZIGGY viewport_offset is WIN32 specific, with SDL just set it to zero - viewport_offset = 0; //-10 //-20; + //g_viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20; + // ZIGGY g_viewport_offset is WIN32 specific, with SDL just set it to zero + g_viewport_offset = 0; //-10 //-20; printf("(II) Setting video mode %dx%d...\n", g_width, g_height); - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); lfb_color_fmt = color_format; if (origin_location != GR_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "origin must be in upper left corner"); if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "number of color buffer is not 2"); @@ -529,12 +529,12 @@ FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrColorFormat_t color_format, GrOrigi #endif #ifdef _WIN32 - glViewport(0, viewport_offset, width, height); + glViewport(0, g_viewport_offset, width, height); viewport_width = width; viewport_height = height; nvidia_viewport_hack = 1; #else - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); viewport_width = g_width; viewport_height = g_height; #endif // _WIN32 @@ -725,26 +725,26 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, if (save_w) { if (tw > save_w && th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, tw, th - save_h); + 0, g_viewport_offset + save_h, tw, th - save_h); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; save_h = th; } else if (tw > save_w) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; } else if (th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, save_w, th - save_h); + 0, g_viewport_offset + save_h, save_w, th - save_h); save_h = th; } } else { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, - 0, viewport_offset, tw, th); + 0, g_viewport_offset, tw, th); save_w = tw; save_h = th; } @@ -793,12 +793,12 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, //printf("viewport %dx%d\n", width, height); if (g_height > screen_height) { - glViewport(0, viewport_offset + screen_height - g_height, g_width, g_height); + glViewport(0, g_viewport_offset + screen_height - g_height, g_width, g_height); } else - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); - glScissor(0, viewport_offset, g_width, g_height); + glScissor(0, g_viewport_offset, g_width, g_height); } else { if (!render_to_texture) //initialization @@ -1333,7 +1333,7 @@ void updateTexture() //glDeleteTextures( 1, &pBufferAddress ); glBindTexture(GL_TEXTURE_2D, pBufferAddress); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, - 0, viewport_offset, g_width, g_height, 0); + 0, g_viewport_offset, g_width, g_height, 0); glBindTexture(GL_TEXTURE_2D, default_texture); //glPopAttrib(); @@ -1359,7 +1359,7 @@ FX_ENTRY void FX_CALL grFramebufferCopyExt(int x, int y, int w, int h, //glReadBuffer(current_buffer); glBindTexture(GL_TEXTURE_2D, depth_texture); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, - 0, viewport_offset, tw, th, 0); + 0, g_viewport_offset, tw, th, 0); glBindTexture(GL_TEXTURE_2D, default_texture); return; } @@ -1422,8 +1422,8 @@ grRenderBuffer(GrBuffer_t buffer) } curBufferAddr = 0; - glViewport(0, viewport_offset, g_width, viewport_height); - glScissor(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, viewport_height); + glScissor(0, g_viewport_offset, g_width, g_height); #ifdef SAVE_CBUFFER if (!use_fbo && render_to_texture == 2) { @@ -1662,7 +1662,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 4; info->writeMode = GR_LFBWRITEMODE_888; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer); } else { buf = (unsigned char*)malloc(g_width*g_height * 4); @@ -1671,7 +1671,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_565; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < g_height; j++) { @@ -1692,7 +1692,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_ZA16; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); } } @@ -1741,7 +1741,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 4); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < src_height; j++) { @@ -1759,7 +1759,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 2); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); for (j = 0; j < src_height; j++) { @@ -1886,7 +1886,7 @@ FxI32 src_stride, void *src_data) } else { - float *buf = (float*)malloc(src_width*(src_height + (viewport_offset))*sizeof(float)); + float *buf = (float*)malloc(src_width*(src_height + (g_viewport_offset))*sizeof(float)); if (src_format != GR_LFBWRITEMODE_ZA16) WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer write format:%x", src_format); @@ -1898,14 +1898,14 @@ FxI32 src_stride, void *src_data) { for (i = 0; i < src_width; i++) { - buf[(j + (viewport_offset))*src_width + i] = + buf[(j + (g_viewport_offset))*src_width + i] = (frameBuffer[(src_height - j - 1)*(src_stride / 2) + i] / (65536.0f*(2.0f / zscale))) + 1 - zscale / 2.0f; } } #ifdef VPDEBUG if (dumping) { - unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (viewport_offset))); + unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (g_viewport_offset))); for (i = 0; i < src_width*src_height; i++) buf2[i] = buf[i] * 255.0f; ilTexImage(src_width, src_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buf2); @@ -1924,7 +1924,7 @@ FxI32 src_stride, void *src_data) //glDrawBuffer(GL_BACK); glClear(GL_DEPTH_BUFFER_BIT); glDepthMask(1); - //glDrawPixels(src_width, src_height+(viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); + //glDrawPixels(src_width, src_height+(g_viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); free(buf); } diff --git a/Source/Glitch64/OGLgeometry.cpp b/Source/Glitch64/OGLgeometry.cpp index 75bfc35e3..dc7b8c8a8 100644 --- a/Source/Glitch64/OGLgeometry.cpp +++ b/Source/Glitch64/OGLgeometry.cpp @@ -276,7 +276,7 @@ void FindBestDepthBias() glVertex3fv(vertices[3]); glEnd(); - glReadPixels(x + 2, 2 + viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); + glReadPixels(x + 2, 2 + g_viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); z -= 0.75f + 8e-6f; if (z < 0.0f) z = -z; if (z > 0.01f) continue; @@ -354,7 +354,7 @@ grDrawTriangle(const void *a, const void *b, const void *c) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -467,7 +467,7 @@ grDrawPoint(const void *pt) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -536,7 +536,7 @@ grDrawLine(const void *a, const void *b) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -612,7 +612,7 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -684,7 +684,7 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } diff --git a/Source/Glitch64/OGLglitchmain.cpp b/Source/Glitch64/OGLglitchmain.cpp index 85af0b374..283de0c84 100644 --- a/Source/Glitch64/OGLglitchmain.cpp +++ b/Source/Glitch64/OGLglitchmain.cpp @@ -51,8 +51,8 @@ static inline void opt_glCopyTexImage2D(GLenum target, width = screen_width - x; //printf("resizing w --> %d\n", width); } - if (y + height >= screen_height + viewport_offset) { - height = screen_height + viewport_offset - y; + if (y + height >= screen_height + g_viewport_offset) { + height = screen_height + g_viewport_offset - y; //printf("resizing h --> %d\n", height); } glCopyTexSubImage2D(target, level, 0, 0, x, y, width, height); @@ -292,7 +292,7 @@ int default_texture; // the infamous "32*1024*1024" is now configurable int current_texture; int depth_texture, color_texture; int glsl_support = 1; -int viewport_width, viewport_height, viewport_offset = 0, nvidia_viewport_hack = 0; +int viewport_width, viewport_height, g_viewport_offset = 0, nvidia_viewport_hack = 0; int save_w, save_h; int lfb_color_fmt; float invtex[2]; @@ -382,11 +382,11 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy) if (int(miny) < 0) miny = 0; if (maxx < minx) maxx = minx; if (maxy < miny) maxy = miny; - glScissor(minx, miny + viewport_offset, maxx - minx, maxy - miny); + glScissor(minx, miny + g_viewport_offset, maxx - minx, maxy - miny); //printf("gl scissor %d %d %d %d\n", minx, miny, maxx, maxy); } else { - glScissor(minx, (viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); + glScissor(minx, (g_viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); } glEnable(GL_SCISSOR_TEST); grDisplayGLError("grClipWindow"); @@ -766,12 +766,12 @@ int nAuxBuffers) #endif #ifndef ANDROID - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); viewport_width = g_width; viewport_height = g_height; nvidia_viewport_hack = 1; #else - glViewport(0, viewport_offset, width, height); + glViewport(0, g_viewport_offset, width, height); viewport_width = width; viewport_height = height; #endif // _WIN32 @@ -969,26 +969,26 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, if (save_w) { if (tw > save_w && th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, tw, th - save_h); + 0, g_viewport_offset + save_h, tw, th - save_h); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; save_h = th; } else if (tw > save_w) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; } else if (th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, save_w, th - save_h); + 0, g_viewport_offset + save_h, save_w, th - save_h); save_h = th; } } else { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, - 0, viewport_offset, tw, th); + 0, g_viewport_offset, tw, th); save_w = tw; save_h = th; } @@ -1037,12 +1037,12 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, //printf("viewport %dx%d\n", width, height); if (g_height > screen_height) { - glViewport(0, viewport_offset + screen_height - g_height, g_width, g_height); + glViewport(0, g_viewport_offset + screen_height - g_height, g_width, g_height); } else - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); - glScissor(0, viewport_offset, g_width, g_height); + glScissor(0, g_viewport_offset, g_width, g_height); grDisplayGLError("grTextureBufferExt :: A"); } @@ -1556,7 +1556,7 @@ void updateTexture() //glDeleteTextures( 1, &pBufferAddress ); glBindTexture(GL_TEXTURE_2D, pBufferAddress); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, - 0, viewport_offset, g_width, g_height, 0); + 0, g_viewport_offset, g_width, g_height, 0); glBindTexture(GL_TEXTURE_2D, default_texture); glPopAttrib(); @@ -1583,7 +1583,7 @@ FX_ENTRY void FX_CALL grFramebufferCopyExt(int /*x*/, int /*y*/, int /*w*/, int glReadBuffer(current_buffer); glBindTexture(GL_TEXTURE_2D, depth_texture); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, - 0, viewport_offset, tw, th, 0); + 0, g_viewport_offset, tw, th, 0); glBindTexture(GL_TEXTURE_2D, default_texture); grDisplayGLError("grFramebufferCopyExt :: A"); return; @@ -1648,8 +1648,8 @@ grRenderBuffer(GrBuffer_t buffer) } curBufferAddr = 0; - glViewport(0, viewport_offset, g_width, viewport_height); - glScissor(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, viewport_height); + glScissor(0, g_viewport_offset, g_width, g_height); #ifdef SAVE_CBUFFER if (!use_fbo && render_to_texture == 2) { @@ -1856,7 +1856,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 4; info->writeMode = GR_LFBWRITEMODE_888; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_BGRA, GL_UNSIGNED_BYTE, frameBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_BGRA, GL_UNSIGNED_BYTE, frameBuffer); } else { buf = (unsigned char*)malloc(g_width*g_height * 4); @@ -1865,7 +1865,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_565; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < g_height; j++) { @@ -1886,7 +1886,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_ZA16; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); } } @@ -1936,7 +1936,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 4); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < src_height; j++) { @@ -1954,7 +1954,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 2); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); for (j = 0; j < src_height; j++) { @@ -2082,7 +2082,7 @@ FxI32 src_stride, void *src_data) } else { - float *buf = (float*)malloc(src_width*(src_height + (viewport_offset))*sizeof(float)); + float *buf = (float*)malloc(src_width*(src_height + (g_viewport_offset))*sizeof(float)); if (src_format != GR_LFBWRITEMODE_ZA16) WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer write format:%x", src_format); @@ -2094,14 +2094,14 @@ FxI32 src_stride, void *src_data) { for (i = 0; i < src_width; i++) { - buf[(j + (viewport_offset))*src_width + i] = + buf[(j + (g_viewport_offset))*src_width + i] = (frameBuffer[(src_height - j - 1)*(src_stride / 2) + i] / (65536.0f*(2.0f / zscale))) + 1 - zscale / 2.0f; } } #ifdef VPDEBUG if (dumping) { - unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (viewport_offset))); + unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (g_viewport_offset))); for (i = 0; i < src_width*src_height; i++) buf2[i] = buf[i] * 255.0f; ilTexImage(src_width, src_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buf2); @@ -2120,7 +2120,7 @@ FxI32 src_stride, void *src_data) glDrawBuffer(GL_BACK); glClear(GL_DEPTH_BUFFER_BIT); glDepthMask(1); - glDrawPixels(src_width, src_height + (viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); + glDrawPixels(src_width, src_height + (g_viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); free(buf); } diff --git a/Source/Glitch64/glitchmain.h b/Source/Glitch64/glitchmain.h index 6d173577c..b95d993ed 100644 --- a/Source/Glitch64/glitchmain.h +++ b/Source/Glitch64/glitchmain.h @@ -155,7 +155,7 @@ extern int fog_coord_support; //extern int pbuffer_support; extern int glsl_support; extern unsigned int pBufferAddress; -extern int viewport_width, viewport_height, viewport_offset, nvidia_viewport_hack; +extern int viewport_width, viewport_height, g_viewport_offset, nvidia_viewport_hack; extern int UMAmode; void grChromaRangeExt(GrColor_t color0, GrColor_t color1, FxU32 mode);