updated -nogl patch to match changes in trunk
[supertux.git] / contrib / supertux-nogl.diff
1 #
2 #  SuperTux -nogl patch
3 #  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
4 #
5 #  This program is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU General Public License
7 #  as published by the Free Software Foundation; either version 2
8 #  of the License, or (at your option) any later version.
9 #
10 #  This program is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU General Public License for more details.
14 #
15 #  You should have received a copy of the GNU General Public License
16 #  along with this program; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 #
19 # -----------------------------------------------------------------------------
20 #
21 #  This patch allows running the game on systems without OpenGL support. 
22 #
23 #  It modifies the video portion of the SuperTux engine to render all graphics
24 #  with SDL functions only. Many features are removed from the video engine,
25 #  so don't expect much.
26 #
27 #  Note that the patched sources will need an additional library, SDL_gfx, to 
28 #  compile.
29 #
30 #  Installing the patch should be pretty straightforward. Simply run the
31 #  following command prior to running autogen.sh and configure:
32 #
33 #  patch -p1 < contrib/supertux-nogl.diff
34 #
35 #  This patch works for revision 3321. It may break for later revisions.
36 #
37 # -----------------------------------------------------------------------------
38 diff -Naur supertux/INSTALL supertux-nogl/INSTALL
39 --- supertux/INSTALL    2006-03-03 21:49:07.000000000 +0100
40 +++ supertux-nogl/INSTALL       2006-04-07 04:13:00.000000000 +0200
41 @@ -1,7 +1,7 @@
42  - Install instructions for SuperTux -
43  http://supertux.berlios.de/
44  
45 -Last update: October 11, 2005 by Ondra Hosek
46 +Last update: March 4, 2006 by Christoph Sommer
47  
48  BINARIES
49  --------
50 @@ -34,17 +34,15 @@
51      Download: ftp://ftp.perforce.com/pub/jam
52      Homepage: http://www.perforce.com/jam/jam.html
53  
54 -* OpenGL headers and libraries
55 -    opengl libraries and headers are specific to your graphics card. Make sure
56 -    that you have hardware accelerated opengl drivers installed. Software
57 -    renderers like Mesa will make supertux unplayable slow.
58 -
59  * SDL 1.2.5 or later (1.2.8 is recommended on MacOS/X)
60      http://www.libsdl.org
61  
62  * SDL_image (any version)
63      http://www.libsdl.org/projects/SDL_image
64  
65 +* SDL_gfx (2.0.13 or later)
66 +    http://www.ferzkopp.net/Software/SDL_gfx-2.0/
67 +
68  * PhysicsFS (1.0.0, the development branch 1.1.x is buggy and does not work,
69               1.2.0 and later should work when it is released)
70      http://www.icculus.org/physfs
71 diff -Naur supertux/README supertux-nogl/README
72 --- supertux/README     2006-03-03 20:43:38.000000000 +0100
73 +++ supertux-nogl/README        2006-04-07 04:13:00.000000000 +0200
74 @@ -2,7 +2,7 @@
75  - An introduction for SuperTux -
76  http://supertux.berlios.de/
77  
78 -Last update: October 13, 2005
79 +Last update: March 4, 2006 by Christoph Sommer
80  
81  DESCRIPTION
82  -----------
83 @@ -75,10 +75,9 @@
84    Also, notice that SuperTux saves the options, so it's often enough to
85    specify them once.
86  
87 -  The game uses OpenGL to render the graphics. You will either need a CPU
88 -  with about 10 GHz or an accelerated video card with the vendor's drivers.
89 -  (On Linux, the team recommends using cards from NVidia with the proprietary
90 -  drivers, but ATI or another verndor should do.)
91 +  The game uses SDL to render the graphics. You will either need a CPU
92 +  with about 1 GHz or go get the original version of SuperTux which uses
93 +  OpenGL.
94  
95  
96  PLAYING THE GAME
97 diff -Naur supertux/configure.ac supertux-nogl/configure.ac
98 --- supertux/configure.ac       2006-03-03 20:43:38.000000000 +0100
99 +++ supertux-nogl/configure.ac  2006-04-07 04:13:00.000000000 +0200
100 @@ -11,7 +11,7 @@
101  
102  dnl Process this file with autoconf to produce a configure script.
103  AC_PREREQ([2.54])
104 -AC_INIT(supertux, 0.2-svn)
105 +AC_INIT(supertux, 0.2-nogl-svn)
106  AC_CONFIG_SRCDIR([src/main.cpp])
107  AC_CONFIG_AUX_DIR([mk/autoconf])
108  AC_CANONICAL_TARGET
109 @@ -112,6 +105,14 @@
110          [AC_MSG_ERROR([Please install SDLImage >= 1.2.1])],
111          [$SDL_CFLAGS], [$SDL_LIBS])
112  
113 +dnl FIXME: This is far from perfect
114 +NP_FINDLIB([SDLGFX], [SDL_gfx], [SDL_gfx >= 2.0.13],
115 +        NP_LANG_PROGRAM([#include <SDL_rotozoom.h>], [0;]),
116 +        [], [-lSDL_gfx],
117 +        [],
118 +        [AC_MSG_ERROR([Please install SDL_gfx >= 2.0.13])],
119 +        [$SDL_CFLAGS], [$SDL_LIBS])
120 +
121  NP_FINDLIB([PHYSFS], [physfs], [physfs >= 1.0.0],
122          NP_LANG_PROGRAM([
123  #include <stdio.h>
124 @@ -131,11 +132,6 @@
125           [AC_MSG_ERROR([Please intall OpenAL])],
126           [], [])
127  
128 -AX_CHECK_GL
129 -if test "$no_gl" = "yes"; then
130 -  AC_MSG_ERROR([Please install opengl libraries and headers])
131 -fi
132 -
133  dnl Checks for library functions.
134  AC_CHECK_FUNCS(mkdir strdup strstr)
135  
136 diff -Naur supertux/src/Jamfile supertux-nogl/src/Jamfile
137 --- supertux/src/Jamfile        2006-03-03 20:34:49.000000000 +0100
138 +++ supertux-nogl/src/Jamfile   2006-04-07 04:11:50.000000000 +0200
139 @@ -24,7 +24,7 @@
140  Application supertux : $(sources) $(wrapper_objects) ;
141  C++Flags supertux : -DAPPDATADIR='\"$(appdatadir)\"' ;
142  LinkWith supertux : squirrel ;
143 -ExternalLibs supertux : SDL SDLIMAGE GL OPENAL VORBIS VORBISFILE OGG ICONV PHYSFS BINRELOC ;
144 +ExternalLibs supertux : SDL SDLIMAGE SDLGFX OPENAL VORBIS VORBISFILE OGG ICONV PHYSFS BINRELOC ;
145  Help supertux : "Build the supertux executable" ;
146  IncludeDir supertux : squirrel/include ;
147  
148 diff -Naur supertux/src/main.cpp supertux-nogl/src/main.cpp
149 --- supertux/src/main.cpp       2006-04-07 03:32:14.000000000 +0200
150 +++ supertux-nogl/src/main.cpp  2006-04-07 04:11:50.000000000 +0200
151 @@ -35,7 +35,6 @@
152  #include <physfs.h>
153  #include <SDL.h>
154  #include <SDL_image.h>
155 -#include <GL/gl.h>
156  
157  #include "gameconfig.hpp"
158  #include "resources.hpp"
159 @@ -269,44 +265,6 @@
160        ;
161  }
162  
163 -static void check_gl_error()
164 -{
165 -  GLenum glerror = glGetError();
166 -  std::string errormsg;
167 -  
168 -  if(glerror != GL_NO_ERROR) {
169 -    switch(glerror) {
170 -      case GL_INVALID_ENUM:
171 -        errormsg = "Invalid enumeration value";
172 -        break;
173 -      case GL_INVALID_VALUE:
174 -        errormsg = "Numeric argzment out of range";
175 -        break;
176 -      case GL_INVALID_OPERATION:
177 -        errormsg = "Invalid operation";
178 -        break;
179 -      case GL_STACK_OVERFLOW:
180 -        errormsg = "stack overflow";
181 -        break;
182 -      case GL_STACK_UNDERFLOW:
183 -        errormsg = "stack underflow";
184 -        break;
185 -      case GL_OUT_OF_MEMORY:
186 -        errormsg = "out of memory";
187 -        break;
188 -      case GL_TABLE_TOO_LARGE:
189 -        errormsg = "table too large";
190 -        break;
191 -      default:
192 -        errormsg = "unknown error number";
193 -        break;
194 -    }
195 -    std::stringstream msg;
196 -    msg << "OpenGL Error: " << errormsg;
197 -    throw std::runtime_error(msg.str());
198 -  }
199 -}
200 -
201  void init_video()
202  {
203    if(texture_manager != NULL)
204 @@ -317,7 +275,7 @@
205    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
206    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
207    
208 -  int flags = SDL_OPENGL;
209 +  int flags = SDL_SWSURFACE;
210    if(config->use_fullscreen)
211      flags |= SDL_FULLSCREEN;
212    int width = config->screenwidth;
213 @@ -347,24 +305,6 @@
214    }
215  #endif
216  
217 -  // setup opengl state and transform
218 -  glDisable(GL_DEPTH_TEST);
219 -  glDisable(GL_CULL_FACE);
220 -  glEnable(GL_TEXTURE_2D);
221 -  glEnable(GL_BLEND);
222 -  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
223 -
224 -  glViewport(0, 0, screen->w, screen->h);
225 -  glMatrixMode(GL_PROJECTION);
226 -  glLoadIdentity();
227 -  // logical resolution here not real monitor resolution
228 -  glOrtho(0, 800, 600, 0, -1.0, 1.0);
229 -  glMatrixMode(GL_MODELVIEW);
230 -  glLoadIdentity();
231 -  glTranslatef(0, 0, 0);
232 -
233 -  check_gl_error();
234 -
235    if(texture_manager != NULL)
236      texture_manager->reload_textures();
237    else
238 diff -Naur supertux/src/video/drawing_context.cpp supertux-nogl/src/video/drawing_context.cpp
239 --- supertux/src/video/drawing_context.cpp      2006-03-31 04:18:01.000000000 +0200
240 +++ supertux-nogl/src/video/drawing_context.cpp 2006-04-07 04:11:49.000000000 +0200
241 @@ -22,7 +22,6 @@
242  #include <cassert>
243  #include <iostream>
244  #include <SDL_image.h>
245 -#include <GL/gl.h>
246  
247  #include "drawing_context.hpp"
248  #include "surface.hpp"
249 @@ -48,30 +47,20 @@
250  {
251    screen = SDL_GetVideoSurface();
252  
253 -  lightmap_width = screen->w / LIGHTMAP_DIV;
254 -  lightmap_height = screen->h / LIGHTMAP_DIV;
255 -  unsigned int width = next_po2(lightmap_width);
256 -  unsigned int height = next_po2(lightmap_height);
257 -
258 -  lightmap = new Texture(width, height, GL_RGB);
259 -
260 -  lightmap_uv_right = static_cast<float>(lightmap_width) / static_cast<float>(width);
261 -  lightmap_uv_bottom = static_cast<float>(lightmap_height) / static_cast<float>(height);
262 -  texture_manager->register_texture(lightmap);
263 -
264 +  target = NORMAL;
265    requests = &drawing_requests;
266  }
267  
268  DrawingContext::~DrawingContext()
269  {
270 -  texture_manager->remove_texture(lightmap);
271 -  delete lightmap;
272  }
273  
274  void
275  DrawingContext::draw_surface(const Surface* surface, const Vector& position,
276      int layer)
277  {
278 +  if(target != NORMAL) return;
279 +
280    assert(surface != 0);
281    
282    DrawingRequest request;
283 @@ -96,6 +85,8 @@
284  DrawingContext::draw_surface_part(const Surface* surface, const Vector& source,
285      const Vector& size, const Vector& dest, int layer)
286  {
287 +  if(target != NORMAL) return;
288 +
289    assert(surface != 0);
290  
291    DrawingRequest request;
292 @@ -135,6 +126,8 @@
293  DrawingContext::draw_text(const Font* font, const std::string& text,
294      const Vector& position, FontAlignment alignment, int layer)
295  {
296 +  if(target != NORMAL) return;
297 +
298    DrawingRequest request;
299  
300    request.type = TEXT;
301 @@ -156,6 +149,8 @@
302  DrawingContext::draw_center_text(const Font* font, const std::string& text,
303      const Vector& position, int layer)
304  {
305 +  if(target != NORMAL) return;
306 +
307    draw_text(font, text, Vector(position.x + SCREEN_WIDTH/2, position.y),
308        CENTER_ALLIGN, layer);
309  }
310 @@ -163,6 +158,8 @@
311  void
312  DrawingContext::draw_gradient(const Color& top, const Color& bottom, int layer)
313  {
314 +  if(target != NORMAL) return;
315 +
316    DrawingRequest request;
317  
318    request.type = GRADIENT;
319 @@ -184,6 +181,8 @@
320  DrawingContext::draw_filled_rect(const Vector& topleft, const Vector& size,
321                                   const Color& color, int layer)
322  {
323 +  if(target != NORMAL) return;
324 +
325    DrawingRequest request;
326  
327    request.type = FILLRECT;
328 @@ -217,23 +216,55 @@
329    delete surfacepartrequest;
330  }
331  
332 +namespace
333 +{
334 +  void fillrect(SDL_Surface* screen, float x, float y, float w, float h, int r, int g, int b, int a)
335 +  {
336 +    if(w < 0) {
337 +      x += w;
338 +      w = -w;
339 +    }
340 +    if(h < 0) {
341 +      y += h;
342 +      h = -h;
343 +    }
344 +
345 +    SDL_Rect src, rect;
346 +    SDL_Surface *temp = NULL;
347 +
348 +    rect.x = (int)x;
349 +    rect.y = (int)y;
350 +    rect.w = (int)w;
351 +    rect.h = (int)h;
352 +
353 +    if(a != 255) {
354 +      temp = SDL_CreateRGBSurface(screen->flags, rect.w, rect.h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
355 +
356 +      src.x = 0;
357 +      src.y = 0;
358 +      src.w = rect.w;
359 +      src.h = rect.h;
360 +
361 +      SDL_FillRect(temp, &src, SDL_MapRGB(screen->format, r, g, b));
362 +      SDL_SetAlpha(temp, SDL_SRCALPHA, a);
363 +      SDL_BlitSurface(temp,0,screen,&rect);
364 +      SDL_FreeSurface(temp);
365 +    } else {
366 +      SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b));
367 +    }
368 +  }
369 +}
370 +
371  void
372  DrawingContext::draw_gradient(DrawingRequest& request)
373  {
374    GradientRequest* gradientrequest = (GradientRequest*) request.request_data;
375    const Color& top = gradientrequest->top;
376    const Color& bottom = gradientrequest->bottom;
377 -  
378 -  glDisable(GL_TEXTURE_2D);
379 -  glBegin(GL_QUADS);
380 -  glColor4f(top.red, top.green, top.blue, top.alpha);
381 -  glVertex2f(0, 0);
382 -  glVertex2f(SCREEN_WIDTH, 0);
383 -  glColor4f(bottom.red, bottom.green, bottom.blue, bottom.alpha);
384 -  glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
385 -  glVertex2f(0, SCREEN_HEIGHT);
386 -  glEnd();
387 -  glEnable(GL_TEXTURE_2D);
388 +
389 +  int width = 800;
390 +  int height = 600;
391 +  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);
392  
393    delete gradientrequest;
394  }
395 @@ -259,17 +290,12 @@
396    float w = fillrectrequest->size.x;
397    float h = fillrectrequest->size.y;
398  
399 -  glDisable(GL_TEXTURE_2D);
400 -  glColor4f(fillrectrequest->color.red, fillrectrequest->color.green,
401 -            fillrectrequest->color.blue, fillrectrequest->color.alpha);
402
403 -  glBegin(GL_QUADS);
404 -  glVertex2f(x, y);
405 -  glVertex2f(x+w, y);
406 -  glVertex2f(x+w, y+h);
407 -  glVertex2f(x, y+h);
408 -  glEnd();
409 -  glEnable(GL_TEXTURE_2D);
410 +  int r = static_cast<int>(fillrectrequest->color.red);
411 +  int g = static_cast<int>(fillrectrequest->color.green);
412 +  int b = static_cast<int>(fillrectrequest->color.blue);
413 +  int a = static_cast<int>(fillrectrequest->color.alpha);
414 +
415 +  ::fillrect(screen, x, y, w, h, r, g, b, a);
416  
417    delete fillrectrequest;
418  }
419 @@ -284,66 +310,10 @@
420    transformstack.clear();
421    target_stack.clear();
422  
423 -  bool use_lightmap = lightmap_requests.size() != 0;
424 -  
425 -  // PART1: create lightmap
426 -  if(use_lightmap) {
427 -    glViewport(0, screen->h - lightmap_height, lightmap_width, lightmap_height);
428 -    glMatrixMode(GL_PROJECTION);
429 -    glLoadIdentity();               
430 -    glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
431 -    glMatrixMode(GL_MODELVIEW);
432 -    glLoadIdentity();
433 -
434 -    //glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
435 -    glClearColor(0, 0, 0, 1);
436 -    glClear(GL_COLOR_BUFFER_BIT);
437 -    handle_drawing_requests(lightmap_requests);
438 -    lightmap_requests.clear();
439 -  
440 -    glDisable(GL_BLEND);
441 -    glBindTexture(GL_TEXTURE_2D, lightmap->get_handle());
442 -    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, screen->h - lightmap_height, lightmap_width, lightmap_height);
443 -
444 -    glViewport(0, 0, screen->w, screen->h);
445 -    glMatrixMode(GL_PROJECTION);
446 -    glLoadIdentity();               
447 -    glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
448 -    glMatrixMode(GL_MODELVIEW);    
449 -    glLoadIdentity();
450 -    glEnable(GL_BLEND);
451 -  }
452 -
453 -  //glClear(GL_COLOR_BUFFER_BIT);
454    handle_drawing_requests(drawing_requests);
455    drawing_requests.clear();
456  
457 -  if(use_lightmap) {
458 -    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
459 -
460 -    glBindTexture(GL_TEXTURE_2D, lightmap->get_handle());
461 -    glBegin(GL_QUADS);
462 -
463 -    glTexCoord2f(0, lightmap_uv_bottom);
464 -    glVertex2f(0, 0);
465 -
466 -    glTexCoord2f(lightmap_uv_right, lightmap_uv_bottom);
467 -    glVertex2f(SCREEN_WIDTH, 0);
468 -
469 -    glTexCoord2f(lightmap_uv_right, 0);
470 -    glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
471 -
472 -    glTexCoord2f(0, 0);
473 -    glVertex2f(0, SCREEN_HEIGHT);
474 -    
475 -    glEnd();
476 -
477 -    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
478 -  }
479 -
480 -  assert_gl("drawing");
481 -
482 -  SDL_GL_SwapBuffers();
483 +  SDL_Flip(screen);
484  }
485  
486  void
487 @@ -432,9 +402,5 @@
488  DrawingContext::set_target(Target target)
489  {
490    this->target = target;
491 -  if(target == LIGHTMAP)
492 -    requests = &lightmap_requests;
493 -  else
494 -    requests = &drawing_requests;
495  }
496  
497 diff -Naur supertux/src/video/drawing_context.hpp supertux-nogl/src/video/drawing_context.hpp
498 --- supertux/src/video/drawing_context.hpp      2006-03-03 20:34:27.000000000 +0100
499 +++ supertux-nogl/src/video/drawing_context.hpp 2006-04-07 04:11:49.000000000 +0200
500 @@ -23,7 +23,6 @@
501  #include <string>
502  #include <stdint.h>
503  
504 -#include <GL/gl.h>
505  #include <SDL.h>
506  #include <stdint.h>
507  #include <memory>
508 @@ -33,8 +32,9 @@
509  #include "font.hpp"
510  #include "color.hpp"
511  
512 +#include "glutil.hpp"
513 +
514  class Surface;
515 -class Texture;
516  
517  // some constants for predefined layer values
518  enum {
519 @@ -202,16 +202,12 @@
520    void draw_filled_rect(DrawingRequest& request);
521    
522    DrawingRequests drawing_requests;
523 -  DrawingRequests lightmap_requests;
524  
525    DrawingRequests* requests;
526  
527    SDL_Surface* screen;
528    Target target;
529    std::vector<Target> target_stack;
530 -  Texture* lightmap;
531 -  int lightmap_width, lightmap_height;
532 -  float lightmap_uv_right, lightmap_uv_bottom;
533  };
534  
535  #endif
536 diff -Naur supertux/src/video/glutil.hpp supertux-nogl/src/video/glutil.hpp
537 --- supertux/src/video/glutil.hpp       2006-03-21 16:13:11.000000000 +0100
538 +++ supertux-nogl/src/video/glutil.hpp  2006-04-07 04:11:49.000000000 +0200
539 @@ -21,45 +21,14 @@
540  
541  #include <sstream>
542  #include <stdexcept>
543 -#include <GL/gl.h>
544  
545 -static inline void assert_gl(const char* message)
546 -{
547 -#ifdef DEBUG
548 -  GLenum error = glGetError();
549 -  if(error != GL_NO_ERROR) {
550 -    std::ostringstream msg;
551 -    msg << "OpenGLError while '" << message << "': ";
552 -    switch(error) {
553 -      case GL_INVALID_ENUM:
554 -        msg << "INVALID_ENUM: An unacceptable value is specified for an "
555 -               "enumerated argument.";
556 -        break;
557 -      case GL_INVALID_VALUE:
558 -        msg << "INVALID_VALUE: A numeric argument is out of range.";
559 -        break;
560 -      case GL_INVALID_OPERATION:
561 -        msg << "INVALID_OPERATION: The specified operation is not allowed "
562 -               "in the current state.";
563 -        break;
564 -      case GL_STACK_OVERFLOW:
565 -        msg << "STACK_OVERFLOW: This command would cause a stack overflow.";
566 -        break;
567 -      case GL_STACK_UNDERFLOW:
568 -        msg << "STACK_UNDERFLOW: This command would cause a stack underflow.";
569 -        break;
570 -      case GL_OUT_OF_MEMORY:
571 -        msg << "OUT_OF_MEMORY: There is not enough memory left to execute the "
572 -               "command.";
573 -        break;
574 -      default:
575 -        msg << "Unknown error (code " << error << ")";
576 -    }
577 -        
578 -    throw std::runtime_error(msg.str());
579 -  }
580 -#endif
581 -}
582 +#define GLenum int
583 +#define GLint int
584 +#define GL_SRC_ALPHA 0
585 +#define GL_ONE_MINUS_SRC_ALPHA 1
586 +#define GL_RGBA 2
587 +
588 +
589  
590  #endif
591  
592 diff -Naur supertux/src/video/screen.cpp supertux-nogl/src/video/screen.cpp
593 --- supertux/src/video/screen.cpp       2006-04-07 03:32:13.000000000 +0200
594 +++ supertux-nogl/src/video/screen.cpp  2006-04-07 04:11:49.000000000 +0200
595 @@ -38,61 +38,70 @@
596  
597  static const float LOOP_DELAY = 20.0;
598  
599 -void fillrect(float x, float y, float w, float h, const Color& col)
600 -{
601 -  if(w < 0) {
602 -    x += w;
603 -    w = -w;
604 -  }
605 -  if(h < 0) {
606 -    y += h;
607 -    h = -h;
608 -  }
609 -
610 -  glColor4f(col.red, col.green, col.blue, col.alpha);
611  
612 -  glDisable(GL_TEXTURE_2D);
613 -  glBegin(GL_POLYGON);
614 -  glVertex2f(x, y);
615 -  glVertex2f(x+w, y);
616 -  glVertex2f(x+w, y+h);
617 -  glVertex2f(x, y+h);
618 -  glEnd();
619 -  glEnable(GL_TEXTURE_2D);
620 -
621 -  glColor4f(0, 0, 0, 1);
622 +void fillrect(float x, float y, float w, float h, int r, int g, int b, int a)
623 +  {
624 +    SDL_Surface* screen = SDL_GetVideoSurface();
625 +
626 +    if(w < 0) {
627 +      x += w;
628 +      w = -w;
629 +    }
630 +    if(h < 0) {
631 +      y += h;
632 +      h = -h;
633 +    }
634 +
635 +    SDL_Rect src, rect;
636 +    SDL_Surface *temp = NULL;
637 +
638 +    rect.x = (int)x;
639 +    rect.y = (int)y;
640 +    rect.w = (int)w;
641 +    rect.h = (int)h;
642 +
643 +    if(a != 255) {
644 +      temp = SDL_CreateRGBSurface(screen->flags, rect.w, rect.h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
645 +
646 +      src.x = 0;
647 +      src.y = 0;
648 +      src.w = rect.w;
649 +      src.h = rect.h;
650 +
651 +      SDL_FillRect(temp, &src, SDL_MapRGB(screen->format, r, g, b));
652 +      SDL_SetAlpha(temp, SDL_SRCALPHA, a);
653 +      SDL_BlitSurface(temp,0,screen,&rect);
654 +      SDL_FreeSurface(temp);
655 +    }
656 +    else
657 +    SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b));
658  }
659  
660  void fadeout(float fade_time)
661  {
662 -  float alpha_inc  = LOOP_DELAY / fade_time;
663 -  Color c(0, 0, 0, alpha_inc);
664 -  float alpha = 1.0;
665 +  float alpha_inc  = 256 / (fade_time / LOOP_DELAY);
666 +  float alpha = 256;
667  
668 -  while(alpha >= 0) {
669 +  while(alpha > 0) {
670      alpha -= alpha_inc;
671 -    fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, c);
672 -    // left side
673 +    fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0,0,0, (int)alpha_inc);  // left side
674      
675 -    SDL_GL_SwapBuffers();
676 +    SDL_Flip(SDL_GetVideoSurface());
677      sound_manager->update();
678      
679      SDL_Delay(int(LOOP_DELAY));
680 -    alpha -= alpha_inc; 
681    }
682 -
683 -  fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, Color());
684 +  fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 255);
685  }
686  
687  void shrink_fade(const Vector& point, float fade_time)
688  {
689 -  float left_inc  = point.x / (fade_time / LOOP_DELAY);
690 -  float right_inc = (SCREEN_WIDTH - point.x) / (fade_time / LOOP_DELAY);
691 -  float up_inc    = point.y / (fade_time / LOOP_DELAY);
692 -  float down_inc  = (SCREEN_HEIGHT - point.y) / (fade_time / LOOP_DELAY);
693 +  float left_inc  = point.x / ((float)fade_time / LOOP_DELAY);
694 +  float right_inc = (SCREEN_WIDTH - point.x) / ((float)fade_time / LOOP_DELAY);
695 +  float up_inc    = point.y / ((float)fade_time / LOOP_DELAY);
696 +  float down_inc  = (SCREEN_HEIGHT - point.y) / ((float)fade_time / LOOP_DELAY);
697                                                                                  
698    float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0;
699 -  Color c;
700                                                                                  
701    while(left_cor < point.x && right_cor < SCREEN_WIDTH - point.x &&
702        up_cor < point.y && down_cor < SCREEN_HEIGHT - point.y) {
703 @@ -101,15 +110,14 @@
704      up_cor    += up_inc;
705      down_cor  += down_inc;
706                                                                                  
707 -    fillrect(0, 0, left_cor, SCREEN_HEIGHT, c);  // left side
708 -    fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, c);  // right side
709 -    fillrect(0, 0, SCREEN_WIDTH, up_cor, c);  // up side
710 -    fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, c);  // down side
711 +    fillrect(0, 0, left_cor, SCREEN_HEIGHT, 0,0,0, 255);  // left side
712 +    fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, 0,0,0, 255);  // right side
713 +    fillrect(0, 0, SCREEN_WIDTH, up_cor, 0,0,0, 255);  // up side
714 +    fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, 0,0,0, 255);  // down side
715  
716 -    SDL_GL_SwapBuffers();
717 +    SDL_Flip(SDL_GetVideoSurface());
718    
719      sound_manager->update();
720      SDL_Delay(int(LOOP_DELAY));
721    }
722  }
723 -
724 diff -Naur supertux/src/video/screen.hpp supertux-nogl/src/video/screen.hpp
725 --- supertux/src/video/screen.hpp       2006-04-07 03:32:13.000000000 +0200
726 +++ supertux-nogl/src/video/screen.hpp  2006-04-07 04:11:49.000000000 +0200
727 @@ -20,7 +20,6 @@
728  #define SUPERTUX_SCREEN_H
729  
730  #include <SDL.h>
731 -#include <GL/gl.h>
732  #include <iostream>
733  
734  #include <vector>
735 diff -Naur supertux/src/video/surface.cpp supertux-nogl/src/video/surface.cpp
736 --- supertux/src/video/surface.cpp      2006-03-25 01:16:31.000000000 +0100
737 +++ supertux-nogl/src/video/surface.cpp 2006-04-07 04:11:49.000000000 +0200
738 @@ -28,6 +29,7 @@
739  
740  #include <SDL.h>
741  #include <SDL_image.h>
742 +#include <SDL_rotozoom.h>
743  
744  #include "gameconfig.hpp"
745  #include "physfs/physfs_sdl.hpp"
746 @@ -40,13 +42,13 @@
747  {
748    texture = texture_manager->get(file);
749    texture->ref();
750 -  uv_left = 0;
751 -  uv_top = 0;
752 -  uv_right = texture->get_uv_right();
753 -  uv_bottom = texture->get_uv_bottom();
754  
755 -  width = texture->get_image_width();
756 -  height = texture->get_image_height();
757 +  offsetx = 0;
758 +  offsety = 0;
759 +  width = static_cast<int>(texture->get_image_width());
760 +  height = static_cast<int>(texture->get_image_height());
761 +
762 +  flipx = false;
763  }
764  
765  Surface::Surface(const std::string& file, int x, int y, int w, int h)
766 @@ -54,15 +56,12 @@
767    texture = texture_manager->get(file);
768    texture->ref();
769  
770 -  float tex_w = static_cast<float> (texture->get_width());
771 -  float tex_h = static_cast<float> (texture->get_height());
772 -  uv_left = static_cast<float>(x) / tex_w;
773 -  uv_top = static_cast<float>(y) / tex_h;
774 -  uv_right = static_cast<float>(x+w) / tex_w;
775 -  uv_bottom = static_cast<float>(y+h) / tex_h;
776 -
777 +  offsetx = x;
778 +  offsety = y;
779    width = w;
780    height = h;
781 +
782 +  flipx = false;
783  }
784  
785  Surface::Surface(const Surface& other)
786 @@ -70,12 +69,12 @@
787    texture = other.texture;
788    texture->ref();
789  
790 -  uv_left = other.uv_left;
791 -  uv_top = other.uv_top;
792 -  uv_right = other.uv_right;
793 -  uv_bottom = other.uv_bottom;
794 +  offsetx = other.offsetx;
795 +  offsety = other.offsety;
796    width = other.width;
797    height = other.height;
798 +
799 +  flipx = other.flipx;
800  }
801  
802  const Surface&
803 @@ -85,81 +84,95 @@
804    texture->unref();
805    texture = other.texture;
806  
807 -  uv_left = other.uv_left;
808 -  uv_top = other.uv_top;
809 -  uv_right = other.uv_right;
810 -  uv_bottom = other.uv_bottom;
811 +  offsetx = other.offsetx;
812 +  offsety = other.offsety;
813    width = other.width;
814    height = other.height;
815  
816 +  flipx = other.flipx;
817 +
818    return *this;
819  }
820  
821  Surface::~Surface()
822  {
823    texture->unref();
824 +
825 +  for (std::list<TransformedSurface*>::iterator i = transformedSurfaces.begin(); i != transformedSurfaces.end(); i++) {
826 +    SDL_FreeSurface((*i)->surface);
827 +    delete (*i);
828 +  }
829  }
830  
831  void
832  Surface::hflip()
833  {
834 -  std::swap(uv_left, uv_right);
835 -}
836 -
837 -static inline void intern_draw(float left, float top, float right, float bottom,                               float uv_left, float uv_top,
838 -                               float uv_right, float uv_bottom,
839 -                               DrawingEffect effect)
840 -{
841 -  if(effect & HORIZONTAL_FLIP)
842 -    std::swap(uv_left, uv_right);
843 -  if(effect & VERTICAL_FLIP) {
844 -    std::swap(uv_top, uv_bottom);
845 -  }
846 -  
847 -  glBegin(GL_QUADS);
848 -  glTexCoord2f(uv_left, uv_top);
849 -  glVertex2f(left, top);
850 -  
851 -  glTexCoord2f(uv_right, uv_top);
852 -  glVertex2f(right, top);
853 -
854 -  glTexCoord2f(uv_right, uv_bottom);
855 -  glVertex2f(right, bottom);
856 -
857 -  glTexCoord2f(uv_left, uv_bottom);
858 -  glVertex2f(left, bottom);
859 -  glEnd();
860 +  flipx = !flipx;
861  }
862  
863  void
864  Surface::draw(float x, float y, float alpha, DrawingEffect effect) const
865  {
866 -  glColor4f(1.0f, 1.0f, 1.0f, alpha);
867 -  glBindTexture(GL_TEXTURE_2D, texture->get_handle());
868 -
869 -  intern_draw(x, y,
870 -              x + width, y + height,
871 -              uv_left, uv_top, uv_right, uv_bottom, effect);
872 +  draw_part(0, 0, x, y, width, height, alpha, effect);
873  }
874  
875  void
876  Surface::draw_part(float src_x, float src_y, float dst_x, float dst_y,
877 -                   float width, float height, float alpha,
878 +                   float width, float height, float,
879                     DrawingEffect effect) const
880  {
881 -  float uv_width = uv_right - uv_left;
882 -  float uv_height = uv_bottom - uv_top;
883 -  
884 -  float uv_left = this->uv_left + (uv_width * src_x) / this->width;
885 -  float uv_top = this->uv_top + (uv_height * src_y) / this->height;
886 -  float uv_right = this->uv_left + (uv_width * (src_x + width)) / this->width;
887 -  float uv_bottom = this->uv_top + (uv_height * (src_y + height)) / this->height;
888 -  
889 -  glColor4f(1.0f, 1.0f, 1.0f, alpha);
890 -  glBindTexture(GL_TEXTURE_2D, texture->get_handle());  
891 -  
892 -  intern_draw(dst_x, dst_y,
893 -              dst_x + width, dst_y + height,
894 -              uv_left, uv_top, uv_right, uv_bottom, effect);
895 +  //FIXME: support parameter "alpha"
896 +  SDL_Surface* surface = texture->getSurface();
897 +
898 +  // get and check SDL_Surface
899 +  if (surface == 0) {
900 +    std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl;
901 +    return;
902 +  }    
903 +
904 +  SDL_Surface* transformedSurface = surface;
905 +
906 +  if (flipx) effect = HORIZONTAL_FLIP;
907 +
908 +  if (effect != NO_EFFECT) {
909 +    transformedSurface = 0;
910 +
911 +    // check if we have this effect buffered
912 +    for (std::list<TransformedSurface*>::const_iterator i = transformedSurfaces.begin(); i != transformedSurfaces.end(); i++) {
913 +      if ((*i)->effect == effect) transformedSurface = (*i)->surface;
914 +    }
915 +
916 +    // if not: transform and buffer
917 +    if (!transformedSurface) {
918 +      if (effect == HORIZONTAL_FLIP) transformedSurface = zoomSurface(surface, -1, 1, 0);
919 +      if (effect == VERTICAL_FLIP) transformedSurface = zoomSurface(surface, 1, -1, 0);
920 +      if (transformedSurface == 0) {
921 +        std::cerr << "Warning: No known transformation applies to surface, skipped draw" << std::endl;
922 +        return;
923 +      }        
924 +      TransformedSurface* su = new TransformedSurface();
925 +      su->surface = transformedSurface;
926 +      su->effect = effect;
927 +
928 +      transformedSurfaces.push_front(su);
929 +    }
930 +  }
931 +
932 +  int ox = offsetx; if (effect == HORIZONTAL_FLIP) ox = static_cast<int>(surface->w) - (ox+static_cast<int>(width));
933 +  int oy = offsety; if (effect == VERTICAL_FLIP) oy = static_cast<int>(surface->h) - (oy+static_cast<int>(height));
934 +  // draw surface to screen
935 +  SDL_Surface* screen = SDL_GetVideoSurface();
936 +
937 +  SDL_Rect srcRect;
938 +  srcRect.x = static_cast<int>(ox+src_x);
939 +  srcRect.y = static_cast<int>(oy+src_y);
940 +  srcRect.w = static_cast<int>(width);
941 +  srcRect.h = static_cast<int>(height);
942 +
943 +  SDL_Rect dstRect;
944 +  dstRect.x = static_cast<int>(dst_x);
945 +  dstRect.y = static_cast<int>(dst_y);
946 +
947 +  SDL_BlitSurface(transformedSurface, &srcRect, screen, &dstRect);
948  }
949  
950 diff -Naur supertux/src/video/surface.hpp supertux-nogl/src/video/surface.hpp
951 --- supertux/src/video/surface.hpp      2006-03-03 20:34:27.000000000 +0100
952 +++ supertux-nogl/src/video/surface.hpp 2006-04-07 04:11:49.000000000 +0200
953 @@ -20,7 +20,9 @@
954  #ifndef __SURFACE_HPP__
955  #define __SURFACE_HPP__
956  
957 +#include <SDL_image.h>
958  #include <string>
959 +#include <list>
960  
961  class ImageTexture;
962  
963 @@ -35,6 +37,15 @@
964  };
965  
966  /**
967 + * Helper class to buffer a pre-transformed SDL_Surface
968 + */
969 +class TransformedSurface {
970 +    public:
971 +       SDL_Surface* surface;
972 +       DrawingEffect effect;
973 +};
974 +
975 +/**
976   * A rectangular image.
977   * The class basically holds a reference to a texture with additional UV
978   * coordinates that specify a rectangular area on this texture
979 @@ -46,18 +57,23 @@
980    friend class Font;
981    ImageTexture* texture;
982  
983 -  float uv_left;
984 -  float uv_top;
985 -  float uv_right;
986 -  float uv_bottom;
987 +  bool flipx;
988  
989 +  /** draw the surface on the screen, applying a ::DrawingEffect on-the-fly. Transformed Surfaces will be cached in ::transformedSurfaces */
990    void draw(float x, float y, float alpha, DrawingEffect effect) const;
991 +
992 +  /** draw the surface on the screen, applying a ::DrawingEffect on-the-fly. Transformed Surfaces will be cached in ::transformedSurfaces */
993    void draw_part(float src_x, float src_y, float dst_x, float dst_y,
994                   float width, float height,
995                   float alpha, DrawingEffect effect) const;
996  
997 -  float width;
998 -  float height;
999 +  int offsetx; /**< Region in ::surface to be used for blitting */
1000 +  int offsety; /**< Region in ::surface to be used for blitting */
1001 +  int width;   /**< Region in ::surface to be used for blitting */
1002 +  int height;  /**< Region in ::surface to be used for blitting */
1003 +
1004 +  mutable std::list<TransformedSurface*> transformedSurfaces; /**< Cache for pre-transformed surfaces */
1005 +
1006  public:
1007    Surface(const std::string& file);
1008    Surface(const std::string& file, int x, int y, int w, int h);
1009 diff -Naur supertux/src/video/texture.cpp supertux-nogl/src/video/texture.cpp
1010 --- supertux/src/video/texture.cpp      2006-03-03 20:34:27.000000000 +0100
1011 +++ supertux-nogl/src/video/texture.cpp 2006-04-07 04:11:49.000000000 +0200
1012 @@ -20,7 +20,6 @@
1013  
1014  #include "texture.hpp"
1015  
1016 -#include <GL/gl.h>
1017  #include <assert.h>
1018  #include "glutil.hpp"
1019  
1020 @@ -29,81 +28,37 @@
1021    return (v & (v-1)) == 0;
1022  }
1023  
1024 -Texture::Texture(unsigned int w, unsigned int h, GLenum glformat)
1025 +Texture::Texture(unsigned int w, unsigned int h, GLenum)
1026  {
1027    assert(is_power_of_2(w));
1028    assert(is_power_of_2(h));
1029  
1030    this->width = w;
1031    this->height = h;
1032 -  
1033 -  assert_gl("before creating texture");
1034 -  glGenTextures(1, &handle);
1035 -  
1036 -  try {
1037 -    glBindTexture(GL_TEXTURE_2D, handle);
1038 -
1039 -    glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, GL_RGBA,
1040 -                 GL_UNSIGNED_BYTE, 0);
1041 -
1042 -    set_texture_params();
1043 -  } catch(...) {
1044 -    glDeleteTextures(1, &handle);
1045 -    throw;
1046 -  }
1047 +
1048 +  surface = 0;
1049  }
1050  
1051 -Texture::Texture(SDL_Surface* image, GLenum glformat)
1052 +Texture::Texture(SDL_Surface* image, GLenum)
1053  {
1054    const SDL_PixelFormat* format = image->format;
1055    if(!is_power_of_2(image->w) || !is_power_of_2(image->h))
1056      throw std::runtime_error("image has no power of 2 size");
1057    if(format->BitsPerPixel != 24 && format->BitsPerPixel != 32)
1058      throw std::runtime_error("image has no 24 or 32 bit color depth");
1059 -  
1060 +
1061    this->width = image->w;
1062    this->height = image->h;
1063  
1064 -  assert_gl("before creating texture");
1065 -  glGenTextures(1, &handle);
1066 -  
1067 -  try {
1068 -    GLenum sdl_format;
1069 -    if(format->BytesPerPixel == 3)
1070 -      sdl_format = GL_RGB;
1071 -    else if(format->BytesPerPixel == 4)
1072 -      sdl_format = GL_RGBA;
1073 -    else
1074 -      assert(false);
1075 -
1076 -    glBindTexture(GL_TEXTURE_2D, handle);
1077 -    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1078 -    glPixelStorei(GL_UNPACK_ROW_LENGTH, image->pitch/format->BytesPerPixel);
1079 -    glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, sdl_format,
1080 -            GL_UNSIGNED_BYTE, image->pixels);
1081 -
1082 -    assert_gl("creating texture");
1083 -
1084 -    set_texture_params();    
1085 -  } catch(...) {
1086 -    glDeleteTextures(1, &handle);
1087 -    throw;
1088 -  }
1089 +  surface = SDL_DisplayFormatAlpha(image);
1090  }
1091  
1092  Texture::~Texture()
1093  {
1094 -  glDeleteTextures(1, &handle);
1095  }
1096  
1097  void
1098  Texture::set_texture_params()
1099  {
1100 -  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1101 -  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1102 -  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1103 -  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1104 -
1105 -  assert_gl("set texture params");
1106  }
1107  
1108 diff -Naur supertux/src/video/texture.hpp supertux-nogl/src/video/texture.hpp
1109 --- supertux/src/video/texture.hpp      2006-03-03 20:34:27.000000000 +0100
1110 +++ supertux-nogl/src/video/texture.hpp 2006-04-07 04:11:49.000000000 +0200
1111 @@ -20,7 +20,7 @@
1112  #define __TEXTURE_HPP__
1113  
1114  #include <SDL.h>
1115 -#include <GL/gl.h>
1116 +#include "glutil.hpp"
1117  
1118  /**
1119   * This class is a wrapper around a texture handle. It stores the texture width
1120 @@ -30,8 +30,9 @@
1121  class Texture
1122  {
1123  protected:
1124 +  SDL_Surface* surface; /**< non-GL branch stores optimized surface */
1125 +
1126    friend class TextureManager;
1127 -  GLuint handle;
1128    unsigned int width;
1129    unsigned int height;
1130  
1131 @@ -40,11 +41,6 @@
1132    Texture(SDL_Surface* surface, GLenum glformat);
1133    virtual ~Texture();
1134    
1135 -  GLuint get_handle() const
1136 -  {
1137 -    return handle;
1138 -  }
1139 -
1140    unsigned int get_width() const
1141    {
1142      return width;
1143 @@ -55,6 +51,14 @@
1144      return height;
1145    }
1146  
1147 +  SDL_Surface* getSurface() {
1148 +    return surface;
1149 +  }
1150 +
1151 +  void setSurface(SDL_Surface* surface) {
1152 +    this->surface = surface;
1153 +  }
1154 +
1155  private:
1156    void set_texture_params();
1157  };
1158 diff -Naur supertux/src/video/texture_manager.cpp supertux-nogl/src/video/texture_manager.cpp
1159 --- supertux/src/video/texture_manager.cpp      2006-04-07 03:32:13.000000000 +0200
1160 +++ supertux-nogl/src/video/texture_manager.cpp 2006-04-07 04:11:49.000000000 +0200
1161 @@ -5,8 +5,6 @@
1162  #include <assert.h>
1163  #include <SDL.h>
1164  #include <SDL_image.h>
1165 -#include <GL/gl.h>
1166 -#include <GL/glext.h>
1167  #include <iostream>
1168  #include <sstream>
1169  #include <stdexcept>
1170 @@ -126,12 +124,6 @@
1171  void
1172  TextureManager::save_textures()
1173  {
1174 -  glPixelStorei(GL_PACK_ROW_LENGTH, 0);
1175 -  glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
1176 -  glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
1177 -  glPixelStorei(GL_PACK_SKIP_ROWS, 0);
1178 -  glPixelStorei(GL_PACK_SKIP_IMAGES, 0);
1179 -  glPixelStorei(GL_PACK_ALIGNMENT, 1);
1180    for(Textures::iterator i = textures.begin(); i != textures.end(); ++i) {
1181      save_texture(*i);
1182    }
1183 @@ -146,75 +138,16 @@
1184  {
1185    SavedTexture saved_texture;
1186    saved_texture.texture = texture;
1187 -  glBindTexture(GL_TEXTURE_2D, texture->get_handle());
1188 -  glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,
1189 -                           &saved_texture.width);
1190 -  glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT,
1191 -                           &saved_texture.height);
1192 -  glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BORDER,
1193 -                           &saved_texture.border);
1194 -  glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
1195 -                      &saved_texture.min_filter);
1196 -  glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
1197 -                      &saved_texture.mag_filter);
1198 -  glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
1199 -                      &saved_texture.wrap_s);
1200 -  glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
1201 -                      &saved_texture.wrap_t);
1202  
1203    size_t pixelssize = saved_texture.width * saved_texture.height * 4;
1204    saved_texture.pixels = new char[pixelssize];
1205 -  
1206 -  glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1207 -                saved_texture.pixels);
1208  
1209    saved_textures.push_back(saved_texture);
1210 -
1211 -  glDeleteTextures(1, &(texture->handle));
1212 -  texture->handle = 0;
1213 -
1214 -  assert_gl("retrieving texture for save");
1215  }
1216  
1217  void
1218  TextureManager::reload_textures()
1219  {
1220 -  glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
1221 -  glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
1222 -  glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
1223 -  glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
1224 -  glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
1225 -  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1226 -  
1227 -  for(std::vector<SavedTexture>::iterator i = saved_textures.begin();
1228 -      i != saved_textures.end(); ++i) {
1229 -    SavedTexture& saved_texture = *i;
1230 -    
1231 -    GLuint handle;
1232 -    glGenTextures(1, &handle);
1233 -    assert_gl("creating texture handle");
1234 -
1235 -    glBindTexture(GL_TEXTURE_2D, handle);
1236 -    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
1237 -                 saved_texture.width, saved_texture.height,
1238 -                 saved_texture.border, GL_RGBA,
1239 -                 GL_UNSIGNED_BYTE, saved_texture.pixels);
1240 -    delete[] saved_texture.pixels;
1241 -    assert_gl("uploading texture pixel data");
1242 -
1243 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
1244 -                    saved_texture.min_filter);
1245 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
1246 -                    saved_texture.mag_filter);
1247 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
1248 -                    saved_texture.wrap_s);
1249 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
1250 -                    saved_texture.wrap_t);
1251 -
1252 -    assert_gl("setting texture_params");
1253 -    saved_texture.texture->handle = handle;
1254 -  }
1255 -
1256    saved_textures.clear();
1257  }
1258  
1259 diff -Naur supertux/src/video/texture_manager.hpp supertux-nogl/src/video/texture_manager.hpp
1260 --- supertux/src/video/texture_manager.hpp      2006-03-03 20:34:27.000000000 +0100
1261 +++ supertux-nogl/src/video/texture_manager.hpp 2006-04-07 04:11:49.000000000 +0200
1262 @@ -1,7 +1,7 @@
1263  #ifndef __IMAGE_TEXTURE_MANAGER_HPP__
1264  #define __IMAGE_TEXTURE_MANAGER_HPP__
1265  
1266 -#include <GL/gl.h>
1267 +#include "video/glutil.hpp"
1268  #include <string>
1269  #include <vector>
1270  #include <map>