[ion] Fix the emscripten build

Change-Id: Ia54c5de4191c47d9840854d9aad12f87a9110da3
This commit is contained in:
Romain Goyet
2017-05-15 22:04:37 +02:00
parent 739c362ff0
commit a1552b2fa1
15 changed files with 226 additions and 135 deletions

View File

@@ -0,0 +1,56 @@
#include "display.h"
extern "C" {
#include <SDL/SDL.h>
#include <assert.h>
}
SDL_Surface * screen = nullptr;
namespace Ion {
namespace Display {
void pushRect(KDRect r, const KDColor * pixels) {
if (SDL_MUSTLOCK(screen)) {
SDL_LockSurface(screen);
}
int pixelNumber = 0;
for (int j=r.top(); j<r.bottom(); j++) {
for (int i=r.left(); i<r.right(); i++) {
KDColor c = pixels[pixelNumber++];
*((Uint32*)screen->pixels + j * Ion::Display::Width + i) = SDL_MapRGB(screen->format, c.red(), c.green(), c.blue());
}
}
if (SDL_MUSTLOCK(screen)) {
SDL_UnlockSurface(screen);
}
SDL_UpdateRect(screen, r.x(), r.y(), r.width(), r.height());
}
void pushRectUniform(KDRect r, KDColor c) {
Uint32 sdlColor = SDL_MapRGB(screen->format, c.red(), c.green(), c.blue());
SDL_Rect sdlRect = { r.x(), r.y(), r.width(), r.height() };
SDL_FillRect(screen, &sdlRect, sdlColor);
SDL_UpdateRect(screen, r.x(), r.y(), r.width(), r.height());
}
void pullRect(KDRect r, KDColor * pixels) {
}
void waitForVBlank() {
}
}
}
namespace Ion {
namespace Display {
namespace Emscripten {
void init() {
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(Ion::Display::Width, Ion::Display::Height, 32, SDL_HWSURFACE);
}
}
}
}