Checking out what libcaca is all about.
Last active
August 29, 2015 14:16
-
-
Save PeterHajdu/e644e2b2e0db81e6571c to your computer and use it in GitHub Desktop.
playing with libcaca
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <caca.h> | |
#include <thetime/clock.hpp> | |
#include <thetime/frequency_meter.hpp> | |
#include <thetime/frequency_stabilizer.hpp> | |
int main() | |
{ | |
if (caca_init()) | |
{ | |
std::cerr << "Failed to initialize caca." << std::endl; | |
return 1; | |
} | |
int event; | |
the::time::Clock clock; | |
the::time::FrequencyMeter< the::time::Clock > frequency_meter( clock ); | |
the::time::FrequencyStabilizer< 60, the::time::Clock > frequency_stabilizer( clock ); | |
while (!(event = caca_get_event(CACA_EVENT_KEY_PRESS))) | |
{ | |
frequency_meter.tick(); | |
caca_set_color(CACA_COLOR_LIGHTGREEN, CACA_COLOR_BLACK ); | |
caca_printf( 0, 20, "dimensions: %d, %d", caca_get_width(), caca_get_height() ); | |
caca_set_color(CACA_COLOR_LIGHTBLUE, CACA_COLOR_BLACK ); | |
caca_printf( 0, 21, "fps: %f", frequency_meter.per_second() ); | |
caca_set_color(CACA_COLOR_LIGHTRED, CACA_COLOR_YELLOW ); | |
caca_draw_thin_line( 0,0,10,10 ); | |
caca_refresh(); | |
frequency_stabilizer.stabilize(); | |
} | |
caca_end(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment