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"
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"
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();
50 glOrtho(0, screen
.width(), screen
.height(), 0, -1, 1);
52 glMatrixMode(GL_MODELVIEW
); glPushMatrix();
55 Core::ImageManager im
;
56 Core::ImageManager::ImagePtr image
= im
.get("pigeon");
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());
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
);
73 glDisable(GL_TEXTURE_2D
);
74 glTranslatef(0.0f
, 0.0f
, 0.1f
);
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();
95 * Destroys a splashscreen object.
97 SplashScreen::~SplashScreen()
102 Interactor::InteractionResult
SplashScreen::processEvents(SDL_Event
& event
)
104 InteractionResult result
= k_notHandled
;
109 if (event
.user
.data2
== m_timeout
.timerId())
111 std::cerr
<< "SplashScreen timeout\n";
119 std::cerr
<< "SplashScreen keydown\n";
131 void SplashScreen::update()
136 void SplashScreen::draw()
140 } // namespace Poopmup