From efc61e9d05b077f13a76982590fb0bd6a9d8dc61 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Sun, 2 Oct 2005 22:57:31 +0000 Subject: [PATCH] - Allow custom leveldots - Fix some crashs (end of level, end of worldmap) - Commit the non finished lightmap stuff I tried at the meeting... SVN-Revision: 2800 --- configure.ac | 15 +-- data/images/sprites.strf | 25 ++++- data/levels/test/light.stl | 83 ++++++++++++++++ data/levels/test/wansti-level4.stl | 5 - src/Jamfile | 2 +- src/control/joystickkeyboardcontroller.cpp | 2 +- src/game_session.cpp | 2 + src/gameconfig.hpp | 3 +- src/object/light.cpp | 37 +++++++ src/object/light.hpp | 41 ++++++++ src/object/player.cpp | 1 + src/object/player.hpp | 2 +- src/player_status.cpp | 12 +++ src/player_status.hpp | 6 ++ src/sprite/sprite_data.hpp | 4 - src/video/drawing_context.cpp | 153 +++++++++++++++++++++++++---- src/video/drawing_context.hpp | 40 +++++++- src/video/glutil.hpp | 41 ++++++++ src/video/screen.hpp | 2 +- src/video/surface.hpp | 4 +- src/video/texture.cpp | 116 ++++++++++++++++++++++ src/video/texture.hpp | 47 +++++++++ src/worldmap.cpp | 27 ++--- src/worldmap.hpp | 2 + 24 files changed, 613 insertions(+), 59 deletions(-) create mode 100644 data/levels/test/light.stl create mode 100644 src/object/light.cpp create mode 100644 src/object/light.hpp create mode 100644 src/video/glutil.hpp create mode 100644 src/video/texture.cpp create mode 100644 src/video/texture.hpp diff --git a/configure.ac b/configure.ac index d6326805f..0affc1a37 100644 --- a/configure.ac +++ b/configure.ac @@ -89,12 +89,6 @@ AM_ICONV AC_SUBST([ICONV_LIBS], [$LIBICONV]) dnl =========================================================================== -dnl Check for OpenGL -AX_CHECK_GL -if test "$no_gl" = "yes"; then - AC_MSG_ERROR([Please install opengl libraries and headers]) -fi - dnl Check for SDL SDL_VERSION=1.2.4 AM_PATH_SDL($SDL_VERSION, @@ -130,6 +124,15 @@ NP_FINDLIB([OPENAL], [OpenAL], [OpenAL], [AC_MSG_ERROR([Please intall OpenAL])], [], []) +AX_CHECK_GL +if test "$no_gl" = "yes"; then + AC_MSG_ERROR([Please install opengl libraries and headers]) +fi +AX_CHECK_GLU +if test "$no_glu" = "yes"; then + AC_MSG_ERROR([Please install opengl utility libraries and headers]) +fi + dnl Checks for library functions. AC_CHECK_FUNCS(mkdir strdup strstr) diff --git a/data/images/sprites.strf b/data/images/sprites.strf index 336e28514..1e44e8dc0 100644 --- a/data/images/sprites.strf +++ b/data/images/sprites.strf @@ -1679,6 +1679,14 @@ (images "powerups/potions/blue-potion.png") ) ) + + (sprite + (name "lightmap_light") + (action + (name "default") + (images "effects/light_red.png") + ) + ) (sprite (name "eat-me") @@ -1754,7 +1762,7 @@ (name "default") (images "objects/keys/key_gold.png") ) - (action + (action (name "display") (images "objects/keys/display_gold.png") ) @@ -1763,5 +1771,20 @@ (images "objects/keys/outline_gold.png") ) ) + (sprite + (name "leveldot") + (action + (name "default") + (x-offset 16) + (y-offset 16) + (images "worldmap/common/leveldot_red.png") + ) + (action + (name "solved") + (x-offset 16) + (y-offset 16) + (images "worldmap/common/leveldot_green.png") + ) + ) ) diff --git a/data/levels/test/light.stl b/data/levels/test/light.stl new file mode 100644 index 000000000..c6cabc495 --- /dev/null +++ b/data/levels/test/light.stl @@ -0,0 +1,83 @@ +;SuperTux level made using the built-in leveleditor +(supertux-level + (version 1) + (name "One Block Fall-through / Spikes") + (author "") + (music "chipdisko.ogg") + (background "arctis.jpg") + (particle_system "") + (bkgd_speed 50) + (bkgd_red_top 50) + (bkgd_green_top 150) + (bkgd_blue_top 150) + (bkgd_red_bottom 150) + (bkgd_green_bottom 150) + (bkgd_blue_bottom 150) + (time 500) + (width 150) + (height 15) + (back_scrolling #f) + (hor_autoscroll_speed 0.0) + (gravity 10.0) + (background-tm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 + 11 11 11 11 11 11 11 11 11 12 200 200 200 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 + 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 +) + (foreground-tm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +) +(reset-points +) +(objects + (light ) + (mriceblock (x 666) (y 68) (stay-on-platform #f)) + (mriceblock (x 892) (y 70) (stay-on-platform #f)) + (mriceblock (x 1146) (y 69) (stay-on-platform #f)) + (mriceblock (x 1363) (y 58) (stay-on-platform #f)) + (mriceblock (x 1180) (y 15) (stay-on-platform #f)) + (mriceblock (x 939) (y 22) (stay-on-platform #f)) + (mriceblock (x 703) (y 25) (stay-on-platform #f)) + (stalactite (x 322) (y 287) (stay-on-platform #f)) +) +) diff --git a/data/levels/test/wansti-level4.stl b/data/levels/test/wansti-level4.stl index 1746aef4d..4b43abd39 100644 --- a/data/levels/test/wansti-level4.stl +++ b/data/levels/test/wansti-level4.stl @@ -168,11 +168,6 @@ (powerup (sprite "red-potion") (script " -function wait(time) { - set_wakeup_time(time); - suspend(); -} - DisplayEffect.set_black(true); wait(0.1); DisplayEffect.set_black(false); diff --git a/src/Jamfile b/src/Jamfile index 38492e855..3b93511f4 100644 --- a/src/Jamfile +++ b/src/Jamfile @@ -24,7 +24,7 @@ TRANSLATABLE_SOURCES += [ SearchSource $(sources) ] ; Application supertux : $(sources) $(wrapper_objects) ; C++Flags supertux : -DAPPDATADIR='\"$(appdatadir)\"' ; LinkWith supertux : squirrel ; -ExternalLibs supertux : SDL SDLIMAGE GL OPENAL VORBIS VORBISFILE OGG ICONV PHYSFS BINRELOC ; +ExternalLibs supertux : SDL SDLIMAGE GL GLU OPENAL VORBIS VORBISFILE OGG ICONV PHYSFS BINRELOC ; Help supertux : "Build the supertux executable" ; IncludeDir supertux : squirrel/include ; diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 0fb4d9ee9..c840019a4 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -253,7 +253,7 @@ JoystickKeyboardController::process_event(const SDL_Event& event) (event.key.keysym.unicode & 0xFF80) == 0) { memmove(last_keys, last_keys+1, sizeof(last_keys)-1); last_keys[sizeof(last_keys)-1] = event.key.keysym.unicode; - if(GameSession::current()) + if(GameSession::current() != NULL) GameSession::current()->try_cheats(); } diff --git a/src/game_session.cpp b/src/game_session.cpp index b7985bbb6..2aa30368a 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -147,6 +147,8 @@ GameSession::~GameSession() delete end_sequence_controller; delete level; delete context; + + current_ = NULL; } void diff --git a/src/gameconfig.hpp b/src/gameconfig.hpp index 8fdaff123..b4172210b 100644 --- a/src/gameconfig.hpp +++ b/src/gameconfig.hpp @@ -31,7 +31,8 @@ public: void save(); /** screen width in pixel (warning: this is the real screen width+height, - * supertux is using a logical width+height and not this one) + * you should use the logical SCREEN_WIDTH and SCREEN_HEIGHT for your + * rendering code.) */ int screenwidth; int screenheight; diff --git a/src/object/light.cpp b/src/object/light.cpp new file mode 100644 index 000000000..ebd8146ac --- /dev/null +++ b/src/object/light.cpp @@ -0,0 +1,37 @@ +#include + +#include "light.hpp" +#include "sprite/sprite_manager.hpp" +#include "resources.hpp" +#include "video/drawing_context.hpp" +#include "object_factory.hpp" +#include "player.hpp" +#include "sector.hpp" + +Light::Light(const lisp::Lisp& ) +{ + sprite = sprite_manager->create("lightmap_light"); +} + +Light::~Light() +{ + delete sprite; +} + +void +Light::update(float ) +{ +} + +void +Light::draw(DrawingContext& context) +{ + context.push_target(); + context.set_target(DrawingContext::LIGHTMAP); + + sprite->draw(context, Sector::current()->player->get_pos(), 0); + + context.pop_target(); +} + +IMPLEMENT_FACTORY(Light, "light"); diff --git a/src/object/light.hpp b/src/object/light.hpp new file mode 100644 index 000000000..4178034a1 --- /dev/null +++ b/src/object/light.hpp @@ -0,0 +1,41 @@ +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Matthias Braun #include "lisp/lisp.hpp" #include "timer.hpp" #include "serializable.hpp" @@ -58,6 +59,8 @@ public: int score_multiplier; int max_score_multiplier; + + void operator= (const PlayerStatus& other); enum { KEY_BRASS = 0x001, @@ -68,6 +71,9 @@ public: }; private: + // don't use this + PlayerStatus(const PlayerStatus& other); + int keys; Sprite* key_iron; Sprite* key_brass; diff --git a/src/sprite/sprite_data.hpp b/src/sprite/sprite_data.hpp index f9a87a3d2..3850141dd 100644 --- a/src/sprite/sprite_data.hpp +++ b/src/sprite/sprite_data.hpp @@ -59,10 +59,6 @@ private: /** Frames per second */ float fps; - /** Mirror is used to avoid duplicating left and right side - sprites */ - // bool mirror; - std::vector surfaces; }; diff --git a/src/video/drawing_context.cpp b/src/video/drawing_context.cpp index 7c8369527..48b9c9776 100644 --- a/src/video/drawing_context.cpp +++ b/src/video/drawing_context.cpp @@ -21,20 +21,44 @@ #include #include #include +#include +#include +#include #include "drawing_context.hpp" #include "surface.hpp" #include "font.hpp" #include "main.hpp" #include "gameconfig.hpp" +#include "glutil.hpp" +#include "texture.hpp" -DrawingContext::DrawingContext(SDL_Surface* targetsurface) +#define LIGHTMAP_DIV 4 + +static inline int next_po2(int val) { - if(targetsurface) { - screen = targetsurface; - } else { - screen = SDL_GetVideoSurface(); - } + int result = 1; + while(result < val) + result *= 2; + + return result; +} + +DrawingContext::DrawingContext() +{ + screen = SDL_GetVideoSurface(); + + lightmap_width = screen->w / LIGHTMAP_DIV; + lightmap_height = screen->h / LIGHTMAP_DIV; + int width = next_po2(lightmap_width); + int height = next_po2(lightmap_height); + + lightmap.reset(new Texture(width, height, GL_RGB)); + + lightmap_uv_right = static_cast(lightmap_width) / static_cast(width); + lightmap_uv_bottom = static_cast(lightmap_height) / static_cast(height); + + requests = &drawing_requests; } DrawingContext::~DrawingContext() @@ -62,7 +86,7 @@ DrawingContext::draw_surface(const Surface* surface, const Vector& position, request.alpha = transform.alpha; request.request_data = const_cast (surface); - drawingrequests.push_back(request); + requests->push_back(request); } void @@ -101,7 +125,7 @@ DrawingContext::draw_surface_part(const Surface* surface, const Vector& source, } request.request_data = surfacepartrequest; - drawingrequests.push_back(request); + requests->push_back(request); } void @@ -123,7 +147,7 @@ DrawingContext::draw_text(const Font* font, const std::string& text, textrequest->alignment = alignment; request.request_data = textrequest; - drawingrequests.push_back(request); + requests->push_back(request); } void @@ -152,7 +176,7 @@ DrawingContext::draw_gradient(Color top, Color bottom, int layer) gradientrequest->bottom = bottom; request.request_data = gradientrequest; - drawingrequests.push_back(request); + requests->push_back(request); } void @@ -177,7 +201,7 @@ DrawingContext::draw_filled_rect(const Vector& topleft, const Vector& size, * ((float) transform.alpha / 255.0)); request.request_data = fillrectrequest; - drawingrequests.push_back(request); + requests->push_back(request); } void @@ -256,13 +280,85 @@ DrawingContext::do_drawing() { #ifdef DEBUG assert(transformstack.empty()); + assert(target_stack.empty()); #endif transformstack.clear(); + target_stack.clear(); + + bool use_lightmap = lightmap_requests.size() != 0; + + // PART1: create lightmap + if(use_lightmap) { + glViewport(0, screen->h - lightmap_height, lightmap_width, lightmap_height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glClearColor(1, 1, 1, 1); + glClear(GL_COLOR_BUFFER_BIT); + handle_drawing_requests(lightmap_requests); + lightmap_requests.clear(); + + glDisable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, lightmap->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(); + glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + } + + //glClear(GL_COLOR_BUFFER_BIT); + handle_drawing_requests(drawing_requests); + drawing_requests.clear(); + + if(use_lightmap) { + glEnable(GL_BLEND); + glBlendFunc(GL_DST_COLOR, GL_ZERO); + //glDisable(GL_BLEND); + //glColor4f((float) rand() / (float) RAND_MAX, .22, .88, 1.0f); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glDisable(GL_ALPHA_TEST); + + glBindTexture(GL_TEXTURE_2D, lightmap->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); - std::stable_sort(drawingrequests.begin(), drawingrequests.end()); + glEnd(); + } - for(DrawingRequests::iterator i = drawingrequests.begin(); - i != drawingrequests.end(); ++i) { + assert_gl("drawing"); + + SDL_GL_SwapBuffers(); +} + +void +DrawingContext::handle_drawing_requests(DrawingRequests& requests) +{ + std::stable_sort(requests.begin(), requests.end()); + + for(DrawingRequests::iterator i = requests.begin(); + i != requests.end(); ++i) { switch(i->type) { case SURFACE: { @@ -290,11 +386,6 @@ DrawingContext::do_drawing() break; } } - - drawingrequests.clear(); - - // update screen - SDL_GL_SwapBuffers(); } void @@ -341,3 +432,27 @@ DrawingContext::get_alpha() const { return transform.alpha; } + +void +DrawingContext::push_target() +{ + target_stack.push_back(target); +} + +void +DrawingContext::pop_target() +{ + set_target(target_stack.back()); + target_stack.pop_back(); +} + +void +DrawingContext::set_target(Target target) +{ + this->target = target; + if(target == LIGHTMAP) + requests = &lightmap_requests; + else + requests = &drawing_requests; +} + diff --git a/src/video/drawing_context.hpp b/src/video/drawing_context.hpp index f105ea125..b3b6d284f 100644 --- a/src/video/drawing_context.hpp +++ b/src/video/drawing_context.hpp @@ -25,6 +25,7 @@ #include #include +#include #include "math/vector.hpp" #include "video/screen.hpp" @@ -32,6 +33,7 @@ #include "video/font.hpp" class Surface; +class Texture; // some constants for predefined layer values enum { @@ -46,7 +48,6 @@ enum { LAYER_GUI = 500 }; -/// Handles drawing of things. /** * This class provides functions for drawing things on screen. It also * maintains a stack of transforms that are applied to graphics. @@ -54,7 +55,7 @@ enum { class DrawingContext { public: - DrawingContext(SDL_Surface* targetsurface = 0); + DrawingContext(); ~DrawingContext(); /// Adds a drawing request for a surface into the request list. @@ -100,6 +101,13 @@ public: void set_alpha(uint8_t alpha); /// return currently set alpha uint8_t get_alpha() const; + + enum Target { + NORMAL, LIGHTMAP + }; + void push_target(); + void pop_target(); + void set_target(Target target); private: class Transform @@ -124,6 +132,19 @@ private: std::vector transformstack; /// the currently active transform Transform transform; + + class Blend + { + public: + GLenum sfactor; + GLenum dfactor; + + Blend() + : sfactor(GL_SRC_ALPHA), dfactor(GL_ONE_MINUS_SRC_ALPHA) + {} + }; + std::vector blend_stack; + Blend blend_mode; enum RequestType { @@ -164,6 +185,7 @@ private: uint32_t drawing_effect; float zoom; int alpha; + Blend blend; void* request_data; @@ -172,17 +194,27 @@ private: return layer < other.layer; } }; + + typedef std::vector DrawingRequests; + void handle_drawing_requests(DrawingRequests& requests); void draw_surface_part(DrawingRequest& request); void draw_text(DrawingRequest& request); void draw_text_center(DrawingRequest& request); void draw_gradient(DrawingRequest& request); void draw_filled_rect(DrawingRequest& request); - typedef std::vector DrawingRequests; - DrawingRequests drawingrequests; + DrawingRequests drawing_requests; + DrawingRequests lightmap_requests; + + DrawingRequests* requests; SDL_Surface* screen; + Target target; + std::vector target_stack; + std::auto_ptr lightmap; + int lightmap_width, lightmap_height; + float lightmap_uv_right, lightmap_uv_bottom; }; #endif diff --git a/src/video/glutil.hpp b/src/video/glutil.hpp new file mode 100644 index 000000000..f7d43109c --- /dev/null +++ b/src/video/glutil.hpp @@ -0,0 +1,41 @@ +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Matthias Braun +#include +#include +#include + +static inline void assert_gl(const char* message) +{ +#ifdef DEBUG + GLenum error = glGetError(); + if(error != GL_NO_ERROR) { + std::ostringstream msg; + msg << "OpenGLError while '" << message << "': " + << gluErrorString(error); + throw std::runtime_error(msg.str()); + } +#endif +} + +#endif + diff --git a/src/video/screen.hpp b/src/video/screen.hpp index 2dd824a92..8f634982b 100644 --- a/src/video/screen.hpp +++ b/src/video/screen.hpp @@ -20,7 +20,7 @@ #define SUPERTUX_SCREEN_H #include -#include +#include #include #include diff --git a/src/video/surface.hpp b/src/video/surface.hpp index ea0b89b9b..bd0da7c0e 100644 --- a/src/video/surface.hpp +++ b/src/video/surface.hpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include "math/vector.hpp" #include "video/screen.hpp" @@ -34,7 +34,6 @@ SDL_Surface* sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf); SDL_Surface* sdl_surface_from_nothing(); class SurfaceImpl; -class SurfaceSDL; class SurfaceOpenGL; class DrawingContext; @@ -83,7 +82,6 @@ public: SurfaceData(Color top_gradient_, Color bottom_gradient_, int w_, int h_); ~SurfaceData(); - SurfaceSDL* create_SurfaceSDL(); SurfaceOpenGL* create_SurfaceOpenGL(); SurfaceImpl* create(); }; diff --git a/src/video/texture.cpp b/src/video/texture.cpp new file mode 100644 index 000000000..98bfc91d3 --- /dev/null +++ b/src/video/texture.cpp @@ -0,0 +1,116 @@ +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Matthias Braun + +#include "texture.hpp" + +#include +#include +#include "glutil.hpp" + +static inline bool is_power_of_2(int v) +{ + return (v & (v-1)) == 0; +} + +Texture::Texture(unsigned int w, unsigned int h, GLenum glformat) +{ + assert(is_power_of_2(w)); + assert(is_power_of_2(h)); + + this->width = w; + this->height = h; + + assert_gl("before creating texture"); + glGenTextures(1, &handle); + + try { + glBindTexture(GL_TEXTURE_2D, handle); + + glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, GL_RGBA, + GL_UNSIGNED_BYTE, 0); + + set_texture_params(); + } catch(...) { + glDeleteTextures(1, &handle); + throw; + } +} + +Texture::Texture(SDL_Surface* image, GLenum glformat) +{ + 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"); + + this->width = image->w; + this->height = image->h; + + assert_gl("before creating texture"); + glGenTextures(1, &handle); + + try { + GLenum sdl_format; + if(format->BytesPerPixel == 3) + sdl_format = GL_RGB; + else if(format->BytesPerPixel == 4) + sdl_format = GL_RGBA; + else + assert(false); + + glBindTexture(GL_TEXTURE_2D, handle); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ROW_LENGTH, image->pitch/format->BytesPerPixel); + glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, sdl_format, + GL_UNSIGNED_BYTE, image->pixels); + + assert_gl("creating texture"); + + set_texture_params(); + } catch(...) { + glDeleteTextures(1, &handle); + throw; + } +} + +Texture::~Texture() +{ + glDeleteTextures(1, &handle); +} + +void upload_texture(SDL_Surface* , int , int , int , int , int , int ) +{ + // TODO + assert(false); +} + +void +Texture::set_texture_params() +{ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP); + + assert_gl("set texture params"); +} + diff --git a/src/video/texture.hpp b/src/video/texture.hpp new file mode 100644 index 000000000..8322e3c7a --- /dev/null +++ b/src/video/texture.hpp @@ -0,0 +1,47 @@ +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Matthias Braun +#include + +/** + * This class is a very simple wrapper around a texture handle + */ +class Texture +{ +public: + GLuint handle; + unsigned int width; + unsigned int height; + + Texture(unsigned int width, unsigned int height, GLenum glformat); + Texture(SDL_Surface* surface, GLenum glformat); + ~Texture(); + + void upload_texture(SDL_Surface* image, int src_x, int src_y, int dst_x, int dst_y, + int width, int height); +private: + void set_texture_params(); +}; + + +#endif + diff --git a/src/worldmap.cpp b/src/worldmap.cpp index d31d4968f..37ef7598d 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -352,8 +352,6 @@ WorldMap::WorldMap() tux = new Tux(this); add_object(tux); - leveldot_green= new Surface("images/worldmap/common/leveldot_green.png", true); - leveldot_red = new Surface("images/worldmap/common/leveldot_red.png", true); messagedot = new Surface("images/worldmap/common/messagedot.png", true); teleporterdot = new Surface("images/worldmap/common/teleporterdot.png", true); @@ -371,11 +369,13 @@ WorldMap::~WorldMap() i != spawn_points.end(); ++i) { delete *i; } - + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) { + Level& level = *i; + delete level.sprite; + } + delete tile_manager; - delete leveldot_green; - delete leveldot_red; delete messagedot; delete teleporterdot; } @@ -516,6 +516,10 @@ WorldMap::parse_level_tile(const lisp::Lisp* level_lisp) level.south = true; level.west = true; + std::string sprite = "leveldot"; + level_lisp->get("sprite", sprite); + level.sprite = sprite_manager->create(sprite); + level_lisp->get("extro-script", level.extro_script); level_lisp->get("next-worldmap", level.next_worldmap); @@ -735,7 +739,8 @@ WorldMap::update(float delta) if (level->pos == tux->get_tile_pos()) { sound_manager->stop_music(); - PlayerStatus old_player_status = *player_status; + PlayerStatus old_player_status; + old_player_status = *player_status; // do a shriking fade to the level shrink_fade(Vector((level->pos.x*32 + 16 + offset.x), @@ -750,6 +755,7 @@ WorldMap::update(float delta) level_finished = true; bool old_level_state = level->solved; level->solved = true; + level->sprite->set_action("solved"); // deal with statistics level->statistics.merge(global_stats); @@ -905,12 +911,8 @@ WorldMap::draw(DrawingContext& context) for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) { - if (i->solved) - context.draw_surface(leveldot_green, - Vector(i->pos.x*32, i->pos.y*32), LAYER_TILES+1); - else - context.draw_surface(leveldot_red, - Vector(i->pos.x*32, i->pos.y*32), LAYER_TILES+1); + const Level& level = *i; + level.sprite->draw(context, level.pos*32 + Vector(16, 16), LAYER_TILES+1); } for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) @@ -1162,6 +1164,7 @@ WorldMap::loadgame(const std::string& filename) if (name == i->name) { i->solved = solved; + i->sprite->set_action(solved ? "solved" : "default"); i->statistics.parse(*level); break; } diff --git a/src/worldmap.hpp b/src/worldmap.hpp index a6a1c6655..6333d34d4 100644 --- a/src/worldmap.hpp +++ b/src/worldmap.hpp @@ -149,6 +149,8 @@ public: std::string title; bool solved; + Sprite* sprite; + /** Statistics for level tiles */ Statistics statistics; -- 2.11.0