#include "initialization.hpp"
class ExamplePath:public Initialization
{
public:
ExamplePath(DemoRunner *runner, int argc, char **argv);
virtual
void
draw_frame(void) override;
virtual
void
handle_event(const SDL_Event &ev) override;
private:
float m_scale;
};
ExamplePath::
ExamplePath(DemoRunner *runner, int argc, char **argv):
Initialization(runner, argc, argv),
m_translate(200.0f, 200.0f),
m_scale(1.0f)
{
m_path
.close_contour();
m_path
m_path
}
void
ExamplePath::
draw_frame(void)
{
m_surface_gl->viewport(vwp);
m_painter->translate(m_translate);
m_painter->scale(m_scale);
.color(1.0f, 0.0f, 0.0f, 1.0f),
.color(1.0f, 0.6f, 0.0f, 0.8f),
.width(8.0f),
m_path,
m_painter->end();
fastuidraw_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
fastuidraw_glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_surface_gl->blit_surface(GL_NEAREST);
}
void
ExamplePath::
handle_event(const SDL_Event &ev)
{
switch (ev.type)
{
case SDL_KEYDOWN:
switch (ev.key.keysym.sym)
{
case SDLK_UP:
m_translate.y() += 16.0f;
break;
case SDLK_DOWN:
m_translate.y() -= 16.0f;
break;
case SDLK_LEFT:
m_translate.x() += 16.0f;
break;
case SDLK_RIGHT:
m_translate.x() -= 16.0f;
break;
case SDLK_PAGEUP:
m_scale += 0.2f;
break;
case SDLK_PAGEDOWN:
m_scale -= 0.2f;
break;
case SDLK_SPACE:
m_scale = 1.0f;
m_translate.x() = 0.0f;
m_translate.y() = 0.0f;
break;
}
break;
}
Initialization::handle_event(ev);
}
int
main(int argc, char **argv)
{
DemoRunner demo;
return demo.main<ExamplePath>(argc, argv);
}