cleanups
authorTobias Gläßer <tobi.web@gmx.de>
Thu, 22 Jan 2004 21:57:57 +0000 (21:57 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Thu, 22 Jan 2004 21:57:57 +0000 (21:57 +0000)
SVN-Revision: 100

src/badguy.c
src/collision.c
src/intro.c
src/level.c
src/player.c
src/screen.c
src/screen.h
src/setup.c
src/texture.c
src/texture.h

index 5c9448e..07b2ba2 100644 (file)
@@ -495,7 +495,7 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object)
       break;
     case CO_BADGUY:
       pbad_c = p_c_object;
-      if (pbad->mode != KICK)
+      if (pbad->mode != FLAT)
         pbad->dir = !pbad->dir;
       else
         {
@@ -525,7 +525,7 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object)
         }
       else if (pbad->kind == BAD_LAPTOP)
         {
-          if (pbad->mode != FLAT)
+          if (pbad->mode != KICK)
             {
               /* Flatten! */
 
index 673d05d..6e2a393 100644 (file)
@@ -84,7 +84,8 @@ void collision_handler()
                     {
                    /* We have detected a collision and now call the collision functions of the collided objects. */
                      badguy_collision(&bad_guys[j], &bad_guys[i], CO_BADGUY);
-                    }
+                     badguy_collision(&bad_guys[i], &bad_guys[j], CO_BADGUY);                    
+                   }
                 }
             }
         }
index 2e106ac..f5ddc35 100644 (file)
@@ -55,7 +55,6 @@ int intro(void)
   
   
   /* Load sprite images: */
-
   texture_load(&bkgd, DATA_PREFIX "/images/intro/intro.png", IGNORE_ALPHA);
   texture_load(&gown_sit, DATA_PREFIX "/images/intro/gown-sit.png", USE_ALPHA);
   texture_load(&gown_lookup, DATA_PREFIX "/images/intro/gown-lookup.png", USE_ALPHA);
index f24012d..ccc3cc5 100644 (file)
@@ -174,8 +174,8 @@ void level_change(st_level* plevel, float x, float y, unsigned char c)
 {
   int xx, yy;
 
-  yy = (y / 32);
-  xx = (x / 32);
+  yy = ((int)y / 32);
+  xx = ((int)x / 32);
 
   if (yy >= 0 && yy < 15 && xx >= 0 && xx <= plevel->width)
     plevel->tiles[yy][xx] = c;
index a4665ba..4e1252b 100644 (file)
@@ -270,7 +270,7 @@ void player_action(player_type* pplayer)
                             }
 
                           if (distro_counter <= 0)
-                            level_change(&current_level,pplayer->base.x, pplayer->base.y, 'a');
+                            level_change(&current_level,pplayer->base.x,pplayer->base.y, 'a');
 
                           play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
                           score = score + SCORE_DISTRO;
index bd83792..b78058a 100644 (file)
@@ -46,12 +46,14 @@ void load_and_display_image(char * file)
 
 void clearscreen(float r, float g, float b)
 {
+#ifndef NOOPENGL
   if(use_gl)
   {
   glClearColor(r/256, g/256, b/256, 1.0);
   glClear(GL_COLOR_BUFFER_BIT);
   }
   else
+#endif
   SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b));
  
 }
@@ -105,158 +107,12 @@ if(!faccessible(st_dir,
   return(surf);
 }
 
-void create_gl_texture(SDL_Surface * surf, GLint * tex)
-{
-SDL_Surface *conv;
-conv = SDL_CreateRGBSurface(SDL_SWSURFACE , surf->w, surf->h, 32,
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-            0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
-#else
-            0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
-#endif
-    SDL_BlitSurface(surf, 0, conv, 0);
-                    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    
-  glGenTextures(1, &*tex);
-
-    glBindTexture(GL_TEXTURE_RECTANGLE_NV , *tex);
-             glEnable(GL_TEXTURE_RECTANGLE_NV);
-    glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glPixelStorei(GL_UNPACK_ROW_LENGTH, conv->pitch / conv->format->BytesPerPixel);
-    glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 3, conv->w, conv->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, conv->pixels);
-    //glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, conv->w, conv->h);
-    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-    SDL_FreeSurface(conv);
-}
-
-/* --- DRAW AN IMAGE ONTO THE SCREEN --- */
-/*
-void drawimage(SDL_Surface * surf, float x, float y, int update)
-{
-if(use_gl)
-{
-GLint gl_tex;
-create_gl_texture(surf,&gl_tex);
-    glColor4ub(255, 255, 255,255);
-glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-glEnable (GL_BLEND);
-    glBindTexture(GL_TEXTURE_RECTANGLE_NV, gl_tex);
-
-    glBegin(GL_QUADS);
-        glTexCoord2f(0, 0);    glVertex2f(x, y);
-        glTexCoord2f((float)surf->w, 0);    glVertex2f((float)surf->w+x, y);
-        glTexCoord2f((float)surf->w, (float)surf->h);    glVertex2f((float)surf->w+x, (float)surf->h+y);
-        glTexCoord2f(0, (float)surf->h);    glVertex2f(x, (float)surf->h+y);
-    glEnd();
- glDeleteTextures(1, &gl_tex);
- }
-else
-{
-  SDL_Rect dest;
-  
-  dest.x = x;
-  dest.y = y;
-  dest.w = surf->w;
-  dest.h = surf->h;
-  
-  SDL_BlitSurface(surf, NULL, screen, &dest);
-  
-  if (update == UPDATE)
-    SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
-}
-}
-*/
-/*
-drawbgimage(SDL_Surface * surf, int update)
-{
-if(use_gl)
-{
-GLint gl_tex;
-create_gl_texture(surf,&gl_tex);
-    //glColor3ub(255, 255, 255);
-
-    glEnable(GL_TEXTURE_RECTANGLE_NV);
-    glBindTexture(GL_TEXTURE_RECTANGLE_NV, gl_tex);
-
-    glBegin(GL_QUADS);
-        glTexCoord2f(0, 0);    glVertex2f(0, 0);
-        glTexCoord2f((float)surf->w, 0);    glVertex2f(screen->w, 0);
-        glTexCoord2f((float)surf->w, (float)surf->h);    glVertex2f(screen->w, screen->h);
-        glTexCoord2f(0, (float)surf->h); glVertex2f(0, screen->h);
-    glEnd();
- glDeleteTextures(1, &gl_tex);
-}
-else
-{
-  SDL_Rect dest;
-  
-  dest.x = 0;
-  dest.y = 0;
-  dest.w = screen->w;
-  dest.h = screen->h;
-  
-  SDL_BlitSurface(surf, NULL, screen, &dest);
-  
-  if (update == UPDATE)
-    SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
-}
-}
-*/
 void update_rect(SDL_Surface *scr, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
 {
 if(!use_gl)
 SDL_UpdateRect(scr, x, y, w, h);
 }
 
-
-/* --- DRAW PART OF AN IMAGE ONTO THE SCREEN --- */
-/*
-void drawpart(SDL_Surface * surf, float x, float y, float w, float h, int update)
-{
-if(use_gl)
-{
-GLint gl_tex;
-create_gl_texture(surf,&gl_tex);
-    glColor3ub(255, 255, 255);
-
-    glEnable(GL_TEXTURE_RECTANGLE_NV);
-    glBindTexture(GL_TEXTURE_RECTANGLE_NV, gl_tex);
-
-    glBegin(GL_QUADS);
-        glTexCoord2f(x, y);    glVertex2f(x, y);
-        glTexCoord2f(x+w, y);    glVertex2f(w+x, y);
-        glTexCoord2f(x+w, y+h);    glVertex2f(w+x, h+y);
-        glTexCoord2f(x, y+h);     glVertex2f(x, h+y);
-    glEnd();
- glDeleteTextures(1, &gl_tex);
- }
-else
-{
-  SDL_Rect src, dest;
-  
-  src.x = x;
-  src.y = y;
-  src.w = w;
-  src.h = h;
-
-  dest.x = x;
-  dest.y = y;
-  dest.w = w;
-  dest.h = h;
-  
-  
-  SDL_BlitSurface(surf, &src, screen, &dest);
-  
-  if (update == UPDATE)
-    update_rect(screen, dest.x, dest.y, dest.w, dest.h);
-    }
-}
-*/
-/* --- DRAW TEXT ONTO THE SCREEN --- */
-
 void drawtext(char * text, int x, int y, SDL_Surface * surf, int update, int shadowsize)
 {
        /* i - helps to keep tracking of the all string length
index fc13c7b..0a30328 100644 (file)
 */
 
 #include <SDL.h>
+#ifndef NOOPENGL
 #include <SDL_opengl.h>
 
-#define NO_UPDATE 0
-#define UPDATE 1
-#define USE_ALPHA 0
-#define IGNORE_ALPHA 1
-
 #ifndef GL_NV_texture_rectangle
 #define GL_TEXTURE_RECTANGLE_NV           0x84F5
 #define GL_TEXTURE_BINDING_RECTANGLE_NV   0x84F6
 #define GL_PROXY_TEXTURE_RECTANGLE_NV     0x84F7
 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV  0x84F8
 #endif
+#endif
+
+#define NO_UPDATE 0
+#define UPDATE 1
+#define USE_ALPHA 0
+#define IGNORE_ALPHA 1
 
 void load_and_display_image(char * file);
 void clearscreen(float r, float g, float b);
@@ -38,6 +40,5 @@ void drawtext(char * text, int x, int y, SDL_Surface * surf, int update, int sha
 void drawcenteredtext(char * text, int y, SDL_Surface * surf, int update, int shadowsize);
 void erasetext(char * text, int x, int y, SDL_Surface * surf, int update, int shadowsize);
 void erasecenteredtext(char * text, int y, SDL_Surface * surf, int update, int shadowsize);
-void create_gl_texture(SDL_Surface * surf, GLint * tex);
 void update_rect(SDL_Surface *scr, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
 
index 31bf697..4f62180 100644 (file)
@@ -17,7 +17,9 @@
 #include <unistd.h>
 #include <SDL.h>
 #include <SDL_image.h>
+#ifndef NOOPENGL
 #include <SDL_opengl.h>
+#endif
 
 #ifdef LINUX
 #include <pwd.h>
@@ -30,6 +32,7 @@
 #include "globals.h"
 #include "setup.h"
 #include "screen.h"
+#include "texture.h"
 
 /* Local function prototypes: */
 
@@ -139,6 +142,12 @@ if(screen != NULL)
   else
   st_video_setup_sdl();
 
+  DEBUG_MSG("1");
+  
+  texture_setup();
+
+  DEBUG_MSG("2");
+    
   /* Set window manager stuff: */
 
   SDL_WM_SetCaption("Super Tux", "Super Tux");
@@ -177,6 +186,7 @@ void st_video_setup_sdl(void)
 
 void st_video_setup_gl(void)
 {
+#ifndef NOOPENGL
 
        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
@@ -235,6 +245,8 @@ void st_video_setup_gl(void)
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.0f, 0.0f, 0.0f);
+
+#endif
 }
 
 void st_joystick_setup(void)
@@ -426,11 +438,14 @@ void parseargs(int argc, char * argv[])
 {
   int i;
 
-
   /* Set defaults: */
 
+
   debug_mode = NO;
   use_fullscreen = NO;
+
+  use_gl = NO;    
+
 #ifndef NOSOUND
 
   use_sound = YES;
@@ -457,9 +472,11 @@ void parseargs(int argc, char * argv[])
       else if (strcmp(argv[i], "--opengl") == 0 ||
           strcmp(argv[i], "-g") == 0)
         {
-          /* Use full screen: */
+       #ifndef NOOPENGL
+          /* Use OpengGL: */
 
           use_gl = YES;
+       #endif
         }
       else if (strcmp(argv[i], "--usage") == 0)
         {
@@ -511,6 +528,8 @@ void parseargs(int argc, char * argv[])
 
           printf("----------  Command-line options  ----------\n\n");
 
+          printf("  --opengl            - If opengl support was compiled in, this will enable the EXPERIMENTAL OpenGL mode.\n\n");
+         
           printf("  --disable-sound     - If sound support was compiled in,  this will\n                        disable sound for this session of the game.\n\n");
 
           printf("  --disable-music     - Like above, but this will disable music.\n\n");
@@ -564,7 +583,7 @@ void usage(char * prog, int ret)
 
   /* Display the usage message: */
 
-  fprintf(fi, "Usage: %s [--fullscreen] [--disable-sound] [--disable-music] [--debug-mode] | [--usage | --help | --version]\n",
+  fprintf(fi, "Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--debug-mode] | [--usage | --help | --version]\n",
           prog);
 
 
index 5b6de05..19a9f74 100644 (file)
 
 #include <SDL/SDL.h>
 #include <SDL/SDL_image.h>
-#include <SDL/SDL_opengl.h>
 #include "globals.h"
 #include "screen.h"
 #include "setup.h"
 #include "texture.h"
 
-void texture_load(texture_type* ptexture, char * file, int use_alpha)
+void texture_setup(void)
+{
+#ifdef NOOPENGL
+texture_load = texture_load_sdl;
+texture_free = texture_free_sdl;
+texture_draw = texture_draw_sdl;
+texture_draw_bg = texture_draw_bg_sdl;
+texture_draw_part = texture_draw_part_sdl;
+#else
+if(use_gl)
+{
+texture_load = texture_load_gl;
+texture_free = texture_free_gl;
+texture_draw = texture_draw_gl;
+texture_draw_bg = texture_draw_bg_gl;
+texture_draw_part = texture_draw_part_gl;
+}
+else
+{
+texture_load = texture_load_sdl;
+texture_free = texture_free_sdl;
+texture_draw = texture_draw_sdl;
+texture_draw_bg = texture_draw_bg_sdl;
+texture_draw_part = texture_draw_part_sdl;
+}
+#endif
+}
+
+#ifndef NOOPENGL
+void texture_load_gl(texture_type* ptexture, char * file, int use_alpha)
+{
+texture_load_sdl(ptexture,file,use_alpha);
+texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture);
+}
+
+void texture_draw_gl(texture_type* ptexture, float x, float y, int update)
+{
+      glColor4ub(255, 255, 255,255);
+      glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+      glEnable (GL_BLEND);
+      glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptexture->gl_texture);
+
+      glBegin(GL_QUADS);
+      glTexCoord2f(0, 0);
+      glVertex2f(x, y);
+      glTexCoord2f((float)ptexture->w, 0);
+      glVertex2f((float)ptexture->w+x, y);
+      glTexCoord2f((float)ptexture->w, (float)ptexture->h);
+      glVertex2f((float)ptexture->w+x, (float)ptexture->h+y);
+      glTexCoord2f(0, (float)ptexture->h);
+      glVertex2f(x, (float)ptexture->h+y);
+      glEnd();
+}
+
+void texture_draw_bg_gl(texture_type* ptexture, int update)
+{
+    //glColor3ub(255, 255, 255);
+
+    glEnable(GL_TEXTURE_RECTANGLE_NV);
+    glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptexture->gl_texture);
+
+    glBegin(GL_QUADS);
+        glTexCoord2f(0, 0);    glVertex2f(0, 0);
+        glTexCoord2f((float)ptexture->w, 0);    glVertex2f(screen->w, 0);
+        glTexCoord2f((float)ptexture->w, (float)ptexture->h);    glVertex2f(screen->w, screen->h);
+        glTexCoord2f(0, (float)ptexture->h); glVertex2f(0, screen->h);
+    glEnd();
+}
+
+void texture_draw_part_gl(texture_type* ptexture, float x, float y, float w, float h, int update)
+{
+      glColor3ub(255, 255, 255);
+
+      glEnable(GL_TEXTURE_RECTANGLE_NV);
+      glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptexture->gl_texture);
+
+      glBegin(GL_QUADS);
+      glTexCoord2f(x, y);
+      glVertex2f(x, y);
+      glTexCoord2f(x+w, y);
+      glVertex2f(w+x, y);
+      glTexCoord2f(x+w, y+h);
+      glVertex2f(w+x, h+y);
+      glTexCoord2f(x, y+h);
+      glVertex2f(x, h+y);
+      glEnd();
+}
+
+void texture_create_gl(SDL_Surface * surf, GLint * tex)
+{
+SDL_Surface *conv;
+conv = SDL_CreateRGBSurface(SDL_SWSURFACE , surf->w, surf->h, 32,
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+            0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
+#else
+            0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
+#endif
+    SDL_BlitSurface(surf, 0, conv, 0);
+                    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    
+  glGenTextures(1, &*tex);
+
+    glBindTexture(GL_TEXTURE_RECTANGLE_NV , *tex);
+             glEnable(GL_TEXTURE_RECTANGLE_NV);
+    glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glPixelStorei(GL_UNPACK_ROW_LENGTH, conv->pitch / conv->format->BytesPerPixel);
+    glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 3, conv->w, conv->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, conv->pixels);
+    //glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, conv->w, conv->h);
+    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+    SDL_FreeSurface(conv);
+}
+
+void texture_free_gl(texture_type* ptexture)
+{
+  SDL_FreeSurface(ptexture->sdl_surface);
+  glDeleteTextures(1, &ptexture->gl_texture);
+}
+#endif
+
+void texture_load_sdl(texture_type* ptexture, char * file, int use_alpha)
 {
   SDL_Surface * temp;
 
@@ -40,14 +160,11 @@ void texture_load(texture_type* ptexture, char * file, int use_alpha)
   ptexture->w = ptexture->sdl_surface->w;
   ptexture->h = ptexture->sdl_surface->h;
 
-  if(use_gl)
-    {
-      create_gl_texture(ptexture->sdl_surface,&ptexture->gl_texture);
-    }
 }
 
 void texture_from_sdl_surface(texture_type* ptexture, SDL_Surface* sdl_surf, int use_alpha)
 {
+
  /* SDL_Surface * temp;
 
   temp = IMG_Load(file);
@@ -66,34 +183,16 @@ void texture_from_sdl_surface(texture_type* ptexture, SDL_Surface* sdl_surf, int
   ptexture->w = ptexture->sdl_surface->w;
   ptexture->h = ptexture->sdl_surface->h;
 
+  #ifndef NOOPENGL
   if(use_gl)
     {
-      create_gl_texture(ptexture->sdl_surface,&ptexture->gl_texture);
+      texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture);
     }
+  #endif
 }
 
-void texture_draw(texture_type* ptexture, float x, float y, int update)
+void texture_draw_sdl(texture_type* ptexture, float x, float y, int update)
 {
-  if(use_gl)
-    {
-      glColor4ub(255, 255, 255,255);
-      glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-      glEnable (GL_BLEND);
-      glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptexture->gl_texture);
-
-      glBegin(GL_QUADS);
-      glTexCoord2f(0, 0);
-      glVertex2f(x, y);
-      glTexCoord2f((float)ptexture->w, 0);
-      glVertex2f((float)ptexture->w+x, y);
-      glTexCoord2f((float)ptexture->w, (float)ptexture->h);
-      glVertex2f((float)ptexture->w+x, (float)ptexture->h+y);
-      glTexCoord2f(0, (float)ptexture->h);
-      glVertex2f(x, (float)ptexture->h+y);
-      glEnd();
-    }
-  else
-    {
       SDL_Rect dest;
 
       dest.x = x;
@@ -105,27 +204,10 @@ void texture_draw(texture_type* ptexture, float x, float y, int update)
 
       if (update == UPDATE)
         SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
-    }
 }
 
-void texture_draw_bg(texture_type* ptexture, int update)
-{
-if(use_gl)
-{
-    //glColor3ub(255, 255, 255);
 
-    glEnable(GL_TEXTURE_RECTANGLE_NV);
-    glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptexture->gl_texture);
-
-    glBegin(GL_QUADS);
-        glTexCoord2f(0, 0);    glVertex2f(0, 0);
-        glTexCoord2f((float)ptexture->w, 0);    glVertex2f(screen->w, 0);
-        glTexCoord2f((float)ptexture->w, (float)ptexture->h);    glVertex2f(screen->w, screen->h);
-        glTexCoord2f(0, (float)ptexture->h); glVertex2f(0, screen->h);
-    glEnd();
-}
-else
+void texture_draw_bg_sdl(texture_type* ptexture, int update)
 {
   SDL_Rect dest;
   
@@ -139,30 +221,9 @@ else
   if (update == UPDATE)
     SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
 }
-}
 
-void texture_draw_part(texture_type* ptexture, float x, float y, float w, float h, int update)
+void texture_draw_part_sdl(texture_type* ptexture, float x, float y, float w, float h, int update)
 {
-  if(use_gl)
-    {
-      glColor3ub(255, 255, 255);
-
-      glEnable(GL_TEXTURE_RECTANGLE_NV);
-      glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptexture->gl_texture);
-
-      glBegin(GL_QUADS);
-      glTexCoord2f(x, y);
-      glVertex2f(x, y);
-      glTexCoord2f(x+w, y);
-      glVertex2f(w+x, y);
-      glTexCoord2f(x+w, y+h);
-      glVertex2f(w+x, h+y);
-      glTexCoord2f(x, y+h);
-      glVertex2f(x, h+y);
-      glEnd();
-    }
-  else
-    {
       SDL_Rect src, dest;
 
       src.x = x;
@@ -180,13 +241,10 @@ void texture_draw_part(texture_type* ptexture, float x, float y, float w, float
 
       if (update == UPDATE)
         update_rect(screen, dest.x, dest.y, dest.w, dest.h);
-    }
 }
 
-void texture_free(texture_type* ptexture)
+void texture_free_sdl(texture_type* ptexture)
 {
   SDL_FreeSurface(ptexture->sdl_surface);
-  if(use_gl)
-    glDeleteTextures(1, &ptexture->gl_texture);
 }
 
index 6584178..b85eb5c 100644 (file)
 #ifndef SUPERTUX_TEXTURE_H
 #define SUPERTUX_TEXTURE_H
 
+#include <SDL/SDL.h>
+#ifndef NOOPENGL
+#include <SDL/SDL_opengl.h>
+#endif
+
 /* Texture type */
 typedef struct texture_type
   {
@@ -23,13 +28,26 @@ typedef struct texture_type
   }  
 texture_type;
 
-void texture_setup(int opengl);
-void texture_load(texture_type* ptexture, char * file, int use_alpha);
+void texture_setup(void);
+void (*texture_load) (texture_type* ptexture, char * file, int use_alpha);  
+void (*texture_free) (texture_type* ptexture);  
+void (*texture_draw) (texture_type* ptexture, float x, float y, int update);  
+void (*texture_draw_bg) (texture_type* ptexture, int update);  
+void (*texture_draw_part) (texture_type* ptexture, float x, float y, float w, float h, int update);
+void texture_load_sdl(texture_type* ptexture, char * file, int use_alpha);
+void texture_free_sdl(texture_type* ptexture);
+void texture_draw_sdl(texture_type* ptexture, float x, float y, int update);
+void texture_draw_bg_sdl(texture_type* ptexture, int update);
+void texture_draw_part_sdl(texture_type* ptexture, float x, float y, float w, float h, int update);
 void texture_from_sdl_surface(texture_type* ptexture, SDL_Surface * sdl_surf, int use_alpha);
-void texture_free(texture_type* ptexture);
-void texture_draw(texture_type* ptexture, float x, float y, int update);
-void texture_draw_bg(texture_type* ptexture, int update);
-void texture_draw_part(texture_type* ptexture, float x, float y, float w, float h, int update);
+#ifndef NOOPENGL
+void texture_load_gl(texture_type* ptexture, char * file, int use_alpha);
+void texture_free_gl(texture_type* ptexture);
+void texture_draw_gl(texture_type* ptexture, float x, float y, int update);
+void texture_draw_bg_gl(texture_type* ptexture, int update);
+void texture_draw_part_gl(texture_type* ptexture, float x, float y, float w, float h, int update);
+void texture_create_gl(SDL_Surface * surf, GLint * tex);
+#endif
 
 #endif /*SUPERTUX_TEXTURE_H*/