- removed define tags out of COpenGL.*

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@8 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
gerstrong
2009-06-08 17:19:32 +00:00
parent 8352242dc6
commit 37cbe42b7e
25 changed files with 242 additions and 41 deletions

Binary file not shown.

View File

@@ -95,7 +95,7 @@ CPP_DEPS += \
src/ai/%.o: ../src/ai/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -26,7 +26,7 @@ CPP_DEPS += \
src/fileio/%.o: ../src/fileio/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -12,7 +12,8 @@ src/hqp/CHQBitmap.d src/hqp/CHQBitmap.o: ../src/hqp/CHQBitmap.cpp \
/usr/include/SDL/SDL_mouse.h /usr/include/SDL/SDL_video.h \
/usr/include/SDL/SDL_joystick.h /usr/include/SDL/SDL_quit.h \
/usr/include/SDL/SDL_loadso.h /usr/include/SDL/SDL_timer.h \
/usr/include/SDL/SDL_version.h
/usr/include/SDL/SDL_version.h ../src/hqp/../CLogFile.h \
../src/hqp/../CSingleton.h
../src/hqp/CHQBitmap.h:
@@ -67,3 +68,7 @@ src/hqp/CHQBitmap.d src/hqp/CHQBitmap.o: ../src/hqp/CHQBitmap.cpp \
/usr/include/SDL/SDL_timer.h:
/usr/include/SDL/SDL_version.h:
../src/hqp/../CLogFile.h:
../src/hqp/../CSingleton.h:

View File

@@ -23,7 +23,7 @@ CPP_DEPS += \
src/hqp/%.o: ../src/hqp/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -29,7 +29,7 @@ CPP_DEPS += \
src/scale2x/%.o: ../src/scale2x/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -23,7 +23,7 @@ CPP_DEPS += \
src/sdl/sound/%.o: ../src/sdl/sound/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -29,7 +29,7 @@ CPP_DEPS += \
src/sdl/%.o: ../src/sdl/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -17,7 +17,7 @@ CPP_DEPS += \
src/sdl/video/%.o: ../src/sdl/video/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -74,7 +74,7 @@ CPP_DEPS += \
src/%.o: ../src/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -17,7 +17,7 @@ CPP_DEPS += \
src/vorbis/%.o: ../src/vorbis/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -26,7 +26,7 @@ CPP_DEPS += \
src/vorticon/%.o: ../src/vorticon/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@@ -1,6 +1,11 @@
Commander Genius v0.2.9.1 Beta (CloneKeenPlus):
Commander Genius v0.2.9.2 Beta (CloneKeenPlus):
-----------------------------------------------
08-06-2009
- Added Doublebuffering support
- Detection of Bitmapsize in HQBitmap implemented
- Added Wiz-code and some fixed bugs (Thanks to Pickle)
07-06-2009
- Improved the timer
- Improved blit-speed at resolution of 320x200

View File

@@ -20,6 +20,7 @@
CGraphics::CGraphics() {
HQBitmap = NULL;
scrollbuffer=NULL;
blitbuffer=NULL;
scrollbuf_memsize = 0;
blitbuf_memsize = 0;
}
@@ -704,7 +705,7 @@ void CGraphics::loadHQGraphics(unsigned char episode, unsigned char level, char
screen_rect.h = g_pVideoDriver->getHeight();
HQBitmap = new CHQBitmap(screen_rect);
if(!HQBitmap->loadImage(buf2))
if(!HQBitmap->loadImage(buf2, (int) map.xsize, (int) map.ysize))
{
delete HQBitmap;
HQBitmap = NULL;

View File

@@ -103,7 +103,6 @@ void CLogFile::textOut(int Color, bool List, const char *Text)
textOut("<br>");
else
textOut("</li>");
}

View File

@@ -8,7 +8,7 @@
#ifndef CLOGFILE_H_
#define CLOGFILE_H_
#define REVISION "CloneKeenPlus Beta v0.2.9.1 (Commander Genius)"
#define REVISION "CloneKeenPlus Beta v0.2.9.2 (Commander Genius)"
#include <stdio.h>
#include "CSingleton.h"

View File

@@ -6,6 +6,7 @@
*/
#include "CHQBitmap.h"
#include "../CLogFile.h"
#include <stdlib.h>
CHQBitmap::CHQBitmap(SDL_Rect screenrect) {
@@ -21,21 +22,29 @@ CHQBitmap::~CHQBitmap() {
if(m_blackscreen){ SDL_FreeSurface(m_blackscreen); m_blackscreen = NULL;}
}
bool CHQBitmap::loadImage(const char *pFilename)
bool CHQBitmap::loadImage(const char *pFilename, int wsize, int hsize)
{
m_scrimg = SDL_LoadBMP(pFilename);
// TODO: Resolution detection and comparison with the tilesize must be performed
m_active = false;
m_active = true;
if(!m_scrimg)
m_active = false;
else
if(m_scrimg)
{
m_active = true;
// Create a empty black surface for alpha blending with black
m_blackscreen = SDL_CreateRGBSurface(SDL_SWSURFACE,
320,240,32,0,0,0,0);
if( ((m_scrimg->h>>4) > hsize) || ((m_scrimg->w>>4) > wsize) )
{
g_pLogFile->textOut(PURPLE,"HQBitmapLoader : The dimensions of the bitmap don't match to the dimensions of the level.<br>");
g_pLogFile->ftextOut("Please use a proper bitmap with %dx%d dimensions.<br>", m_scrimg->w, m_scrimg->h);
g_pLogFile->ftextOut("Your bitmap is of %dx%d.<br>", wsize, hsize);
g_pLogFile->textOut(BLUE,"HQBitmapLoader : Loading the level without HQBitmap.<br>");
}
else
{
m_active = true;
// Create a empty black surface for alpha blending with black
m_blackscreen = SDL_CreateRGBSurface(SDL_SWSURFACE,
320,240,32,0,0,0,0);
}
}
return m_active;
}

View File

@@ -17,7 +17,7 @@ public:
void setScrollposition(unsigned int xpos, unsigned int ypos);
void updateHQBitmap(SDL_Surface *m_surface, unsigned int x, unsigned int y);
bool loadImage(const char *pFilename);
bool loadImage(const char *pFilename, int wsize, int hsize);
void setAlphaBlend(Uint8 alpha);
void offsetAlphaBlend(Uint8 alpha);

View File

@@ -1535,7 +1535,6 @@ char ShowPressF10;
}*/
} while(!g_pInput->getExitEvent());
// TODO: This invokes Segfault. Please check, where!
if(g_pInput->getExitEvent())
return 1;

View File

@@ -11,6 +11,9 @@
#include "CInput.h"
#include "../CLogFile.h"
#ifdef WIZ
#include "gp2x.h"
#endif
CInput::CInput() {
@@ -127,9 +130,14 @@ bool CInput::readNewEvent(int position)
return true;
break;
case SDL_JOYBUTTONDOWN:
#ifdef WIZ
WIZ_EmuKeyboard( Event.jbutton.button, 1 );
return false;
#else
InputCommand[position].joyeventtype = ETYPE_JOYBUTTON;
InputCommand[position].joybutton = Event.jbutton.button;
return true;
#endif
break;
case SDL_JOYAXISMOTION:
InputCommand[position].joyeventtype = ETYPE_JOYAXIS;
@@ -180,8 +188,11 @@ void CInput::pollEvents()
processJoystickButton(0);
break;
}
}
#ifdef WIZ
WIZ_AdjustVolume( volume_direction );
#endif
}
void CInput::processJoystickAxis(void)
@@ -206,6 +217,9 @@ void CInput::processJoystickAxis(void)
}
void CInput::processJoystickButton(int value)
{
#ifdef WIZ
WIZ_EmuKeyboard( Event.jbutton.button, value );
#else
unsigned int i;
for(i=0 ; i<NUMBER_OF_COMMANDS ; i++)
{
@@ -216,6 +230,7 @@ void CInput::processJoystickButton(int value)
InputCommand[i].active = value;
}
}
#endif
}
void CInput::sendKey(int key){ immediate_keytable[key] = true; }
@@ -376,3 +391,133 @@ void CInput::flushKeys(void)
memset(immediate_keytable,false,KEYTABLE_SIZE);
memset(last_immediate_keytable,false,KEYTABLE_SIZE);
}
#ifdef WIZ
void CInput::WIZ_EmuKeyboard( int button, int value )
{
SDL_Event fakeevent1, fakeevent2;
//printf( "Button %d Value %d\n", button, value );
if( value == 1 ) {
fakeevent1.type = SDL_KEYDOWN;
fakeevent1.key.state = SDL_PRESSED;
fakeevent1.key.type = SDL_KEYDOWN;
fakeevent1.key.keysym.mod = KMOD_NONE;
fakeevent2.type = SDL_KEYDOWN;
fakeevent2.key.state = SDL_PRESSED;
fakeevent2.key.type = SDL_KEYDOWN;
fakeevent2.key.keysym.mod = KMOD_NONE;
}
else {
fakeevent1.type = SDL_KEYUP;
fakeevent1.key.state = SDL_RELEASED;
fakeevent1.key.type = SDL_KEYUP;
fakeevent1.key.keysym.mod = KMOD_NONE;
fakeevent2.type = SDL_KEYUP;
fakeevent2.key.state = SDL_RELEASED;
fakeevent2.key.type = SDL_KEYUP;
fakeevent2.key.keysym.mod = KMOD_NONE;
}
//printf( "Button %d %d\n", button, value );
fakeevent1.key.keysym.sym = SDLK_UNKNOWN;
fakeevent2.key.keysym.sym = SDLK_UNKNOWN;
switch(button)
{
case GP2X_BUTTON_LEFT:
fakeevent1.key.keysym.sym = SDLK_LEFT;
break;
case GP2X_BUTTON_RIGHT:
fakeevent1.key.keysym.sym = SDLK_RIGHT;
break;
case GP2X_BUTTON_UP:
fakeevent1.key.keysym.sym = SDLK_UP;
break;
case GP2X_BUTTON_DOWN:
fakeevent1.key.keysym.sym = SDLK_DOWN;
break;
case GP2X_BUTTON_SELECT:
fakeevent1.key.keysym.sym = SDLK_RETURN;
break;
case GP2X_BUTTON_START:
fakeevent1.key.keysym.sym = SDLK_ESCAPE;
break;
case GP2X_BUTTON_L:
fakeevent1.key.keysym.sym = SDLK_q;
fakeevent2.key.keysym.sym = SDLK_1;
break;
case GP2X_BUTTON_R:
fakeevent1.key.keysym.sym = SDLK_t;
fakeevent2.key.keysym.sym = SDLK_2;
break;
case GP2X_BUTTON_A:
fakeevent1.key.keysym.sym = SDLK_a;
break;
case GP2X_BUTTON_B:
fakeevent1.key.keysym.sym = SDLK_b;
break;
case GP2X_BUTTON_X:
fakeevent1.key.keysym.sym = SDLK_n;
break;
case GP2X_BUTTON_Y:
fakeevent1.key.keysym.sym = SDLK_y;
fakeevent2.key.keysym.sym = SDLK_F3;
break;
case GP2X_BUTTON_VOLUP:
if( value == 1)
volume_direction = VOLUME_UP;
else
volume_direction = VOLUME_NOCHG;
break;
case GP2X_BUTTON_VOLDOWN:
if( value == 1)
volume_direction = VOLUME_DOWN;
else
volume_direction = VOLUME_NOCHG;
break;
}
if( fakeevent1.key.keysym.sym != SDLK_UNKNOWN )
{
SDL_PushEvent (&fakeevent1);
}
if( fakeevent2.key.keysym.sym != SDLK_UNKNOWN )
{
SDL_PushEvent (&fakeevent2);
}
}
void CInput::WIZ_AdjustVolume( int direction )
{
if( direction != VOLUME_NOCHG )
{
if( volume <= 10 )
{
if( direction == VOLUME_UP ) volume += VOLUME_CHANGE_RATE/2;
if( direction == VOLUME_DOWN ) volume -= VOLUME_CHANGE_RATE/2;
}
else
{
if( direction == VOLUME_UP ) volume += VOLUME_CHANGE_RATE;
if( direction == VOLUME_DOWN ) volume -= VOLUME_CHANGE_RATE;
}
if( volume < VOLUME_MIN ) volume = VOLUME_MIN;
if( volume > VOLUME_MAX ) volume = VOLUME_MAX;
printf( "Volume Change: %i\n", volume );
unsigned long soundDev = open("/dev/mixer", O_RDWR);
if(soundDev)
{
int vol = ((volume << 8) | volume);
ioctl(soundDev, SOUND_MIXER_WRITE_PCM, &vol);
close(soundDev);
}
}
}
#endif

View File

@@ -8,6 +8,13 @@
#ifndef CINPUT_H_
#define CINPUT_H_
#ifdef WIZ
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <fcntl.h>
#include <unistd.h>
#endif
#include "../CSingleton.h"
#define g_pInput CInput::Get()
@@ -159,10 +166,18 @@ private:
bool immediate_keytable[KEYTABLE_SIZE];
bool last_immediate_keytable[KEYTABLE_SIZE];
#ifdef WIZ
int volume;
int volume_direction;
#endif
void processKeys(int value);
void processJoystickAxis(void);
void processJoystickButton(int value);
#ifdef WIZ
void WIZ_EmuKeyboard( int button, int value );
void WIZ_AdjustVolume( int direction );
#endif
};

View File

@@ -4,7 +4,6 @@
* Created on: 04.06.2009
* Author: gerstrong
*/
#include "COpenGL.h"
#include "../CLogFile.h"
@@ -102,8 +101,6 @@ bool COpenGL::initGL(unsigned Width, unsigned Height, unsigned char Depth,
g_pLogFile->ftextOut("OpenGL Init(): Interface succesfully opened!<br>");
}
// TODO: Find out where crashes, when OpenGL init failed!
return true;
}

View File

@@ -9,9 +9,6 @@
*
*/
#ifndef COPENGL_H_
#define COPENGL_H_
#include <SDL.h>
#include <SDL_opengl.h>
#include "../scale2x/scalebit.h"
@@ -35,4 +32,3 @@ private:
unsigned int m_texparam;
};
#endif /* COPENGL_H_ */

View File

@@ -57,8 +57,10 @@ CVideoDriver::CVideoDriver() {
FrameSkip=2;
m_targetfps = 0; // Disable automatic frameskipping by default
m_opengl = false;
#ifdef USE_OPENGL
m_opengl_filter = GL_NEAREST;
mp_OpenGL = NULL;
#endif
screenrect.x=0;
screenrect.y=0;
@@ -80,7 +82,10 @@ void CVideoDriver::stop(void)
if(screen) { SDL_FreeSurface(screen); g_pLogFile->textOut("freed screen<br>"); }
if(ScrollSurface && (ScrollSurface->map != NULL)) { SDL_FreeSurface(ScrollSurface); g_pLogFile->textOut("freed scrollsurface<br>"); }
if(blitsurface_alloc) { blitsurface_alloc = 0; SDL_FreeSurface(BlitSurface); g_pLogFile->textOut("freed blitsurface<br>"); }
#ifdef USE_OPENGL
if(mp_OpenGL) { delete mp_OpenGL; mp_OpenGL = NULL; }
#endif
g_pLogFile->textOut(GREEN,"CVideoDriver Close%s<br>", SDL_GetError());
}
@@ -121,12 +126,18 @@ bool CVideoDriver::applyMode(void)
// Grab a surface on the screen
Mode = SDL_HWPALETTE;
// Support for doublebuffering
Mode |= SDL_DOUBLEBUF;
// Enable OpenGL
#ifdef USE_OPENGL
if(m_opengl)
{
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
Mode |= SDL_OPENGL;
}
#endif
// Now we decide if it will be fullscreen or windowed mode.
if(Fullscreen)
@@ -245,6 +256,7 @@ bool CVideoDriver::createSurfaces(void)
dstrect.w = GAME_STD_WIDTH;
dstrect.h = GAME_STD_HEIGHT;
#ifdef USE_OPENGL
if(m_opengl) // If OpenGL could be set, initialize the matrices
{
mp_OpenGL = new COpenGL();
@@ -257,6 +269,7 @@ bool CVideoDriver::createSurfaces(void)
else
mp_OpenGL->setSurface(BlitSurface);
}
#endif
return true;
}
@@ -384,6 +397,7 @@ void CVideoDriver::blitBGLayer(void)
void CVideoDriver::update_screen(void)
{
#ifdef USE_OPENGL
if(m_opengl)
{
SDL_BlitSurface(FGLayerSurface, NULL, BlitSurface, NULL);
@@ -398,6 +412,7 @@ void CVideoDriver::update_screen(void)
}
else // No OpenGL but Software Rendering
{
#endif
SDL_BlitSurface(FGLayerSurface, NULL, BlitSurface, NULL);
// if we're doing zoom then we have copied the scroll buffer into
@@ -471,16 +486,19 @@ void CVideoDriver::update_screen(void)
}
SDL_UnlockSurface(screen);
SDL_UnlockSurface(BlitSurface);
}
SDL_UpdateRect(screen, screenrect.x, screenrect.y, screenrect.w, screenrect.h);
SDL_Flip(screen);
//SDL_UpdateRect(screen, screenrect.x, screenrect.y, screenrect.w, screenrect.h);
SDL_LockSurface(FGLayerSurface);
// Flush the layers
memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0),
GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel);
SDL_UnlockSurface(FGLayerSurface);
#ifdef USE_OPENGL
}
#endif
}
void CVideoDriver::noscale(char *dest, char *src, short bbp)

View File

@@ -11,7 +11,9 @@
#include "../CSingleton.h"
#define g_pVideoDriver CVideoDriver::Get()
#ifdef USE_OPENGL
#include "COpenGL.h"
#endif
#include <SDL.h>
@@ -56,23 +58,33 @@ public:
unsigned int getHeight(void);
unsigned short getDepth(void);
bool isOpenGL(void) { return m_opengl; }
#ifdef USE_OPENGL
unsigned char getOGLFilter(void) { return (m_opengl_filter==GL_LINEAR); }
#else
unsigned char getOGLFilter(void) { return 0; }
#endif
SDL_Surface *getScrollSurface(void);
SDL_Surface *getBGLayerSurface(void);
void setFrameskip(unsigned short value);
void setFilter(short value);
void setZoom(short value);
void setZoom(short vale);
#ifdef USE_OPENGL
void enableOpenGL(bool value) { m_opengl = value; }
void setOGLFilter(unsigned char value) { m_opengl_filter = (value==1) ? GL_LINEAR : GL_NEAREST ; }
void setTargetFPS(unsigned char targetfps){ if( targetfps >= 0 && targetfps <= 60 ) m_targetfps = targetfps; }
#else
void enableOpenGL(bool value) { m_opengl = false; }
void setOGLFilter(unsigned char value) { m_opengl_filter = 0; }
#endif
void setTargetFPS(unsigned int targetfps){ if( targetfps >= 0 && targetfps <= 60 ) m_targetfps = targetfps; }
unsigned char getTargetFPS(void){ return m_targetfps; }
void showFPS(bool value);
private:
#ifdef USE_OPENGL
COpenGL *mp_OpenGL;
#endif
unsigned int Width;
unsigned int Height;
@@ -82,7 +94,7 @@ private:
short Filtermode;
unsigned short Zoom;
unsigned short FrameSkip;
unsigned char m_targetfps; // Used for automatic frame skipping
unsigned int m_targetfps; // Used for automatic frame skipping
bool showfps;
bool m_opengl;
int m_opengl_filter;