X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=contrib%2Fsupertux-nogl.diff;h=f67baae10840b1a70601d07e0ae5c48ab6a3d20b;hb=ad961cb86ef28feed73e1f524fda692ed58d4e5e;hp=d4f01c636aa721c65a59f90497b3958d821d2a27;hpb=344734d5302a1a07840e5aa142262e4ed63dadbe;p=supertux.git diff --git a/contrib/supertux-nogl.diff b/contrib/supertux-nogl.diff index d4f01c636..f67baae10 100644 --- a/contrib/supertux-nogl.diff +++ b/contrib/supertux-nogl.diff @@ -32,8 +32,10 @@ # # patch -p1 < contrib/supertux-nogl.diff # +# This patch works for revision 4186. It may break for later revisions. +# # ----------------------------------------------------------------------------- -diff -Naur -x .svn -x build -x doxygen supertux/INSTALL supertux-nogl/INSTALL +diff -Naur supertux/INSTALL supertux-nogl/INSTALL --- supertux/INSTALL 2006-03-03 21:49:07.000000000 +0100 +++ supertux-nogl/INSTALL 2006-04-07 04:13:00.000000000 +0200 @@ -1,7 +1,7 @@ @@ -66,7 +68,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/INSTALL supertux-nogl/INSTALL * PhysicsFS (1.0.0, the development branch 1.1.x is buggy and does not work, 1.2.0 and later should work when it is released) http://www.icculus.org/physfs -diff -Naur -x .svn -x build -x doxygen supertux/README supertux-nogl/README +diff -Naur supertux/README supertux-nogl/README --- supertux/README 2006-03-03 20:43:38.000000000 +0100 +++ supertux-nogl/README 2006-04-07 04:13:00.000000000 +0200 @@ -2,7 +2,7 @@ @@ -92,7 +94,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/README supertux-nogl/README PLAYING THE GAME -diff -Naur -x .svn -x build -x doxygen supertux/configure.ac supertux-nogl/configure.ac +diff -Naur supertux/configure.ac supertux-nogl/configure.ac --- supertux/configure.ac 2006-03-03 20:43:38.000000000 +0100 +++ supertux-nogl/configure.ac 2006-04-07 04:13:00.000000000 +0200 @@ -11,7 +11,7 @@ @@ -104,7 +106,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/configure.ac supertux-nogl/confi AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_AUX_DIR([mk/autoconf]) AC_CANONICAL_TARGET -@@ -105,6 +105,14 @@ +@@ -120,6 +120,14 @@ [AC_MSG_ERROR([Please install SDLImage >= 1.2.1])], [$SDL_CFLAGS], [$SDL_LIBS]) @@ -119,7 +121,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/configure.ac supertux-nogl/confi NP_FINDLIB([PHYSFS], [physfs], [physfs >= 1.0.0], NP_LANG_PROGRAM([ #include -@@ -124,11 +132,6 @@ +@@ -139,11 +147,6 @@ [AC_MSG_ERROR([Please intall OpenAL])], [], []) @@ -131,84 +133,39 @@ diff -Naur -x .svn -x build -x doxygen supertux/configure.ac supertux-nogl/confi dnl Checks for library functions. AC_CHECK_FUNCS(mkdir strdup strstr) -diff -Naur -x .svn -x build -x doxygen supertux/src/Jamfile supertux-nogl/src/Jamfile +diff -Naur supertux/src/Jamfile supertux-nogl/src/Jamfile --- supertux/src/Jamfile 2006-03-03 20:34:49.000000000 +0100 +++ supertux-nogl/src/Jamfile 2006-04-07 04:11:50.000000000 +0200 -@@ -24,7 +24,7 @@ - Application supertux : $(sources) $(wrapper_objects) ; +@@ -26,7 +26,7 @@ + Application supertux : $(sources) $(wrapper_objects) : linkerfile ; C++Flags supertux : -DAPPDATADIR='\"$(appdatadir)\"' ; LinkWith supertux : squirrel ; -ExternalLibs supertux : SDL SDLIMAGE GL OPENAL VORBIS VORBISFILE OGG ICONV PHYSFS BINRELOC ; +ExternalLibs supertux : SDL SDLIMAGE SDLGFX OPENAL VORBIS VORBISFILE OGG ICONV PHYSFS BINRELOC ; Help supertux : "Build the supertux executable" ; - IncludeDir supertux : squirrel/include ; + IncludeDir supertux : squirrel/include squirrel ; -diff -Naur -x .svn -x build -x doxygen supertux/src/main.cpp supertux-nogl/src/main.cpp +diff -Naur supertux/src/main.cpp supertux-nogl/src/main.cpp --- supertux/src/main.cpp 2006-04-07 03:32:14.000000000 +0200 +++ supertux-nogl/src/main.cpp 2006-04-07 04:11:50.000000000 +0200 @@ -35,7 +35,6 @@ #include #include #include --#include +-#include #include "gameconfig.hpp" #include "resources.hpp" -@@ -266,44 +265,6 @@ - ; - } - --static void check_gl_error() --{ -- GLenum glerror = glGetError(); -- std::string errormsg; -- -- if(glerror != GL_NO_ERROR) { -- switch(glerror) { -- case GL_INVALID_ENUM: -- errormsg = "Invalid enumeration value"; -- break; -- case GL_INVALID_VALUE: -- errormsg = "Numeric argzment out of range"; -- break; -- case GL_INVALID_OPERATION: -- errormsg = "Invalid operation"; -- break; -- case GL_STACK_OVERFLOW: -- errormsg = "stack overflow"; -- break; -- case GL_STACK_UNDERFLOW: -- errormsg = "stack underflow"; -- break; -- case GL_OUT_OF_MEMORY: -- errormsg = "out of memory"; -- break; -- case GL_TABLE_TOO_LARGE: -- errormsg = "table too large"; -- break; -- default: -- errormsg = "unknown error number"; -- break; -- } -- std::stringstream msg; -- msg << "OpenGL Error: " << errormsg; -- throw std::runtime_error(msg.str()); -- } --} -- - void init_video() - { - if(texture_manager != NULL) -@@ -314,7 +275,7 @@ +@@ -308,7 +307,7 @@ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); - + - int flags = SDL_OPENGL; + int flags = SDL_SWSURFACE; if(config->use_fullscreen) flags |= SDL_FULLSCREEN; int width = config->screenwidth; -@@ -344,24 +305,6 @@ +@@ -338,24 +337,6 @@ } #endif @@ -228,24 +185,23 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/main.cpp supertux-nogl/src/m - glLoadIdentity(); - glTranslatef(0, 0, 0); - -- check_gl_error(); +- check_gl_error("Setting up view matrices"); - if(texture_manager != NULL) texture_manager->reload_textures(); else -diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp supertux-nogl/src/video/drawing_context.cpp ---- supertux/src/video/drawing_context.cpp 2006-03-31 04:18:01.000000000 +0200 -+++ supertux-nogl/src/video/drawing_context.cpp 2006-04-07 04:11:49.000000000 +0200 -@@ -22,8 +22,6 @@ +diff -aur supertux/src/video/drawing_context.cpp supertux-nogl/src/video/drawing_context.cpp +--- supertux/src/video/drawing_context.cpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/drawing_context.cpp 2006-07-03 02:00:29.000000000 +0200 +@@ -23,7 +23,6 @@ #include #include #include -#include --#include #include "drawing_context.hpp" #include "surface.hpp" -@@ -49,30 +47,20 @@ +@@ -49,24 +48,12 @@ { screen = SDL_GetVideoSurface(); @@ -271,15 +227,16 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su } void - DrawingContext::draw_surface(const Surface* surface, const Vector& position, - int layer) +@@ -74,6 +61,8 @@ + float angle, const Color& color, const Blend& blend, + int layer) { + if(target != NORMAL) return; + assert(surface != 0); - + DrawingRequest request; -@@ -97,6 +85,8 @@ +@@ -109,6 +98,8 @@ DrawingContext::draw_surface_part(const Surface* surface, const Vector& source, const Vector& size, const Vector& dest, int layer) { @@ -288,7 +245,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su assert(surface != 0); DrawingRequest request; -@@ -136,6 +126,8 @@ +@@ -148,6 +139,8 @@ DrawingContext::draw_text(const Font* font, const std::string& text, const Vector& position, FontAlignment alignment, int layer) { @@ -297,7 +254,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su DrawingRequest request; request.type = TEXT; -@@ -157,6 +149,8 @@ +@@ -169,6 +162,8 @@ DrawingContext::draw_center_text(const Font* font, const std::string& text, const Vector& position, int layer) { @@ -306,7 +263,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su draw_text(font, text, Vector(position.x + SCREEN_WIDTH/2, position.y), CENTER_ALLIGN, layer); } -@@ -164,6 +158,8 @@ +@@ -176,6 +171,8 @@ void DrawingContext::draw_gradient(const Color& top, const Color& bottom, int layer) { @@ -315,7 +272,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su DrawingRequest request; request.type = GRADIENT; -@@ -185,6 +181,8 @@ +@@ -197,6 +194,8 @@ DrawingContext::draw_filled_rect(const Vector& topleft, const Vector& size, const Color& color, int layer) { @@ -324,7 +281,64 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su DrawingRequest request; request.type = FILLRECT; -@@ -218,23 +216,55 @@ +@@ -219,6 +218,8 @@ + DrawingContext::draw_filled_rect(const Rect& rect, const Color& color, + int layer) + { ++ if(target != NORMAL) return; ++ + DrawingRequest request; + + request.type = FILLRECT; +@@ -238,39 +239,20 @@ + } + + void +-DrawingContext::get_light(const Vector& position, Color* color) ++DrawingContext::get_light(const Vector& , Color* color) + { +- if( ambient_color.red == 1.0f && ambient_color.green == 1.0f +- && ambient_color.blue == 1.0f ) { +- *color = Color( 1.0f, 1.0f, 1.0f); +- return; ++ static int i = 0; ++ i += 1; i &= 0xFFFF; ++ if (i & 0x8000) { ++ *color = Color(0.0f, 0.0f, 0.0f); ++ } else { ++ *color = Color(1.0f, 1.0f, 1.0f); + } +- DrawingRequest request; +- request.type = GETLIGHT; +- request.pos = transform.apply(position); +- request.layer = LAYER_GUI; //make sure all get_light requests are handled last. +- +- GetLightRequest* getlightrequest = new GetLightRequest; +- getlightrequest->color_ptr = color; +- request.request_data = getlightrequest; +- lightmap_requests.push_back(request); + } + + void +-DrawingContext::get_light(DrawingRequest& request) ++DrawingContext::get_light(DrawingRequest& ) + { +- GetLightRequest* getlightrequest = (GetLightRequest*) request.request_data; +- +- float pixels[3]; +- for( int i = 0; i<3; i++) +- pixels[i] = 0.0f; //set to black +- +- //TODO: hacky. Make coordinate conversion more generic +- glReadPixels((GLint) request.pos.x / 4, 600-(GLint)request.pos.y / 4, 1, 1, GL_RGB, GL_FLOAT, pixels); +- *(getlightrequest->color_ptr) = Color( pixels[0], pixels[1], pixels[2]); +- //printf("get_light %f/%f r%f g%f b%f\n", request.pos.x, request.pos.y, pixels[0], pixels[1], pixels[2]); +- +- delete getlightrequest; + } + + void +@@ -288,6 +264,45 @@ delete surfacepartrequest; } @@ -370,10 +384,10 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su void DrawingContext::draw_gradient(DrawingRequest& request) { - GradientRequest* gradientrequest = (GradientRequest*) request.request_data; +@@ -295,16 +310,9 @@ const Color& top = gradientrequest->top; const Color& bottom = gradientrequest->bottom; -- + - glDisable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glColor4f(top.red, top.green, top.blue, top.alpha); @@ -384,21 +398,24 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su - glVertex2f(0, SCREEN_HEIGHT); - glEnd(); - glEnable(GL_TEXTURE_2D); -+ + int width = 800; + int height = 600; + for(float y = 0; y < height; y += 2) ::fillrect(screen, 0, (int)y, width, 2, (int)(((float)(top.red-bottom.red)/(0-height)) * y + top.red), (int)(((float)(top.green-bottom.green)/(0-height)) * y + top.green), (int)(((float)(top.blue-bottom.blue)/(0-height)) * y + top.blue), 255); delete gradientrequest; } -@@ -260,17 +290,12 @@ +@@ -330,47 +338,19 @@ float w = fillrectrequest->size.x; float h = fillrectrequest->size.y; - glDisable(GL_TEXTURE_2D); - glColor4f(fillrectrequest->color.red, fillrectrequest->color.green, - fillrectrequest->color.blue, fillrectrequest->color.alpha); -- ++ int r = static_cast(fillrectrequest->color.red); ++ int g = static_cast(fillrectrequest->color.green); ++ int b = static_cast(fillrectrequest->color.blue); ++ int a = static_cast(fillrectrequest->color.alpha); + - glBegin(GL_QUADS); - glVertex2f(x, y); - glVertex2f(x+w, y); @@ -406,76 +423,86 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su - glVertex2f(x, y+h); - glEnd(); - glEnable(GL_TEXTURE_2D); -+ int r = static_cast(fillrectrequest->color.red); -+ int g = static_cast(fillrectrequest->color.green); -+ int b = static_cast(fillrectrequest->color.blue); -+ int a = static_cast(fillrectrequest->color.alpha); -+ + ::fillrect(screen, x, y, w, h, r, g, b, a); delete fillrectrequest; } -@@ -285,66 +310,10 @@ + + void +-DrawingContext::draw_lightmap(DrawingRequest& request) ++DrawingContext::draw_lightmap(DrawingRequest& ) + { +- const Texture* texture = reinterpret_cast (request.request_data); +- +- // multiple the lightmap with the framebuffer +- glBlendFunc(GL_DST_COLOR, GL_ZERO); +- +- glBindTexture(GL_TEXTURE_2D, texture->get_handle()); +- glBegin(GL_QUADS); +- +- glTexCoord2f(0, lightmap_uv_bottom); +- glVertex2f(0, 0); +- +- glTexCoord2f(lightmap_uv_right, lightmap_uv_bottom); +- glVertex2f(SCREEN_WIDTH, 0); +- +- glTexCoord2f(lightmap_uv_right, 0); +- glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT); +- +- glTexCoord2f(0, 0); +- glVertex2f(0, SCREEN_HEIGHT); +- +- glEnd(); +- +- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + void +@@ -383,50 +363,9 @@ transformstack.clear(); target_stack.clear(); -- bool use_lightmap = lightmap_requests.size() != 0; -- +- //Use Lightmap if ambient color is not white. +- bool use_lightmap = ( ambient_color.red != 1.0f || ambient_color.green != 1.0f || +- ambient_color.blue != 1.0f ); +- - // PART1: create lightmap - if(use_lightmap) { - glViewport(0, screen->h - lightmap_height, lightmap_width, lightmap_height); - glMatrixMode(GL_PROJECTION); -- glLoadIdentity(); +- glLoadIdentity(); - glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - -- //glClearColor(1.0f, 1.0f, 1.0f, 1.0f); -- glClearColor(0, 0, 0, 1); +- glClearColor( ambient_color.red, ambient_color.green, ambient_color.blue, 1 ); - glClear(GL_COLOR_BUFFER_BIT); - handle_drawing_requests(lightmap_requests); - lightmap_requests.clear(); -- +- - glDisable(GL_BLEND); - glBindTexture(GL_TEXTURE_2D, lightmap->get_handle()); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, screen->h - lightmap_height, lightmap_width, lightmap_height); - - glViewport(0, 0, screen->w, screen->h); - glMatrixMode(GL_PROJECTION); -- glLoadIdentity(); +- glLoadIdentity(); - glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0); -- glMatrixMode(GL_MODELVIEW); +- glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glEnable(GL_BLEND); +- +- // add a lightmap drawing request into the queue +- DrawingRequest request; +- request.type = LIGHTMAPREQUEST; +- request.layer = LAYER_HUD - 1; +- request.request_data = lightmap; +- requests->push_back(request); - } - - //glClear(GL_COLOR_BUFFER_BIT); handle_drawing_requests(drawing_requests); drawing_requests.clear(); - -- if(use_lightmap) { -- glBlendFunc(GL_SRC_ALPHA, GL_ONE); -- -- glBindTexture(GL_TEXTURE_2D, lightmap->get_handle()); -- glBegin(GL_QUADS); -- -- glTexCoord2f(0, lightmap_uv_bottom); -- glVertex2f(0, 0); -- -- glTexCoord2f(lightmap_uv_right, lightmap_uv_bottom); -- glVertex2f(SCREEN_WIDTH, 0); -- -- glTexCoord2f(lightmap_uv_right, 0); -- glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT); -- -- glTexCoord2f(0, 0); -- glVertex2f(0, SCREEN_HEIGHT); -- -- glEnd(); -- -- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -- } -- - assert_gl("drawing"); - - SDL_GL_SwapBuffers(); @@ -483,7 +510,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su } void -@@ -433,9 +402,5 @@ +@@ -524,10 +463,6 @@ DrawingContext::set_target(Target target) { this->target = target; @@ -493,10 +520,11 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.cpp su - requests = &drawing_requests; } -diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.hpp supertux-nogl/src/video/drawing_context.hpp ---- supertux/src/video/drawing_context.hpp 2006-03-03 20:34:27.000000000 +0100 -+++ supertux-nogl/src/video/drawing_context.hpp 2006-04-07 04:11:49.000000000 +0200 -@@ -23,7 +23,6 @@ + void +diff -aur supertux/src/video/drawing_context.hpp supertux-nogl/src/video/drawing_context.hpp +--- supertux/src/video/drawing_context.hpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/drawing_context.hpp 2006-07-03 02:00:29.000000000 +0200 +@@ -24,7 +24,6 @@ #include #include @@ -504,7 +532,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.hpp su #include #include #include -@@ -33,8 +32,9 @@ +@@ -35,8 +34,9 @@ #include "font.hpp" #include "color.hpp" @@ -515,13 +543,15 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.hpp su // some constants for predefined layer values enum { -@@ -202,16 +202,12 @@ +@@ -225,18 +225,14 @@ void draw_filled_rect(DrawingRequest& request); - + void draw_lightmap(DrawingRequest& request); + DrawingRequests drawing_requests; - DrawingRequests lightmap_requests; DrawingRequests* requests; + Color ambient_color; SDL_Surface* screen; Target target; @@ -532,16 +562,16 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/drawing_context.hpp su }; #endif -diff -Naur -x .svn -x build -x doxygen supertux/src/video/glutil.hpp supertux-nogl/src/video/glutil.hpp ---- supertux/src/video/glutil.hpp 2006-03-21 16:13:11.000000000 +0100 -+++ supertux-nogl/src/video/glutil.hpp 2006-04-07 04:11:49.000000000 +0200 -@@ -21,45 +21,13 @@ +diff -aur supertux/src/video/glutil.hpp supertux-nogl/src/video/glutil.hpp +--- supertux/src/video/glutil.hpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/glutil.hpp 2006-07-03 02:00:29.000000000 +0200 +@@ -21,58 +21,12 @@ #include #include -#include --static inline void assert_gl(const char* message) +-static inline void check_gl_error(const char* message) -{ -#ifdef DEBUG - GLenum error = glGetError(); @@ -570,170 +600,40 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/glutil.hpp supertux-no - msg << "OUT_OF_MEMORY: There is not enough memory left to execute the " - "command."; - break; +-#ifdef GL_TABLE_TOO_LARGE +- case GL_TABLE_TOO_LARGE: +- msg << "TABLE_TOO_LARGE: table is too large"; +- break; +-#endif - default: - msg << "Unknown error (code " << error << ")"; - } -- +- - throw std::runtime_error(msg.str()); - } -#endif -} +#define GLenum int ++#define GLint int +#define GL_SRC_ALPHA 0 +#define GL_ONE_MINUS_SRC_ALPHA 1 +#define GL_RGBA 2 -+ -+ - - #endif - -diff -Naur -x .svn -x build -x doxygen supertux/src/video/screen.cpp supertux-nogl/src/video/screen.cpp ---- supertux/src/video/screen.cpp 2006-04-07 03:32:13.000000000 +0200 -+++ supertux-nogl/src/video/screen.cpp 2006-04-07 04:11:49.000000000 +0200 -@@ -38,61 +38,70 @@ ++#define GL_ONE 3 - static const float LOOP_DELAY = 20.0; - --void fillrect(float x, float y, float w, float h, const Color& col) +-static inline void assert_gl(const char* message) -{ -- if(w < 0) { -- x += w; -- w = -w; -- } -- if(h < 0) { -- y += h; -- h = -h; -- } -- -- glColor4f(col.red, col.green, col.blue, col.alpha); - -- glDisable(GL_TEXTURE_2D); -- glBegin(GL_POLYGON); -- glVertex2f(x, y); -- glVertex2f(x+w, y); -- glVertex2f(x+w, y+h); -- glVertex2f(x, y+h); -- glEnd(); -- glEnable(GL_TEXTURE_2D); -- -- glColor4f(0, 0, 0, 1); -+void fillrect(float x, float y, float w, float h, int r, int g, int b, int a) -+ { -+ SDL_Surface* screen = SDL_GetVideoSurface(); -+ -+ if(w < 0) { -+ x += w; -+ w = -w; -+ } -+ if(h < 0) { -+ y += h; -+ h = -h; -+ } -+ -+ SDL_Rect src, rect; -+ SDL_Surface *temp = NULL; -+ -+ rect.x = (int)x; -+ rect.y = (int)y; -+ rect.w = (int)w; -+ rect.h = (int)h; -+ -+ if(a != 255) { -+ temp = SDL_CreateRGBSurface(screen->flags, rect.w, rect.h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); -+ -+ src.x = 0; -+ src.y = 0; -+ src.w = rect.w; -+ src.h = rect.h; -+ -+ SDL_FillRect(temp, &src, SDL_MapRGB(screen->format, r, g, b)); -+ SDL_SetAlpha(temp, SDL_SRCALPHA, a); -+ SDL_BlitSurface(temp,0,screen,&rect); -+ SDL_FreeSurface(temp); -+ } -+ else -+ SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b)); - } - - void fadeout(float fade_time) - { -- float alpha_inc = LOOP_DELAY / fade_time; -- Color c(0, 0, 0, alpha_inc); -- float alpha = 1.0; -+ float alpha_inc = 256 / (fade_time / LOOP_DELAY); -+ float alpha = 256; - -- while(alpha >= 0) { -+ while(alpha > 0) { - alpha -= alpha_inc; -- fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, c); -- // left side -+ fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0,0,0, (int)alpha_inc); // left side - -- SDL_GL_SwapBuffers(); -+ SDL_Flip(SDL_GetVideoSurface()); - sound_manager->update(); - - SDL_Delay(int(LOOP_DELAY)); -- alpha -= alpha_inc; - } -- -- fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, Color()); -+ fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 255); - } - - void shrink_fade(const Vector& point, float fade_time) - { -- float left_inc = point.x / (fade_time / LOOP_DELAY); -- float right_inc = (SCREEN_WIDTH - point.x) / (fade_time / LOOP_DELAY); -- float up_inc = point.y / (fade_time / LOOP_DELAY); -- float down_inc = (SCREEN_HEIGHT - point.y) / (fade_time / LOOP_DELAY); -+ float left_inc = point.x / ((float)fade_time / LOOP_DELAY); -+ float right_inc = (SCREEN_WIDTH - point.x) / ((float)fade_time / LOOP_DELAY); -+ float up_inc = point.y / ((float)fade_time / LOOP_DELAY); -+ float down_inc = (SCREEN_HEIGHT - point.y) / ((float)fade_time / LOOP_DELAY); - - float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0; -- Color c; - - while(left_cor < point.x && right_cor < SCREEN_WIDTH - point.x && - up_cor < point.y && down_cor < SCREEN_HEIGHT - point.y) { -@@ -101,15 +110,14 @@ - up_cor += up_inc; - down_cor += down_inc; - -- fillrect(0, 0, left_cor, SCREEN_HEIGHT, c); // left side -- fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, c); // right side -- fillrect(0, 0, SCREEN_WIDTH, up_cor, c); // up side -- fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, c); // down side -+ fillrect(0, 0, left_cor, SCREEN_HEIGHT, 0,0,0, 255); // left side -+ fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, 0,0,0, 255); // right side -+ fillrect(0, 0, SCREEN_WIDTH, up_cor, 0,0,0, 255); // up side -+ fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, 0,0,0, 255); // down side - -- SDL_GL_SwapBuffers(); -+ SDL_Flip(SDL_GetVideoSurface()); - - sound_manager->update(); - SDL_Delay(int(LOOP_DELAY)); - } - } +-#ifdef DEBUG +- check_gl_error(message); +-#else +- (void) message; + #endif +-} - -diff -Naur -x .svn -x build -x doxygen supertux/src/video/screen.hpp supertux-nogl/src/video/screen.hpp ---- supertux/src/video/screen.hpp 2006-04-07 03:32:13.000000000 +0200 -+++ supertux-nogl/src/video/screen.hpp 2006-04-07 04:11:49.000000000 +0200 -@@ -20,7 +20,6 @@ - #define SUPERTUX_SCREEN_H - - #include --#include - #include - - #include -diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-nogl/src/video/surface.cpp ---- supertux/src/video/surface.cpp 2006-03-25 01:16:31.000000000 +0100 -+++ supertux-nogl/src/video/surface.cpp 2006-04-07 04:11:49.000000000 +0200 -@@ -28,6 +29,7 @@ +-#endif +diff -aur supertux/src/video/surface.cpp supertux-nogl/src/video/surface.cpp +--- supertux/src/video/surface.cpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/surface.cpp 2006-07-03 02:00:29.000000000 +0200 +@@ -28,6 +28,7 @@ #include #include @@ -741,7 +641,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n #include "gameconfig.hpp" #include "physfs/physfs_sdl.hpp" -@@ -40,13 +42,13 @@ +@@ -41,13 +42,13 @@ { texture = texture_manager->get(file); texture->ref(); @@ -761,7 +661,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n } Surface::Surface(const std::string& file, int x, int y, int w, int h) -@@ -54,15 +56,12 @@ +@@ -55,15 +56,12 @@ texture = texture_manager->get(file); texture->ref(); @@ -781,7 +681,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n } Surface::Surface(const Surface& other) -@@ -70,12 +69,12 @@ +@@ -71,12 +69,12 @@ texture = other.texture; texture->ref(); @@ -798,7 +698,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n } const Surface& -@@ -85,81 +84,95 @@ +@@ -86,52 +84,33 @@ texture->unref(); texture = other.texture; @@ -830,8 +730,9 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n Surface::hflip() { - std::swap(uv_left, uv_right); --} -- ++ flipx = !flipx; + } + -static inline void intern_draw(float left, float top, float right, float bottom, float uv_left, float uv_top, - float uv_right, float uv_bottom, - DrawingEffect effect) @@ -841,11 +742,11 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n - if(effect & VERTICAL_FLIP) { - std::swap(uv_top, uv_bottom); - } -- +- - glBegin(GL_QUADS); - glTexCoord2f(uv_left, uv_top); - glVertex2f(left, top); -- +- - glTexCoord2f(uv_right, uv_top); - glVertex2f(right, top); - @@ -855,7 +756,33 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n - glTexCoord2f(uv_left, uv_bottom); - glVertex2f(left, bottom); - glEnd(); -+ flipx = !flipx; +-} +- ++/* + static inline void intern_draw2(float left, float top, float right, float bottom, + float uv_left, float uv_top, + float uv_right, float uv_bottom, +@@ -182,50 +161,76 @@ + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } ++*/ + + void +-Surface::draw(float x, float y, float alpha, float angle, const Color& color, const Blend& blend, DrawingEffect effect) const ++Surface::draw(float x, float y, float alpha, float, const Color&, const Blend&, DrawingEffect effect) const + { +- glColor4f(1.0f, 1.0f, 1.0f, alpha); +- glBindTexture(GL_TEXTURE_2D, texture->get_handle()); +- +- intern_draw2(x, y, +- x + width, y + height, +- uv_left, uv_top, uv_right, uv_bottom, +- angle, +- color, +- blend, +- effect); ++ draw_part(0, 0, x, y, width, height, alpha, effect); } void @@ -873,34 +800,31 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n void Surface::draw_part(float src_x, float src_y, float dst_x, float dst_y, - float width, float height, float alpha, -+ float width, float height, float, ++ float width, float height, float , DrawingEffect effect) const { - float uv_width = uv_right - uv_left; - float uv_height = uv_bottom - uv_top; -- ++ //FIXME: support parameter "alpha" ++ SDL_Surface* surface = texture->getSurface(); + - float uv_left = this->uv_left + (uv_width * src_x) / this->width; - float uv_top = this->uv_top + (uv_height * src_y) / this->height; - float uv_right = this->uv_left + (uv_width * (src_x + width)) / this->width; - float uv_bottom = this->uv_top + (uv_height * (src_y + height)) / this->height; -- -- glColor4f(1.0f, 1.0f, 1.0f, alpha); -- glBindTexture(GL_TEXTURE_2D, texture->get_handle()); -- -- intern_draw(dst_x, dst_y, -- dst_x + width, dst_y + height, -- uv_left, uv_top, uv_right, uv_bottom, effect); -+ //FIXME: support parameter "alpha" -+ SDL_Surface* surface = texture->getSurface(); -+ + // get and check SDL_Surface + if (surface == 0) { + std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl; + return; + } -+ + +- glColor4f(1.0f, 1.0f, 1.0f, alpha); +- glBindTexture(GL_TEXTURE_2D, texture->get_handle()); + SDL_Surface* transformedSurface = surface; -+ + +- intern_draw(dst_x, dst_y, +- dst_x + width, dst_y + height, +- uv_left, uv_top, uv_right, uv_bottom, effect); + if (flipx) effect = HORIZONTAL_FLIP; + + if (effect != NO_EFFECT) { @@ -944,10 +868,9 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.cpp supertux-n + + SDL_BlitSurface(transformedSurface, &srcRect, screen, &dstRect); } - -diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.hpp supertux-nogl/src/video/surface.hpp ---- supertux/src/video/surface.hpp 2006-03-03 20:34:27.000000000 +0100 -+++ supertux-nogl/src/video/surface.hpp 2006-04-07 04:11:49.000000000 +0200 +diff -aur supertux/src/video/surface.hpp supertux-nogl/src/video/surface.hpp +--- supertux/src/video/surface.hpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/surface.hpp 2006-07-03 02:00:29.000000000 +0200 @@ -20,7 +20,9 @@ #ifndef __SURFACE_HPP__ #define __SURFACE_HPP__ @@ -955,10 +878,10 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.hpp supertux-n +#include #include +#include + #include "math/vector.hpp" - class ImageTexture; - -@@ -35,6 +37,15 @@ + class Color; +@@ -37,6 +39,15 @@ }; /** @@ -974,7 +897,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.hpp supertux-n * A rectangular image. * The class basically holds a reference to a texture with additional UV * coordinates that specify a rectangular area on this texture -@@ -46,18 +57,23 @@ +@@ -48,19 +59,26 @@ friend class Font; ImageTexture* texture; @@ -985,8 +908,11 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.hpp supertux-n + bool flipx; + /** draw the surface on the screen, applying a ::DrawingEffect on-the-fly. Transformed Surfaces will be cached in ::transformedSurfaces */ + void draw(float x, float y, float alpha, float angle, const Color& color, const Blend& blend, DrawingEffect effect) const; ++ ++ /** draw the surface on the screen, applying a ::DrawingEffect on-the-fly. Transformed Surfaces will be cached in ::transformedSurfaces */ void draw(float x, float y, float alpha, DrawingEffect effect) const; -+ ++ + /** draw the surface on the screen, applying a ::DrawingEffect on-the-fly. Transformed Surfaces will be cached in ::transformedSurfaces */ void draw_part(float src_x, float src_y, float dst_x, float dst_y, float width, float height, @@ -1004,10 +930,10 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/surface.hpp supertux-n public: Surface(const std::string& file); Surface(const std::string& file, int x, int y, int w, int h); -diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.cpp supertux-nogl/src/video/texture.cpp ---- supertux/src/video/texture.cpp 2006-03-03 20:34:27.000000000 +0100 -+++ supertux-nogl/src/video/texture.cpp 2006-04-07 04:11:49.000000000 +0200 -@@ -20,7 +20,6 @@ +diff -aur supertux/src/video/texture.cpp supertux-nogl/src/video/texture.cpp +--- supertux/src/video/texture.cpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/texture.cpp 2006-07-03 02:00:29.000000000 +0200 +@@ -21,7 +21,6 @@ #include "texture.hpp" @@ -1015,7 +941,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.cpp supertux-n #include #include "glutil.hpp" -@@ -29,81 +28,37 @@ +@@ -30,7 +29,7 @@ return (v & (v-1)) == 0; } @@ -1024,13 +950,13 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.cpp supertux-n { assert(is_power_of_2(w)); assert(is_power_of_2(h)); - +@@ -38,23 +37,10 @@ this->width = w; this->height = h; -- + - assert_gl("before creating texture"); - glGenTextures(1, &handle); -- +- - try { - glBindTexture(GL_TEXTURE_2D, handle); - @@ -1042,7 +968,6 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.cpp supertux-n - glDeleteTextures(1, &handle); - throw; - } -+ + surface = 0; } @@ -1051,17 +976,13 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.cpp supertux-n { const SDL_PixelFormat* format = image->format; if(!is_power_of_2(image->w) || !is_power_of_2(image->h)) - throw std::runtime_error("image has no power of 2 size"); - if(format->BitsPerPixel != 24 && format->BitsPerPixel != 32) - throw std::runtime_error("image has no 24 or 32 bit color depth"); -- -+ +@@ -65,45 +51,14 @@ this->width = image->w; this->height = image->h; - assert_gl("before creating texture"); - glGenTextures(1, &handle); -- +- - try { - GLenum sdl_format; - if(format->BytesPerPixel == 3) @@ -1079,7 +1000,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.cpp supertux-n - - assert_gl("creating texture"); - -- set_texture_params(); +- set_texture_params(); - } catch(...) { - glDeleteTextures(1, &handle); - throw; @@ -1102,11 +1023,10 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.cpp supertux-n - - assert_gl("set texture params"); } - -diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.hpp supertux-nogl/src/video/texture.hpp ---- supertux/src/video/texture.hpp 2006-03-03 20:34:27.000000000 +0100 -+++ supertux-nogl/src/video/texture.hpp 2006-04-07 04:11:49.000000000 +0200 -@@ -20,7 +20,7 @@ +diff -aur supertux/src/video/texture.hpp supertux-nogl/src/video/texture.hpp +--- supertux/src/video/texture.hpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/texture.hpp 2006-07-03 02:00:29.000000000 +0200 +@@ -21,7 +21,7 @@ #define __TEXTURE_HPP__ #include @@ -1115,7 +1035,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.hpp supertux-n /** * This class is a wrapper around a texture handle. It stores the texture width -@@ -30,8 +30,9 @@ +@@ -31,8 +31,9 @@ class Texture { protected: @@ -1126,10 +1046,10 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.hpp supertux-n unsigned int width; unsigned int height; -@@ -40,11 +41,6 @@ +@@ -41,11 +42,6 @@ Texture(SDL_Surface* surface, GLenum glformat); virtual ~Texture(); - + - GLuint get_handle() const - { - return handle; @@ -1138,7 +1058,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.hpp supertux-n unsigned int get_width() const { return width; -@@ -55,6 +51,14 @@ +@@ -56,6 +52,14 @@ return height; } @@ -1153,10 +1073,10 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture.hpp supertux-n private: void set_texture_params(); }; -diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.cpp supertux-nogl/src/video/texture_manager.cpp ---- supertux/src/video/texture_manager.cpp 2006-04-07 03:32:13.000000000 +0200 -+++ supertux-nogl/src/video/texture_manager.cpp 2006-04-07 04:11:49.000000000 +0200 -@@ -5,8 +5,6 @@ +diff -aur supertux/src/video/texture_manager.cpp supertux-nogl/src/video/texture_manager.cpp +--- supertux/src/video/texture_manager.cpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/texture_manager.cpp 2006-07-03 02:00:29.000000000 +0200 +@@ -24,8 +24,6 @@ #include #include #include @@ -1165,7 +1085,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.cpp su #include #include #include -@@ -126,12 +124,6 @@ +@@ -145,12 +143,6 @@ void TextureManager::save_textures() { @@ -1178,7 +1098,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.cpp su for(Textures::iterator i = textures.begin(); i != textures.end(); ++i) { save_texture(*i); } -@@ -146,75 +138,16 @@ +@@ -165,74 +157,15 @@ { SavedTexture saved_texture; saved_texture.texture = texture; @@ -1200,7 +1120,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.cpp su size_t pixelssize = saved_texture.width * saved_texture.height * 4; saved_texture.pixels = new char[pixelssize]; -- +- - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, - saved_texture.pixels); @@ -1209,7 +1129,7 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.cpp su - glDeleteTextures(1, &(texture->handle)); - texture->handle = 0; - -- assert_gl("retrieving texture"); +- assert_gl("retrieving texture for save"); } void @@ -1221,11 +1141,11 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.cpp su - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); -- +- - for(std::vector::iterator i = saved_textures.begin(); - i != saved_textures.end(); ++i) { - SavedTexture& saved_texture = *i; -- +- - GLuint handle; - glGenTextures(1, &handle); - assert_gl("creating texture handle"); @@ -1253,15 +1173,15 @@ diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.cpp su - saved_textures.clear(); } - -diff -Naur -x .svn -x build -x doxygen supertux/src/video/texture_manager.hpp supertux-nogl/src/video/texture_manager.hpp ---- supertux/src/video/texture_manager.hpp 2006-03-03 20:34:27.000000000 +0100 -+++ supertux-nogl/src/video/texture_manager.hpp 2006-04-07 04:11:49.000000000 +0200 -@@ -1,7 +1,6 @@ +diff -aur supertux/src/video/texture_manager.hpp supertux-nogl/src/video/texture_manager.hpp +--- supertux/src/video/texture_manager.hpp 2006-07-03 02:00:48.000000000 +0200 ++++ supertux-nogl/src/video/texture_manager.hpp 2006-07-03 02:00:29.000000000 +0200 +@@ -20,7 +20,7 @@ #ifndef __IMAGE_TEXTURE_MANAGER_HPP__ #define __IMAGE_TEXTURE_MANAGER_HPP__ -#include ++#include "video/glutil.hpp" #include #include #include