mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-12-21 08:29:25 +00:00
don't create the printer window until we need it
This commit is contained in:
parent
39fdffd9c4
commit
349120a419
@ -17,19 +17,8 @@ SDLPrinter::SDLPrinter()
|
|||||||
|
|
||||||
memset((void *)_hackyBitmap, 0, sizeof(_hackyBitmap));
|
memset((void *)_hackyBitmap, 0, sizeof(_hackyBitmap));
|
||||||
|
|
||||||
window = SDL_CreateWindow(WINDOWNAME,
|
window = NULL;
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
renderer = NULL;
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
|
||||||
WIDTH, HEIGHT,
|
|
||||||
SDL_WINDOW_SHOWN);
|
|
||||||
|
|
||||||
// SDL_RENDERER_SOFTWARE because, at least on my Mac, this has some
|
|
||||||
// serious issues with hardware accelerated drawing (flashing and
|
|
||||||
// crashing).
|
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
|
|
||||||
SDL_RenderClear(renderer); // clear it to the selected color
|
|
||||||
SDL_RenderPresent(renderer); // perform the render
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLPrinter::~SDLPrinter()
|
SDLPrinter::~SDLPrinter()
|
||||||
@ -41,6 +30,16 @@ void SDLPrinter::update()
|
|||||||
if (isDirty) {
|
if (isDirty) {
|
||||||
isDirty = false; // set early in case there's a race
|
isDirty = false; // set early in case there's a race
|
||||||
|
|
||||||
|
if (!window) {
|
||||||
|
window = SDL_CreateWindow(WINDOWNAME,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
WIDTH, HEIGHT,
|
||||||
|
SDL_WINDOW_SHOWN);
|
||||||
|
|
||||||
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
for (int y=0; y<HEIGHT; y++) {
|
for (int y=0; y<HEIGHT; y++) {
|
||||||
for (int x=0; x<WIDTH; x++) {
|
for (int x=0; x<WIDTH; x++) {
|
||||||
if (_hackyBitmap[y*WIDTH+x]) {
|
if (_hackyBitmap[y*WIDTH+x]) {
|
||||||
|
@ -35,7 +35,6 @@ class SDLPrinter : public PhysicalPrinter {
|
|||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
bool _hackyBitmap[WIDTH * HEIGHT];
|
bool _hackyBitmap[WIDTH * HEIGHT];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user