Browse Source

core: rename vec2i to ivec2 etc. to better match GLSL.

legacy
Sam Hocevar sam 13 years ago
parent
commit
6bbe943492
26 changed files with 60 additions and 60 deletions
  1. +3
    -3
      src/androidapp.cpp
  2. +2
    -2
      src/debug/quad.cpp
  3. +2
    -2
      src/debug/record.cpp
  4. +2
    -2
      src/eglapp.cpp
  5. +1
    -1
      src/eglapp.h
  6. +2
    -2
      src/font.cpp
  7. +1
    -1
      src/font.h
  8. +5
    -5
      src/image.cpp
  9. +1
    -1
      src/image.h
  10. +5
    -5
      src/input.cpp
  11. +2
    -2
      src/input.h
  12. +1
    -1
      src/matrix.h
  13. +2
    -2
      src/ps3app.cpp
  14. +1
    -1
      src/ps3app.h
  15. +1
    -1
      src/ps3input.cpp
  16. +2
    -2
      src/sdlapp.cpp
  17. +1
    -1
      src/sdlapp.h
  18. +5
    -5
      src/sdlinput.cpp
  19. +1
    -1
      src/tiler.cpp
  20. +1
    -1
      src/tiler.h
  21. +4
    -4
      src/tileset.cpp
  22. +3
    -3
      src/tileset.h
  23. +6
    -6
      src/video.cpp
  24. +2
    -2
      src/video.h
  25. +1
    -1
      src/worldentity.h
  26. +3
    -3
      test/debug/quad.cpp

+ 3
- 3
src/androidapp.cpp View File

@@ -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);
}



+ 2
- 2
src/debug/quad.cpp View File

@@ -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;


+ 2
- 2
src/debug/record.cpp View File

@@ -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)
{


+ 2
- 2
src/eglapp.cpp View File

@@ -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
}


+ 1
- 1
src/eglapp.h View File

@@ -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();


+ 2
- 2
src/font.cpp View File

@@ -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;
}


+ 1
- 1
src/font.h View File

@@ -37,7 +37,7 @@ protected:
public:
/* New methods */
void Print(vec3i pos, char const *str);
vec2i GetSize() const;
ivec2 GetSize() const;

private:
FontData *data;


+ 5
- 5
src/image.cpp View File

@@ -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;
}


+ 1
- 1
src/image.h View File

@@ -37,7 +37,7 @@ public:
}
format_t;

vec2i GetSize() const;
ivec2 GetSize() const;
format_t GetFormat() const;
void *GetData() const;



+ 5
- 5
src/input.cpp View File

@@ -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;


+ 2
- 2
src/input.h View File

@@ -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);
};


+ 1
- 1
src/matrix.h View File

@@ -144,7 +144,7 @@ template <typename T> struct Vec2
};

typedef Vec2<float> vec2;
typedef Vec2<int> vec2i;
typedef Vec2<int> ivec2;

template <typename T> struct Vec3
{


+ 2
- 2
src/ps3app.cpp View File

@@ -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);


+ 1
- 1
src/ps3app.h View File

@@ -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();


+ 1
- 1
src/ps3input.cpp View File

@@ -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 */


+ 2
- 2
src/sdlapp.cpp View File

@@ -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
}


+ 1
- 1
src/sdlapp.h View File

@@ -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();


+ 5
- 5
src/sdlinput.cpp View File

@@ -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)


+ 1
- 1
src/tiler.cpp View File

@@ -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);


+ 1
- 1
src/tiler.h View File

@@ -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 *);
};


+ 4
- 4
src/tileset.cpp View File

@@ -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;
}


+ 3
- 3
src/tileset.h View File

@@ -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);


+ 6
- 6
src/video.cpp View File

@@ -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
}



+ 2
- 2
src/video.h View File

@@ -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();
};


+ 1
- 1
src/worldentity.h View File

@@ -29,7 +29,7 @@ public:
vec3 velocity;
vec3 bbox[2];

vec2i mousepos;
ivec2 mousepos;
vec3i mousebuttons;
vec3i pressed, clicked, released;



+ 3
- 3
test/debug/quad.cpp View File

@@ -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 */


Loading…
Cancel
Save