Fixed windings on map.
[poopmup2.git] / poopmup / splashscreen.cpp
blobe272936413339a5f7bdcb2ab509c382a4e8c5a87
1 /**
2 * @file poopmup/splashscreen.cpp
3 * The private implemntation file for the splashscreen class.
5 * Copyright 2008, 2010 Stephen M. Webb <bregma@poopmup.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "poopmup/splashscreen.h"
23 #include <iostream>
24 #include <SDL/SDL.h>
25 #include "poopmup/core/font.h"
26 #include "poopmup/core/fontmanager.h"
27 #include "poopmup/core/image.h"
28 #include "poopmup/core/imagemanager.h"
29 #include "poopmup/opengl.h"
30 #include "poopmup/screen.h"
33 namespace Poopmup
37 /**
38 * Splats the splash screen up (with a maximum size).
40 * @todo get the screen size from the screen and be self-adjusting.
42 SplashScreen::SplashScreen(const Screen& screen)
43 : m_timeout(5000) // ~5 s
45 const float width = 640.0;
46 const float height = 480.0;
48 glMatrixMode(GL_PROJECTION); glPushMatrix();
49 glLoadIdentity();
50 glOrtho(0, screen.width(), screen.height(), 0, -1, 1);
52 glMatrixMode(GL_MODELVIEW); glPushMatrix();
53 glLoadIdentity();
55 Core::ImageManager im;
56 Core::ImageManager::ImagePtr image = im.get("pigeon");
58 glEnable(GL_BLEND);
59 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
61 float leftEdge = (screen.width() - width) / 2.0f;
62 float topEdge = (screen.height() - height) / 2.0f;
64 glEnable(GL_TEXTURE_2D);
65 glTranslatef(0.0f, 0.0f, -0.1f);
66 glBindTexture(GL_TEXTURE_2D, image->texture());
67 glBegin(GL_QUADS);
68 glTexCoord2f(0.0f, 0.0f); glVertex3f(leftEdge, topEdge, 0.0f);
69 glTexCoord2f(1.0f, 0.0f); glVertex3f(leftEdge+width, topEdge, 0.0f);
70 glTexCoord2f(1.0f, 1.0f); glVertex3f(leftEdge+width, topEdge+height, 0.0f);
71 glTexCoord2f(0.0f, 1.0f); glVertex3f(leftEdge, topEdge+height, 0.0f);
72 glEnd();
73 glDisable(GL_TEXTURE_2D);
74 glTranslatef(0.0f, 0.0f, 0.1f);
76 Core::FontManager fm;
77 Core::FontManager::FontPtr font = fm.get("font1");
79 glColor4f(1.0f, 0.4f, 0.4f, 1.0f);
80 font->print(leftEdge + 40.0f, topEdge + 60.0f, 40.0f, 40.0f, "Poop'M Up 2.0");
81 glColor4f(1.0f, 1.0f, 0.2f, 0.75f);
82 font->print(leftEdge + 20.0f, topEdge + height - 20.0f, 12.0f, 12.0f,
83 "Copyright 2002 Zaroubi, Fink, Leclerc, Stanek");
84 font->print(leftEdge + 20.0f, topEdge + height - 10.0f, 12.0f, 12.0f,
85 "Copyright 2008 Stephen M. Webb");
87 glMatrixMode(GL_MODELVIEW); glPopMatrix();
88 glMatrixMode(GL_PROJECTION); glPopMatrix();
90 ::SDL_GL_SwapBuffers();
94 /**
95 * Destroys a splashscreen object.
97 SplashScreen::~SplashScreen()
102 Interactor::InteractionResult SplashScreen::processEvents(SDL_Event& event)
104 InteractionResult result = k_notHandled;
105 switch (event.type)
107 case SDL_USEREVENT:
109 if (event.user.data2 == m_timeout.timerId())
111 std::cerr << "SplashScreen timeout\n";
112 result = k_done;
114 break;
117 case SDL_KEYDOWN:
119 std::cerr << "SplashScreen keydown\n";
120 result = k_done;
121 break;
124 default:
125 break;
127 return result;
131 void SplashScreen::update()
136 void SplashScreen::draw()
140 } // namespace Poopmup