33 lines
947 B
C++
33 lines
947 B
C++
|
#include "sdlpp/sdlpp.hpp"
|
||
|
#include <SDL2/SDL2_framerate.h>
|
||
|
|
||
|
int main() {
|
||
|
SDLPP::init();
|
||
|
SDLPP::Window w("Test");
|
||
|
w.setResizable( true );
|
||
|
auto renderer = std::make_shared< SDLPP::Renderer >( w );
|
||
|
renderer->setBlendMode( SDL_BLENDMODE_BLEND );
|
||
|
auto main_scene = std::make_shared< SDLPP::Scene >( renderer );
|
||
|
auto bg = std::make_shared<SDLPP::RectangleRender>(0, 0, 10, 10, renderer, "#FF0000", true);
|
||
|
bg->setId(123);
|
||
|
bg->setPermanent(true);
|
||
|
main_scene->addObject(bg);
|
||
|
FPSmanager gFPS;
|
||
|
SDL_initFramerate( &gFPS );
|
||
|
SDL_setFramerate( &gFPS, 60 );
|
||
|
|
||
|
int base = SDL_GetTicks();
|
||
|
int frames = 0;
|
||
|
while(true) {
|
||
|
SDL_PumpEvents();
|
||
|
main_scene->renderScene();
|
||
|
main_scene->presentScene();
|
||
|
frames++;
|
||
|
if ( SDL_GetTicks() - base >= 1000 ) {
|
||
|
base = SDL_GetTicks();
|
||
|
printf( "FPS: %d\n", frames );
|
||
|
frames = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|