From d7dc5effea73fee9312444860ec0d7dc0861fc6c Mon Sep 17 00:00:00 2001 From: mudlord Date: Thu, 10 Jan 2008 08:59:37 +0000 Subject: [PATCH] SDL-OpenGL fixes: - Filters > 2x now work with the OpenGL renderer - Window resizing with the OpenGL renderer is fixed - Fixed hq3x and hq4x when in 32bpp mode + C version of the filters - Disabled ASM CPU emulation core since it doesn't build here git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@281 a31d4220-a93d-0410-bf67-fe4944624d44 --- Makefile | 3 +-- src/hq/c/hq_base.h | 15 +++++++++++++++ src/sdl/SDL.cpp | 20 ++++++++++---------- src/sdl/filters.cpp | 37 +++++++++++++++++++------------------ 4 files changed, 45 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 4924066d..80db02af 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC=gcc CPPC=g++ -CFLAGS=-W -Wall -Wno-unused -O3 -DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DFINAL_VERSION -DBKPT_SUPPORT -DSDL -DSYSCONFDIR="home" -DUSE_OPENGL +CFLAGS=-W -Wall -Wno-unused -O3 -DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DFINAL_VERSION -DBKPT_SUPPORT -DSDL -DSYSCONFDIR="home" -DUSE_OPENGL -DC_CORE CXXFLAGS=${CFLAGS} ASM=nasm ASMFLAGS=-w-orphan-labels -f elf -DELF -O1 -Isrc/hq/asm/ @@ -69,7 +69,6 @@ ifeq ($(USEASM),yes) OBJECTS+=${ASMOBJ} else OBJECTS+=${CALTERNOBJ} -CFLAGS+=-DC_CORE endif ifeq ($(USEFEX),yes) diff --git a/src/hq/c/hq_base.h b/src/hq/c/hq_base.h index 9677a471..5f588320 100644 --- a/src/hq/c/hq_base.h +++ b/src/hq/c/hq_base.h @@ -420,6 +420,21 @@ int Xres, int Yres ) } } +#ifdef _32BIT + #ifdef _HQ3X +void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres) +{ + hq3x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres); +} + #endif + #ifdef _HQ4X +void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres) +{ + hq4x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres); +} + #endif +#endif + #undef SIZE_PIXEL #undef COLORTYPE #undef _MAGNIFICATION diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index 11253256..905ce67e 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -785,7 +785,7 @@ void sdlOpenGLInit(int w, int h) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, openGL == 2 ? GL_LINEAR : GL_NEAREST); - textureSize = filterFunction ? 512 : 256; + textureSize = 256 * filter_enlarge; glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize, textureSize, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); } @@ -1287,6 +1287,15 @@ void sdlPollEvents() case SDL_QUIT: emulating = 0; break; + case SDL_VIDEORESIZE: + if (openGL) + { + SDL_SetVideoMode(event.resize.w, event.resize.h, 16, + SDL_OPENGL | SDL_RESIZABLE | + (fullscreen ? SDL_FULLSCREEN : 0)); + sdlOpenGLInit(event.resize.w, event.resize.h); + } + break; case SDL_ACTIVEEVENT: if(pauseWhenInactive && (event.active.state & SDL_APPINPUTFOCUS)) { active = event.active.gain; @@ -1406,15 +1415,6 @@ void sdlPollEvents() } debugger = true; break; - case SDL_VIDEORESIZE: - if (openGL) - { - SDL_SetVideoMode(event.resize.w, event.resize.h, 16, - SDL_OPENGL | SDL_RESIZABLE | - (fullscreen ? SDL_FULLSCREEN : 0)); - sdlOpenGLInit(event.resize.w, event.resize.h); - } - break; case SDLK_F1: case SDLK_F2: case SDLK_F3: diff --git a/src/sdl/filters.cpp b/src/sdl/filters.cpp index 42122efe..e67203d2 100644 --- a/src/sdl/filters.cpp +++ b/src/sdl/filters.cpp @@ -52,8 +52,8 @@ extern void lq2x(u8*,u32,u8*,u8*,u32,int,int); extern void lq2x32(u8*,u32,u8*,u8*,u32,int,int); extern void hq3x16(u8*,u32,u8*,u8*,u32,int,int); extern void hq4x16(u8*,u32,u8*,u8*,u32,int,int); -extern void hq3x32(u8*,u32,u8*,u8*,u32,int,int); -extern void hq4x32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq3x32_32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq4x32_32(u8*,u32,u8*,u8*,u32,int,int); struct FilterDesc { char name[30]; @@ -79,9 +79,9 @@ const FilterDesc Filters[] = { { "lq2x", 2, lq2x, 0, lq2x32 }, { "hq2x", 2, hq2x, 0, hq2x32 }, { "Stretch 3x", 3, sdlStretch3x, sdlStretch3x, sdlStretch3x }, - { "hq3x", 3, hq3x16, 0, hq3x32 }, + { "hq3x", 3, hq3x16, 0, hq3x32_32 }, { "Stretch 4x", 4, sdlStretch4x, sdlStretch4x, sdlStretch4x }, - { "hq4x", 4, hq4x16, 0, hq4x32 } + { "hq4x", 4, hq4x16, 0, hq4x32_32 } }; int getFilterEnlargeFactor(const Filter f) @@ -117,29 +117,29 @@ FilterFunc initFilter(const Filter f, const int colorDepth, const int srcWidth) if (func) switch (f) { case kStretch1x: - sdlStretchInit(colorDepth, 0, srcWidth); + sdlStretchInit(colorDepth, 0, srcWidth); break; case kStretch2x: - sdlStretchInit(colorDepth, 1, srcWidth); + sdlStretchInit(colorDepth, 1, srcWidth); break; case kStretch3x: - sdlStretchInit(colorDepth, 2, srcWidth); + sdlStretchInit(colorDepth, 2, srcWidth); break; case kStretch4x: - sdlStretchInit(colorDepth, 3, srcWidth); + sdlStretchInit(colorDepth, 3, srcWidth); break; case k2xSaI: - case kSuper2xSaI: - case kSuperEagle: - if (colorDepth == 15) Init_2xSaI(555); - else if (colorDepth == 16) Init_2xSaI(565); - else Init_2xSaI(colorDepth); + case kSuper2xSaI: + case kSuperEagle: + if (colorDepth == 15) Init_2xSaI(555); + else if (colorDepth == 16) Init_2xSaI(565); + else Init_2xSaI(colorDepth); break; - case khq2x: - case klq2x: - hq2x_init(colorDepth); - break; - default: + case khq2x: + case klq2x: + hq2x_init(colorDepth); + break; + default: break; } @@ -615,3 +615,4 @@ void sdlStretch4x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 } } +