[Scummvm-cvs-logs] CVS: scummvm Makefile,1.47,1.48 Makefile.mingw,1.22,1.23 sdl.cpp,1.124,1.125
Travis Howell
kirben at users.sourceforge.net
Thu Jun 13 20:53:13 CEST 2002
Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv14975
Modified Files:
Makefile Makefile.mingw sdl.cpp
Log Message:
Add OpenGL support patch from Andre Souza
Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/scummvm/Makefile,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- Makefile 7 Jun 2002 14:11:29 -0000 1.47
+++ Makefile 14 Jun 2002 03:52:02 -0000 1.48
@@ -15,6 +15,9 @@
# DEFINES += -DUSE_ALSA
# LIBS += -lasound
+# Uncomment this to activate the OpenGL rendering routines (it needs SDL!)
+# LIBS += -lGL
+# DEFINES += -DOPENGL
# Now, please choose a graphical output system between SDL and X11.
# Beware, only define one of them, otherwise the compilation will blow up.
Index: Makefile.mingw
===================================================================
RCS file: /cvsroot/scummvm/scummvm/Makefile.mingw,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- Makefile.mingw 6 Jun 2002 09:15:27 -0000 1.22
+++ Makefile.mingw 14 Jun 2002 03:52:02 -0000 1.23
@@ -18,6 +18,10 @@
LIBS = -lmingw32 -lwinmm -lmad -lstdc++ $(SDL_LIBS)
EXEEXT :=.exe
+# Uncomment this to activate the OpenGL rendering routines (it needs SDL!)
+#LIBS += -lopengl32
+#DEFINES += -DOPENGL
+
OBJS = sdl.o scummvmico.o
include Makefile.common
Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sdl.cpp,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- sdl.cpp 4 Jun 2002 18:18:43 -0000 1.124
+++ sdl.cpp 14 Jun 2002 03:52:02 -0000 1.125
@@ -30,6 +30,21 @@
#include <SDL.h>
+
+#ifdef OPENGL
+
+#ifdef WIN32
+/* Use OpenGL 1.1 */
+#define OGL_1_1
+#endif
+
+#include "fb2opengl.h"
+
+int gl_shake=0;
+
+#endif
+
+
#define MAX(a,b) (((a)<(b)) ? (b) : (a))
#define MIN(a,b) (((a)>(b)) ? (b) : (a))
@@ -247,10 +262,14 @@
uint i;
SDL_Color *base = _cur_pal + start;
for(i=0;i!=num;i++) {
- base[i].r = b[0];
- base[i].g = b[1];
- base[i].b = b[2];
- b += 4;
+ #ifdef OPENGL
+ fb2gl_palette(i+start,b[0],b[1],b[2]);
+ #else
+ base[i].r = b[0];
+ base[i].g = b[1];
+ base[i].b = b[2];
+ #endif
+ b += 4;
}
if (start < _palette_changed_first)
@@ -267,7 +286,11 @@
_sai_func = NULL;
sdl_tmpscreen = NULL;
-
+
+#ifdef OPENGL
+ scaling=1;
+ _mode_flags |= DF_REAL_8BIT;
+#else
switch(_mode) {
case GFX_2XSAI:
scaling = 2;
@@ -303,11 +326,13 @@
scaling = 1;
break;
}
-
+#endif
+
sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 8, 0, 0, 0, 0);
if (sdl_screen == NULL)
error("sdl_screen failed failed");
+#ifndef OPENGL
if (_sai_func) {
uint16 *tmp_screen = (uint16*)calloc((SCREEN_WIDTH+3)*(SCREEN_HEIGHT+3),sizeof(uint16));
_mode_flags = DF_WANT_RECT_OPTIM | DF_SEPARATE_TEMPSCREEN | DF_UPDATE_EXPAND_1_PIXEL;
@@ -334,6 +359,9 @@
error("sdl_tmpscreen failed");
} else {
+#else
+ {
+#endif
switch(scaling) {
case 3:
_sai_func = Normal3x;
@@ -348,12 +376,20 @@
_mode_flags = DF_WANT_RECT_OPTIM | DF_REAL_8BIT;
+ #ifdef OPENGL
+ #ifdef OGL_1_1
+ fb2gl_init(640,480,0,70, FB2GL_FS | FB2GL_320 | FB2GL_PITCH | FB2GL_RGBA | FB2GL_EXPAND);
+ #else
+ fb2gl_init(640,480,0,70, FB2GL_FS | FB2GL_320 | FB2GL_PITCH);
+ #endif
+ #else
sdl_hwscreen = SDL_SetVideoMode(SCREEN_WIDTH * scaling, SCREEN_HEIGHT * scaling, 8,
_full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
);
if (sdl_hwscreen == NULL)
error("sdl_hwscreen failed");
-
+ #endif
+
sdl_tmpscreen = sdl_screen;
}
}
@@ -362,7 +398,9 @@
SDL_FreeSurface(sdl_screen);
sdl_screen = NULL;
+#ifndef OPENGL
SDL_FreeSurface(sdl_hwscreen);
+#endif
sdl_hwscreen = NULL;
if (_mode_flags & DF_SEPARATE_TEMPSCREEN) {
@@ -542,9 +580,11 @@
}
void OSystem_SDL::update_screen() {
-
+
+#ifndef OPENGL
if (sdl_hwscreen == NULL)
return; // Can this really happen?
+#endif
/* First make sure the mouse is drawn, if it should be drawn. */
draw_mouse();
@@ -554,10 +594,16 @@
* be set up for conversion from 8bit to 16bit.
*/
if (((_mode_flags & DF_REAL_8BIT) == 0) && _palette_changed_last != 0) {
+ #ifdef OPENGL
+ fb2gl_set_palette(_palette_changed_first,
+ _palette_changed_last - _palette_changed_first);
+ fb2gl_update(sdl_tmpscreen->pixels,320,200,320,0,gl_shake);
+ #else
SDL_SetColors(sdl_screen, _cur_pal + _palette_changed_first,
_palette_changed_first,
_palette_changed_last - _palette_changed_first);
-
+ #endif
+
_palette_changed_last = 0;
force_full = true;
@@ -567,13 +613,18 @@
/* If the shake position changed, fill the dirty area with blackness */
if (_current_shake_pos != _new_shake_pos) {
SDL_Rect blackrect = {0, 0, SCREEN_WIDTH*scaling, _new_shake_pos*scaling};
+ #ifdef OPENGL
+ gl_shake=_new_shake_pos;
+ fb2gl_update(sdl_tmpscreen->pixels,320,200,320,0,gl_shake);
+ #else
SDL_FillRect(sdl_hwscreen, &blackrect, 0);
-
+ #endif
_current_shake_pos = _new_shake_pos;
force_full = true;
}
+#ifndef OPENGL
/* force a full redraw if requested */
if (force_full) {
num_dirty_rects = 1;
@@ -659,20 +710,28 @@
SDL_UnlockSurface(sdl_tmpscreen);
SDL_UnlockSurface(sdl_hwscreen);
}
-
+#endif
+
/* Palette update in case we are in "real" 8 bit color mode.
* Must take place after the screen data was updated, since with
* "real" 8bit mode, palatte changes may be visible immediatly,
* and we want to avoid any ugly effects.
*/
if (_mode_flags & DF_REAL_8BIT && _palette_changed_last != 0) {
+ #ifdef OPENGL
+ fb2gl_set_palette(_palette_changed_first,
+ _palette_changed_last - _palette_changed_first);
+ fb2gl_update(sdl_tmpscreen->pixels,320,200,320,0,gl_shake);
+ #else
SDL_SetColors(sdl_hwscreen, _cur_pal + _palette_changed_first,
_palette_changed_first,
_palette_changed_last - _palette_changed_first);
+ #endif
_palette_changed_last = 0;
}
-
+
+#ifndef OPENGL
if (num_dirty_rects > 0) {
/* Finally, blit all our changes to the screen */
SDL_UpdateRects(sdl_hwscreen, num_dirty_rects, dirty_rect_list);
@@ -680,6 +739,16 @@
num_dirty_rects = 0;
force_full = false;
+#else /* OpenGL */
+ else gl_shake=0; /* _new_sake_pos == _current_shake_pos */
+ if (_palette_changed_last != 0) {
+ fb2gl_set_palette(_palette_changed_first,
+ _palette_changed_last - _palette_changed_first);
+ _palette_changed_last=0;
+ }
+ fb2gl_update(sdl_tmpscreen->pixels,320,200,320,0,gl_shake);
+#endif
+
}
bool OSystem_SDL::show_mouse(bool visible) {
@@ -875,11 +944,16 @@
force_full = true;
+#ifdef OPENGL
+ fb2gl_set_palette(0,256);
+ fb2gl_update(sdl_tmpscreen->pixels,320,200,320,0,gl_shake);
+#else
/* reset palette */
if (_mode_flags & DF_REAL_8BIT)
SDL_SetColors(sdl_hwscreen, _cur_pal, 0, 256);
else
SDL_SetColors(sdl_screen, _cur_pal, 0, 256);
+#endif
/* blit image */
OSystem_SDL::copy_rect(bak_mem, SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
More information about the Scummvm-git-logs
mailing list