spacebox/demo/fill_screen/fill_screen.cpp

50 lines
1.7 KiB
C++

/*!<pre>
* /\ +------------------------------------------------------+
* ____/ \____ /| - Open source game framework licensed to freely use, |
* \ / / | copy, modify and sell without restriction |
* +--\ ^__^ /--+ | |
* | ~/ \~ | | - created for <https://foam.shampoo.ooo> |
* | ~~~~~~~~~~~~ | +------------------------------------------------------+
* | SPACE ~~~~~ | /
* | ~~~~~~~ BOX |/
* +--------------+ </pre>
*
* Fill screen example by frank at shampoo.ooo
*
* This is an example program that fills the screen with a color every frame. It is a minimal example of a SPACEBOX program
* that can be used for testing builds.
*/
#include "Game.hpp"
class FillScreen : public Game
{
public:
/* Color component values that will increment each frame to combine into a different solid color. */
float red = 1.0f, green = 0.5f, blue = 0.25f;
/* This gets called every frame by the parent class. Clear the screen with a solid color. */
void update()
{
red += 0.004f;
green += 0.002f;
blue += 0.001f;
glClearColor(std::abs(red - int(red) - 0.5f), std::abs(green - int(green) - 0.5f), std::abs(blue - int(blue) - 0.5f), 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(window());
}
};
/* Create a game object, load its GL context, and run the game. */
int main(int argc, char* argv[])
{
FillScreen fill_screen = FillScreen();
fill_screen.load_gl_context();
fill_screen.run();
fill_screen.quit();
return 0;
}