]> git.tdb.fi Git - libs/demoscene.git/blob - source/launchscreen.cpp
Initial files lifted from the Skrolliparty 2 demo
[libs/demoscene.git] / source / launchscreen.cpp
1 #include <msp/gl/blend.h>
2 #include <msp/gl/framebuffer.h>
3 #include <msp/gl/renderer.h>
4 #include <msp/strings/format.h>
5 #include "launchscreen.h"
6
7 using namespace Msp;
8
9 LaunchScreen::LaunchScreen(DataFile::Collection &resources):
10         font(resources.get<GL::Font>("ikarius-48.font")),
11         tech(resources.get<GL::Technique>("basic_text.tech")),
12         countdown(font, &tech),
13         countdown_value(0),
14         enter_prompt(font, &tech),
15         esc_prompt(font, &tech)
16 {
17         countdown.set_alignment(GL::Text::CENTER);
18
19         enter_prompt.set_alignment(GL::Text::CENTER);
20         enter_prompt.set_text("Press ENTER now to remain windowed");
21
22         esc_prompt.set_alignment(GL::Text::CENTER);
23         esc_prompt.set_text("Press ESC at any time to exit");
24
25         camera.set_orthographic(1920, 1080);
26         camera.set_depth_clip(-1, 1);
27 }
28
29 void LaunchScreen::set_countdown(unsigned c)
30 {
31         if(c!=countdown_value)
32         {
33                 countdown_value = c;
34                 countdown.set_text(format("Going fullscreen in %d...", countdown_value));
35         }
36 }
37
38 void LaunchScreen::render()
39 {
40         GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT);
41         GL::Bind blend(GL::Blend::alpha());
42         GL::Renderer renderer(&camera);
43         renderer.transform(GL::Matrix().scale(48).translate(0, 1.2, 0));
44         countdown.render(renderer);
45         renderer.transform(GL::Matrix::translation(0, -1.2, 0));
46         enter_prompt.render(renderer);
47         renderer.transform(GL::Matrix::translation(0, -1.2, 0));
48         esc_prompt.render(renderer);
49 }