diff --git a/src/androidapp.cpp b/src/androidapp.cpp index d8cd4ccf..dbc5f537 100644 --- a/src/androidapp.cpp +++ b/src/androidapp.cpp @@ -51,7 +51,7 @@ Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env) Log::Info("initialising renderer"); Ticker::Setup(30.0f); - Video::Setup(vec2i(320, 200)); + Video::Setup(ivec2(320, 200)); new Interface(); new DebugFps(20, 20); @@ -62,7 +62,7 @@ Java_org_zoy_LolEngine_LolRenderer_nativeResize(JNIEnv* env, jobject thiz, jint w, jint h) { Log::Info("resizing to %i x %i", w, h); - Video::Setup(vec2i(w, h)); + Video::Setup(ivec2(w, h)); } extern "C" void @@ -93,7 +93,7 @@ extern "C" void Java_org_zoy_LolEngine_LolView_nativeMove(JNIEnv* env, jobject thiz, jint x, jint y) { - vec2i pos = vec2i(0, 479) + vec2i(x * 640, -y * 480) / Video::GetSize(); + ivec2 pos = ivec2(0, 479) + ivec2(x * 640, -y * 480) / Video::GetSize(); Input::SetMousePos(pos); } diff --git a/src/debug/quad.cpp b/src/debug/quad.cpp index 2bbf0ba9..7b94a5e6 100644 --- a/src/debug/quad.cpp +++ b/src/debug/quad.cpp @@ -167,8 +167,8 @@ void DebugQuad::TickDraw(float deltams) } /* Prepare our quad coordinates */ - vec2i const layout(5, 4); - data->step = vec2(2.0f, -2.0f) / (4 * layout + vec2i(1)); + ivec2 const layout(5, 4); + data->step = vec2(2.0f, -2.0f) / (4 * layout + ivec2(1)); data->orig = vec2(-1.0f, 1.0f) + data->step; data->aa = data->orig; data->bb = data->orig + 3.0f * data->step; diff --git a/src/debug/record.cpp b/src/debug/record.cpp index 73a57bfa..29a345dc 100644 --- a/src/debug/record.cpp +++ b/src/debug/record.cpp @@ -36,7 +36,7 @@ class DebugRecordData private: char const *path; - vec2i size; + ivec2 size; int fps; #if defined USE_PIPI pipi_sequence_t *sequence; @@ -71,7 +71,7 @@ void DebugRecord::TickDraw(float deltams) { Entity::TickDraw(deltams); - vec2i size = Video::GetSize(); + ivec2 size = Video::GetSize(); if (data->size != size) { diff --git a/src/eglapp.cpp b/src/eglapp.cpp index 961e0bf5..20a40593 100644 --- a/src/eglapp.cpp +++ b/src/eglapp.cpp @@ -48,7 +48,7 @@ private: * Public EglApp class */ -EglApp::EglApp(char const *title, vec2i res, float fps) : +EglApp::EglApp(char const *title, ivec2 res, float fps) : data(new EglAppData()) { #if defined USE_EGL @@ -149,7 +149,7 @@ EglApp::EglApp(char const *title, vec2i res, float fps) : /* Initialise everything */ Ticker::Setup(fps); - Video::Setup(vec2i(gwa.width, gwa.height)); + Video::Setup(ivec2(gwa.width, gwa.height)); Audio::Setup(2); #endif } diff --git a/src/eglapp.h b/src/eglapp.h index f279a824..7364d775 100644 --- a/src/eglapp.h +++ b/src/eglapp.h @@ -26,7 +26,7 @@ class EglAppData; class EglApp { public: - EglApp(char const *title, vec2i res, float fps); + EglApp(char const *title, ivec2 res, float fps); virtual ~EglApp(); void Run(); diff --git a/src/font.cpp b/src/font.cpp index 782de129..a54f4c2e 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -33,7 +33,7 @@ class FontData private: char *name; TileSet *tileset; - vec2i size; + ivec2 size; }; /* @@ -84,7 +84,7 @@ void Font::Print(vec3i pos, char const *str) } } -vec2i Font::GetSize() const +ivec2 Font::GetSize() const { return data->size; } diff --git a/src/font.h b/src/font.h index db2df2e5..730dd7de 100644 --- a/src/font.h +++ b/src/font.h @@ -37,7 +37,7 @@ protected: public: /* New methods */ void Print(vec3i pos, char const *str); - vec2i GetSize() const; + ivec2 GetSize() const; private: FontData *data; diff --git a/src/image.cpp b/src/image.cpp index a45ca447..cf9c5bba 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -48,7 +48,7 @@ class ImageData friend class Image; private: - vec2i size; + ivec2 size; Image::format_t format; #if defined __APPLE__ && defined __MACH__ @@ -94,7 +94,7 @@ Image::Image(char const *path) int w = CGImageGetWidth(image.CGImage); int h = CGImageGetHeight(image.CGImage); - data->size = vec2i(w, h); + data->size = ivec2(w, h); data->format = FORMAT_RGBA; CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); @@ -123,7 +123,7 @@ Image::Image(char const *path) exit(1); } - data->size = vec2i(data->img->w, data->img->h); + data->size = ivec2(data->img->w, data->img->h); data->format = data->img->format->Amask ? FORMAT_RGBA : FORMAT_RGB; #elif defined ANDROID_NDK jclass cls = g_env->GetObjectClass(g_ctx); @@ -258,7 +258,7 @@ Image::Image(char const *path) } /* Decode image */ - data->size = vec2i(info.imageWidth, info.imageHeight); + data->size = ivec2(info.imageWidth, info.imageHeight); data->format = FORMAT_RGBA; data->pixels = (uint8_t *)malloc(info.imageWidth * 4 * info.imageHeight); CellPngDecDataCtrlParam data_ctrl_param; @@ -311,7 +311,7 @@ Image::Image(char const *path) #endif } -vec2i Image::GetSize() const +ivec2 Image::GetSize() const { return data->size; } diff --git a/src/image.h b/src/image.h index 1e51df1f..458c4794 100644 --- a/src/image.h +++ b/src/image.h @@ -37,7 +37,7 @@ public: } format_t; - vec2i GetSize() const; + ivec2 GetSize() const; format_t GetFormat() const; void *GetData() const; diff --git a/src/input.cpp b/src/input.cpp index bf12bc05..82457d24 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -41,7 +41,7 @@ public: { } private: - vec2i mouse; + ivec2 mouse; vec3i buttons; static int const MAX_ENTITIES = 100; @@ -77,7 +77,7 @@ vec2 Input::GetAxis(int axis) return ret; } -vec2i Input::GetMousePos() +ivec2 Input::GetMousePos() { return data->mouse; } @@ -108,7 +108,7 @@ void Input::UntrackMouse(WorldEntity *e) } } -void Input::SetMousePos(vec2i coord) +void Input::SetMousePos(ivec2 coord) { data->mouse = coord; @@ -130,7 +130,7 @@ void Input::SetMousePos(vec2i coord) { if (data->entities[n] == top) { - data->entities[n]->mousepos = (vec2i)((vec3i)coord - top->bbox[0]); + data->entities[n]->mousepos = (ivec2)((vec3i)coord - top->bbox[0]); if (top != data->lastfocus) data->entities[n]->pressed = data->buttons; else @@ -138,7 +138,7 @@ void Input::SetMousePos(vec2i coord) } else { - data->entities[n]->mousepos = vec2i(-1); + data->entities[n]->mousepos = ivec2(-1); /* FIXME */ data->entities[n]->released = 0; data->entities[n]->pressed = 0; diff --git a/src/input.h b/src/input.h index 06bc59fd..a6142522 100644 --- a/src/input.h +++ b/src/input.h @@ -28,7 +28,7 @@ class Input public: /* These methods are general queries */ static vec2 GetAxis(int axis); - static vec2i GetMousePos(); + static ivec2 GetMousePos(); static vec3i GetMouseButtons(); /* Entities can subscribe to events */ @@ -36,7 +36,7 @@ public: static void UntrackMouse(WorldEntity *e); /* These methods are called by the underlying input listeners */ - static void SetMousePos(vec2i coord); + static void SetMousePos(ivec2 coord); static void SetMouseButton(int index); static void UnsetMouseButton(int index); }; diff --git a/src/matrix.h b/src/matrix.h index 26d11cf4..7bd46ff6 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -144,7 +144,7 @@ template struct Vec2 }; typedef Vec2 vec2; -typedef Vec2 vec2i; +typedef Vec2 ivec2; template struct Vec3 { diff --git a/src/ps3app.cpp b/src/ps3app.cpp index f17c88c1..992fbec1 100644 --- a/src/ps3app.cpp +++ b/src/ps3app.cpp @@ -49,7 +49,7 @@ private: * Public Ps3App class */ -Ps3App::Ps3App(char const *title, vec2i res, float fps) : +Ps3App::Ps3App(char const *title, ivec2 res, float fps) : data(new Ps3AppData()) { #if defined __CELLOS_LV2__ @@ -90,7 +90,7 @@ Ps3App::Ps3App(char const *title, vec2i res, float fps) : GL_MULTISAMPLING_4X_SQUARE_ROTATED_SCE); GLuint w, h; psglGetDeviceDimensions(psgl, &w, &h); - res = vec2i(w, h); + res = ivec2(w, h); PSGLcontext *ctx = psglCreateContext(); psglMakeCurrent(ctx, psgl); diff --git a/src/ps3app.h b/src/ps3app.h index 22ad8a9d..2fbf1f3e 100644 --- a/src/ps3app.h +++ b/src/ps3app.h @@ -26,7 +26,7 @@ class Ps3AppData; class Ps3App { public: - Ps3App(char const *title, vec2i res, float fps); + Ps3App(char const *title, ivec2 res, float fps); virtual ~Ps3App(); void Run(); diff --git a/src/ps3input.cpp b/src/ps3input.cpp index 761a6d69..8a1ea132 100644 --- a/src/ps3input.cpp +++ b/src/ps3input.cpp @@ -110,7 +110,7 @@ void Ps3Input::TickGame(float deltams) vec2 delta(4e-3f * (abs(x - 127) < 16 ? 0 : x - 127), -4e-3f * (abs(y - 127) < 16 ? 0 : y - 127)); data->mousepos += delta * deltams; - Input::SetMousePos((vec2i)data->mousepos); + Input::SetMousePos((ivec2)data->mousepos); } /* L1 or R1 for mouse button */ diff --git a/src/sdlapp.cpp b/src/sdlapp.cpp index 227d3d0a..86047f18 100644 --- a/src/sdlapp.cpp +++ b/src/sdlapp.cpp @@ -39,7 +39,7 @@ private: * Public SdlApp class */ -SdlApp::SdlApp(char const *title, vec2i res, float fps) : +SdlApp::SdlApp(char const *title, ivec2 res, float fps) : data(new SdlAppData()) { #if defined USE_SDL @@ -65,7 +65,7 @@ SdlApp::SdlApp(char const *title, vec2i res, float fps) : /* Initialise everything */ Ticker::Setup(fps); - Video::Setup(vec2i(video->w, video->h)); + Video::Setup(ivec2(video->w, video->h)); Audio::Setup(2); #endif } diff --git a/src/sdlapp.h b/src/sdlapp.h index de7091a7..f7ec1b39 100644 --- a/src/sdlapp.h +++ b/src/sdlapp.h @@ -26,7 +26,7 @@ class SdlAppData; class SdlApp { public: - SdlApp(char const *title, vec2i res, float fps); + SdlApp(char const *title, ivec2 res, float fps); virtual ~SdlApp(); void Run(); diff --git a/src/sdlinput.cpp b/src/sdlinput.cpp index ad2e6892..e917dc30 100644 --- a/src/sdlinput.cpp +++ b/src/sdlinput.cpp @@ -31,7 +31,7 @@ class SdlInputData friend class SdlInput; private: - static vec2i GetMousePos(); + static ivec2 GetMousePos(); }; /* @@ -54,7 +54,7 @@ void SdlInput::TickGame(float deltams) Entity::TickGame(deltams); /* Handle mouse input */ - vec2i mouse = SdlInputData::GetMousePos();; + ivec2 mouse = SdlInputData::GetMousePos();; Input::SetMousePos(mouse); /* Handle keyboard and WM events */ @@ -74,7 +74,7 @@ void SdlInput::TickGame(float deltams) case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { - vec2i newmouse = SdlInputData::GetMousePos(); + ivec2 newmouse = SdlInputData::GetMousePos(); if (newmouse != mouse) Input::SetMousePos(mouse = newmouse); if (event.type == SDL_MOUSEBUTTONDOWN) @@ -101,9 +101,9 @@ SdlInput::~SdlInput() delete data; } -vec2i SdlInputData::GetMousePos() +ivec2 SdlInputData::GetMousePos() { - vec2i ret(-1, -1); + ivec2 ret(-1, -1); #if defined USE_SDL if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) diff --git a/src/tiler.cpp b/src/tiler.cpp index 653f94ea..07490374 100644 --- a/src/tiler.cpp +++ b/src/tiler.cpp @@ -40,7 +40,7 @@ static TilerData * const data = &tilerdata; * Public Tiler class */ -TileSet *Tiler::Register(char const *path, vec2i size, vec2i count, +TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count, float dilate) { int id = data->tilesets.MakeSlot(path); diff --git a/src/tiler.h b/src/tiler.h index 856516a1..90e2d083 100644 --- a/src/tiler.h +++ b/src/tiler.h @@ -27,7 +27,7 @@ namespace lol class Tiler { public: - static TileSet *Register(char const *path, vec2i size, vec2i count, + static TileSet *Register(char const *path, ivec2 size, ivec2 count, float dilate); static void Deregister(TileSet *); }; diff --git a/src/tileset.cpp b/src/tileset.cpp index c5e7a0d3..7d327880 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -41,7 +41,7 @@ class TileSetData private: char *name, *path; int *tiles, ntiles; - vec2i size, isize, count; + ivec2 size, isize, count; float dilate, tx, ty; Image *img; @@ -52,7 +52,7 @@ private: * Public TileSet class */ -TileSet::TileSet(char const *path, vec2i size, vec2i count, float dilate) +TileSet::TileSet(char const *path, ivec2 size, ivec2 count, float dilate) : data(new TileSetData()) { data->name = (char *)malloc(10 + strlen(path) + 1); @@ -159,12 +159,12 @@ char const *TileSet::GetName() return data->name; } -vec2i TileSet::GetCount() const +ivec2 TileSet::GetCount() const { return data->count; } -vec2i TileSet::GetSize(int tileid) const +ivec2 TileSet::GetSize(int tileid) const { return data->size; } diff --git a/src/tileset.h b/src/tileset.h index 0c805e8b..e839e6ca 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -31,7 +31,7 @@ class TileSetData; class TileSet : public Entity { public: - TileSet(char const *path, vec2i size, vec2i count, float dilate); + TileSet(char const *path, ivec2 size, ivec2 count, float dilate); virtual ~TileSet(); protected: @@ -41,8 +41,8 @@ protected: public: /* New methods */ - vec2i GetCount() const; - vec2i GetSize(int tileid) const; + ivec2 GetCount() const; + ivec2 GetSize(int tileid) const; void Bind(); void BlitTile(uint32_t id, vec3i pos, int o, float *vertex, float *texture); diff --git a/src/video.cpp b/src/video.cpp index 2d1c82d3..6a6e6192 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -34,7 +34,7 @@ class VideoData private: static mat4 proj_matrix, view_matrix; #if defined ANDROID_NDK || defined __CELLOS_LV2__ - static vec2i saved_viewport; + static ivec2 saved_viewport; #endif }; @@ -42,14 +42,14 @@ mat4 VideoData::proj_matrix; mat4 VideoData::view_matrix; #if defined ANDROID_NDK || defined __CELLOS_LV2__ -vec2i VideoData::saved_viewport = 0; +ivec2 VideoData::saved_viewport = 0; #endif /* * Public Video class */ -void Video::Setup(vec2i size) +void Video::Setup(ivec2 size) { #if defined USE_GLEW /* Initialise GLEW if necessary */ @@ -132,7 +132,7 @@ void Video::SetDepth(bool set) void Video::Clear() { - vec2i size = GetSize(); + ivec2 size = GetSize(); glViewport(0, 0, size.x, size.y); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -176,7 +176,7 @@ void Video::Capture(uint32_t *buffer) } } -vec2i Video::GetSize() +ivec2 Video::GetSize() { #if defined ANDROID_NDK return VideoData::saved_viewport; @@ -186,7 +186,7 @@ vec2i Video::GetSize() #else GLint v[4]; glGetIntegerv(GL_VIEWPORT, v); - return vec2i(v[2], v[3]); + return ivec2(v[2], v[3]); #endif } diff --git a/src/video.h b/src/video.h index d464e22a..d41455f8 100644 --- a/src/video.h +++ b/src/video.h @@ -25,13 +25,13 @@ namespace lol class Video { public: - static void Setup(vec2i size); + static void Setup(ivec2 size); static void Destroy(); static void SetFov(float theta); static void SetDepth(bool set); static void Clear(); static void Capture(uint32_t *buffer); - static vec2i GetSize(); + static ivec2 GetSize(); static mat4 const & GetProjMatrix(); static mat4 const & GetViewMatrix(); }; diff --git a/src/worldentity.h b/src/worldentity.h index 9791b7fe..fca7c039 100644 --- a/src/worldentity.h +++ b/src/worldentity.h @@ -29,7 +29,7 @@ public: vec3 velocity; vec3 bbox[2]; - vec2i mousepos; + ivec2 mousepos; vec3i mousebuttons; vec3i pressed, clicked, released; diff --git a/test/debug/quad.cpp b/test/debug/quad.cpp index 6165c74b..56f20b21 100644 --- a/test/debug/quad.cpp +++ b/test/debug/quad.cpp @@ -35,11 +35,11 @@ using namespace lol; int main(int argc, char **argv) { #if defined __CELLOS_LV2__ - Ps3App app("Quad", vec2i(640, 480), 60.0f); + Ps3App app("Quad", ivec2(640, 480), 60.0f); #elif defined HAVE_GLES_2X - EglApp app("Quad", vec2i(640, 480), 60.0f); + EglApp app("Quad", ivec2(640, 480), 60.0f); #else - SdlApp app("Quad", vec2i(640, 480), 60.0f); + SdlApp app("Quad", ivec2(640, 480), 60.0f); #endif /* Register an input driver and some debug stuff */