# HG changeset patch # User John Tsiombikas # Date 1398393849 -10800 # Node ID 879194e4b1f0e048d31117e57a509a0a7921f21a # Parent cd7755e4663a4dcfba599b3d31e0b29876f4ba97 fixed line-endings diff -r cd7755e4663a -r 879194e4b1f0 src/game.cc --- a/src/game.cc Fri Apr 25 05:43:26 2014 +0300 +++ b/src/game.cc Fri Apr 25 05:44:09 2014 +0300 @@ -1,180 +1,180 @@ -#include "game.h" -#include "opengl.h" -#include "camera.h" -#include "texture.h" -//#include "OVR_CAPI_GL.h" - -static void draw_scene(); - -static const float move_speed = 10.0f; - -static int fb_width, fb_height; -static FlyCamera cam; -static Texture floor_tex; -static bool keystate[256]; - -bool game_init() -{ - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - glClearColor(0.1, 0.1, 0.1, 1); - - if(!floor_tex.load("data/tiles.png")) { - return false; - } - - cam.input_move(0, 0, 5); - return true; -} - -void game_cleanup() -{ - floor_tex.destroy(); -} - - -void game_update(unsigned int msec) -{ - static unsigned int prev_msec; - float dt = (msec - prev_msec) / 1000.0f; - float offs = dt * move_speed; - prev_msec = msec; - - Vector3 move; - float roll = 0.0f; - - if(keystate['d'] || keystate['D']) { - move.x += offs; - } - if(keystate['a'] || keystate['A']) { - move.x -= offs; - } - if(keystate['s'] || keystate['S']) { - move.z += offs; - } - if(keystate['w'] || keystate['W']) { - move.z -= offs; - } - if(keystate['e'] || keystate['E']) { - roll += dt; - } - if(keystate['q'] || keystate['Q']) { - roll -= dt; - } - - cam.input_move(move.x, move.y, move.z); - cam.input_rotate(0, 0, roll); -} - -void game_render(int eye) -{ - Matrix4x4 view_matrix = cam.get_matrix().inverse(); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, (float)fb_width / (float)fb_height, 0.5, 500.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glLoadTransposeMatrixf(view_matrix[0]); - - draw_scene(); -} - -void game_reshape(int x, int y) -{ - glViewport(0, 0, x, y); - fb_width = x; - fb_height = y; -} - -void game_keyboard(int key, bool pressed, int x, int y) -{ - if(pressed) { - switch(key) { - case 27: - exit(0); - } - } - - if(key < 256) { - keystate[key] = pressed; - } -} - -static int prev_x, prev_y; -static bool bnstate[32]; - -void game_mouse(int bn, bool pressed, int x, int y) -{ - bnstate[bn] = pressed; - prev_x = x; - prev_y = y; -} - -void game_motion(int x, int y) -{ - int dx = x - prev_x; - int dy = y - prev_y; - prev_x = x; - prev_y = y; - - if(!dx && !dy) return; - - if(bnstate[0]) { - float xrot = dy * 0.5; - float yrot = dx * 0.5; - cam.input_rotate(DEG_TO_RAD(xrot), 0, 0); - cam.input_rotate(0, DEG_TO_RAD(yrot), 0); - } -} - -void game_6dof_move(float x, float y, float z) -{ - cam.input_move(x, y, z); -} - -void game_6dof_rotate(float x, float y, float z) -{ - cam.input_rotate(x, y, z); -} - -static void draw_scene() -{ - glMatrixMode(GL_MODELVIEW); - glTranslatef(0, -1.5, 0); - - float lpos[] = {-20, 30, 10, 1}; - glLightfv(GL_LIGHT0, GL_POSITION, lpos); - - glEnable(GL_TEXTURE_2D); - floor_tex.bind(); - - glMatrixMode(GL_TEXTURE); - glScalef(8, 8, 8); - - glBegin(GL_QUADS); - glNormal3f(0, 1, 0); - glTexCoord2f(0, 0); glVertex3f(-25, 0, 25); - glTexCoord2f(1, 0); glVertex3f(25, 0, 25); - glTexCoord2f(1, 1); glVertex3f(25, 0, -25); - glTexCoord2f(0, 1); glVertex3f(-25, 0, -25); - glEnd(); - glDisable(GL_TEXTURE_2D); - glLoadIdentity(); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslatef(0, 0.75, 0); - - glFrontFace(GL_CW); - glutSolidTeapot(1.0); - glFrontFace(GL_CCW); - - glPopMatrix(); -} +#include "game.h" +#include "opengl.h" +#include "camera.h" +#include "texture.h" +//#include "OVR_CAPI_GL.h" + +static void draw_scene(); + +static const float move_speed = 10.0f; + +static int fb_width, fb_height; +static FlyCamera cam; +static Texture floor_tex; +static bool keystate[256]; + +bool game_init() +{ + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glClearColor(0.1, 0.1, 0.1, 1); + + if(!floor_tex.load("data/tiles.png")) { + return false; + } + + cam.input_move(0, 0, 5); + return true; +} + +void game_cleanup() +{ + floor_tex.destroy(); +} + + +void game_update(unsigned int msec) +{ + static unsigned int prev_msec; + float dt = (msec - prev_msec) / 1000.0f; + float offs = dt * move_speed; + prev_msec = msec; + + Vector3 move; + float roll = 0.0f; + + if(keystate['d'] || keystate['D']) { + move.x += offs; + } + if(keystate['a'] || keystate['A']) { + move.x -= offs; + } + if(keystate['s'] || keystate['S']) { + move.z += offs; + } + if(keystate['w'] || keystate['W']) { + move.z -= offs; + } + if(keystate['e'] || keystate['E']) { + roll += dt; + } + if(keystate['q'] || keystate['Q']) { + roll -= dt; + } + + cam.input_move(move.x, move.y, move.z); + cam.input_rotate(0, 0, roll); +} + +void game_render(int eye) +{ + Matrix4x4 view_matrix = cam.get_matrix().inverse(); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, (float)fb_width / (float)fb_height, 0.5, 500.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glLoadTransposeMatrixf(view_matrix[0]); + + draw_scene(); +} + +void game_reshape(int x, int y) +{ + glViewport(0, 0, x, y); + fb_width = x; + fb_height = y; +} + +void game_keyboard(int key, bool pressed, int x, int y) +{ + if(pressed) { + switch(key) { + case 27: + exit(0); + } + } + + if(key < 256) { + keystate[key] = pressed; + } +} + +static int prev_x, prev_y; +static bool bnstate[32]; + +void game_mouse(int bn, bool pressed, int x, int y) +{ + bnstate[bn] = pressed; + prev_x = x; + prev_y = y; +} + +void game_motion(int x, int y) +{ + int dx = x - prev_x; + int dy = y - prev_y; + prev_x = x; + prev_y = y; + + if(!dx && !dy) return; + + if(bnstate[0]) { + float xrot = dy * 0.5; + float yrot = dx * 0.5; + cam.input_rotate(DEG_TO_RAD(xrot), 0, 0); + cam.input_rotate(0, DEG_TO_RAD(yrot), 0); + } +} + +void game_6dof_move(float x, float y, float z) +{ + cam.input_move(x, y, z); +} + +void game_6dof_rotate(float x, float y, float z) +{ + cam.input_rotate(x, y, z); +} + +static void draw_scene() +{ + glMatrixMode(GL_MODELVIEW); + glTranslatef(0, -1.5, 0); + + float lpos[] = {-20, 30, 10, 1}; + glLightfv(GL_LIGHT0, GL_POSITION, lpos); + + glEnable(GL_TEXTURE_2D); + floor_tex.bind(); + + glMatrixMode(GL_TEXTURE); + glScalef(8, 8, 8); + + glBegin(GL_QUADS); + glNormal3f(0, 1, 0); + glTexCoord2f(0, 0); glVertex3f(-25, 0, 25); + glTexCoord2f(1, 0); glVertex3f(25, 0, 25); + glTexCoord2f(1, 1); glVertex3f(25, 0, -25); + glTexCoord2f(0, 1); glVertex3f(-25, 0, -25); + glEnd(); + glDisable(GL_TEXTURE_2D); + glLoadIdentity(); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glTranslatef(0, 0.75, 0); + + glFrontFace(GL_CW); + glutSolidTeapot(1.0); + glFrontFace(GL_CCW); + + glPopMatrix(); +} diff -r cd7755e4663a -r 879194e4b1f0 src/game.h --- a/src/game.h Fri Apr 25 05:43:26 2014 +0300 +++ b/src/game.h Fri Apr 25 05:44:09 2014 +0300 @@ -1,18 +1,18 @@ -#ifndef GAME_H_ -#define GAME_H_ - -bool game_init(); -void game_cleanup(); - -void game_update(unsigned int msec); -void game_render(int eye); - -void game_reshape(int x, int y); -void game_keyboard(int key, bool pressed, int x, int y); -void game_mouse(int bn, bool pressed, int x, int y); -void game_motion(int x, int y); - -void game_6dof_move(float x, float y, float z); -void game_6dof_rotate(float x, float y, float z); - -#endif // GAME_H_ \ No newline at end of file +#ifndef GAME_H_ +#define GAME_H_ + +bool game_init(); +void game_cleanup(); + +void game_update(unsigned int msec); +void game_render(int eye); + +void game_reshape(int x, int y); +void game_keyboard(int key, bool pressed, int x, int y); +void game_mouse(int bn, bool pressed, int x, int y); +void game_motion(int x, int y); + +void game_6dof_move(float x, float y, float z); +void game_6dof_rotate(float x, float y, float z); + +#endif // GAME_H_ diff -r cd7755e4663a -r 879194e4b1f0 src/image.cc --- a/src/image.cc Fri Apr 25 05:43:26 2014 +0300 +++ b/src/image.cc Fri Apr 25 05:44:09 2014 +0300 @@ -1,94 +1,94 @@ -#include -#include "imago2.h" -#include "image.h" - -Image::Image() -{ - pixels = 0; - own_pixels = true; - width = height = 0; -} - -Image::~Image() -{ - destroy(); -} - -Image::Image(const Image &img) -{ - pixels = 0; - own_pixels = false; - - create(img.width, img.height, img.pixels); -} - -Image &Image::operator =(const Image &img) -{ - if(this != &img) { - destroy(); - create(img.width, img.height, img.pixels); - } - return *this; -} - -void Image::create(int xsz, int ysz, unsigned char *pixels) -{ - destroy(); - - this->pixels = new unsigned char[xsz * ysz * 4]; - if(pixels) { - memcpy(this->pixels, pixels, xsz * ysz * 4); - } else { - memset(this->pixels, 0, xsz * ysz * 4); - } - width = xsz; - height = ysz; - own_pixels = true; -} - -void Image::destroy() -{ - if(own_pixels) { - delete [] pixels; - } - pixels = 0; - width = height = 0; - own_pixels = true; -} - -int Image::get_width() const -{ - return width; -} - -int Image::get_height() const -{ - return height; -} - -void Image::set_pixels(int xsz, int ysz, unsigned char *pixels) -{ - destroy(); - - this->pixels = pixels; - width = xsz; - height = ysz; - own_pixels = false; -} - -unsigned char *Image::get_pixels() const -{ - return pixels; -} - -bool Image::load(const char *fname) -{ - int xsz, ysz; - unsigned char *pix = (unsigned char*)img_load_pixels(fname, &xsz, &ysz); - if(!pix) { - return false; - } - - create(xsz, ysz, pix); - return true; -} \ No newline at end of file +#include +#include "imago2.h" +#include "image.h" + +Image::Image() +{ + pixels = 0; + own_pixels = true; + width = height = 0; +} + +Image::~Image() +{ + destroy(); +} + +Image::Image(const Image &img) +{ + pixels = 0; + own_pixels = false; + + create(img.width, img.height, img.pixels); +} + +Image &Image::operator =(const Image &img) +{ + if(this != &img) { + destroy(); + create(img.width, img.height, img.pixels); + } + return *this; +} + +void Image::create(int xsz, int ysz, unsigned char *pixels) +{ + destroy(); + + this->pixels = new unsigned char[xsz * ysz * 4]; + if(pixels) { + memcpy(this->pixels, pixels, xsz * ysz * 4); + } else { + memset(this->pixels, 0, xsz * ysz * 4); + } + width = xsz; + height = ysz; + own_pixels = true; +} + +void Image::destroy() +{ + if(own_pixels) { + delete [] pixels; + } + pixels = 0; + width = height = 0; + own_pixels = true; +} + +int Image::get_width() const +{ + return width; +} + +int Image::get_height() const +{ + return height; +} + +void Image::set_pixels(int xsz, int ysz, unsigned char *pixels) +{ + destroy(); + + this->pixels = pixels; + width = xsz; + height = ysz; + own_pixels = false; +} + +unsigned char *Image::get_pixels() const +{ + return pixels; +} + +bool Image::load(const char *fname) +{ + int xsz, ysz; + unsigned char *pix = (unsigned char*)img_load_pixels(fname, &xsz, &ysz); + if(!pix) { + return false; + } + + create(xsz, ysz, pix); + return true; +} diff -r cd7755e4663a -r 879194e4b1f0 src/image.h --- a/src/image.h Fri Apr 25 05:43:26 2014 +0300 +++ b/src/image.h Fri Apr 25 05:44:09 2014 +0300 @@ -1,29 +1,29 @@ -#ifndef IMAGE_H_ -#define IMAGE_H_ - -class Image { -private: - int width, height; - unsigned char *pixels; - bool own_pixels; - -public: - Image(); - ~Image(); - - Image(const Image &img); - Image &operator =(const Image &img); - - void create(int xsz, int ysz, unsigned char *pix = 0); - void destroy(); - - int get_width() const; - int get_height() const; - - void set_pixels(int xsz, int ysz, unsigned char *pix); - unsigned char *get_pixels() const; - - bool load(const char *fname); -}; - -#endif // IMAGE_H_ \ No newline at end of file +#ifndef IMAGE_H_ +#define IMAGE_H_ + +class Image { +private: + int width, height; + unsigned char *pixels; + bool own_pixels; + +public: + Image(); + ~Image(); + + Image(const Image &img); + Image &operator =(const Image &img); + + void create(int xsz, int ysz, unsigned char *pix = 0); + void destroy(); + + int get_width() const; + int get_height() const; + + void set_pixels(int xsz, int ysz, unsigned char *pix); + unsigned char *get_pixels() const; + + bool load(const char *fname); +}; + +#endif // IMAGE_H_ diff -r cd7755e4663a -r 879194e4b1f0 src/main.cc --- a/src/main.cc Fri Apr 25 05:43:26 2014 +0300 +++ b/src/main.cc Fri Apr 25 05:44:09 2014 +0300 @@ -1,111 +1,111 @@ -#include -#include -#include "opengl.h" -#include "game.h" - -static bool init(); -static void cleanup(); - -static void display(); -static void idle(); -static void reshape(int x, int y); -static void keyb(unsigned char key, int x, int y); -static void keyb_up(unsigned char key, int x, int y); -static void mouse(int bn, int st, int x, int y); -static void motion(int x, int y); -static void sball_motion(int x, int y, int z); -static void sball_rotate(int x, int y, int z); - -int main(int argc, char **argv) -{ - glutInitWindowSize(1024, 600); - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - glutCreateWindow("VR Chess"); - - glutDisplayFunc(display); - glutIdleFunc(idle); - glutReshapeFunc(reshape); - glutKeyboardFunc(keyb); - glutKeyboardUpFunc(keyb_up); - glutMouseFunc(mouse); - glutMotionFunc(motion); - glutSpaceballMotionFunc(sball_motion); - glutSpaceballRotateFunc(sball_rotate); - - if(!init()) { - return 1; - } - atexit(cleanup); - - glutMainLoop(); - return 0; -} - -static bool init() -{ - glewInit(); - - if(!game_init()) { - return false; - } - return true; -} - -static void cleanup() -{ - game_cleanup(); -} - -static void display() -{ - unsigned int msec = glutGet(GLUT_ELAPSED_TIME); - - game_update(msec); - game_render(0); - - glutSwapBuffers(); -} - -static void idle() -{ - glutPostRedisplay(); -} - -static void reshape(int x, int y) -{ - game_reshape(x, y); -} - -static void keyb(unsigned char key, int x, int y) -{ - game_keyboard(key, true, x, y); -} - -static void keyb_up(unsigned char key, int x, int y) -{ - game_keyboard(key, false, x, y); -} - -static void mouse(int bn, int st, int x, int y) -{ - game_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y); -} - -static void motion(int x, int y) -{ - game_motion(x, y); -} - -#define SBALL_MOVE_SCALE 0.00025 -#define SBALL_ROT_SCALE 0.01 - -static void sball_motion(int x, int y, int z) -{ - game_6dof_move(x * SBALL_MOVE_SCALE, y * SBALL_MOVE_SCALE, z * SBALL_MOVE_SCALE); -} - -static void sball_rotate(int x, int y, int z) -{ - game_6dof_rotate(x * SBALL_ROT_SCALE, y * SBALL_ROT_SCALE, z * SBALL_ROT_SCALE); -} \ No newline at end of file +#include +#include +#include "opengl.h" +#include "game.h" + +static bool init(); +static void cleanup(); + +static void display(); +static void idle(); +static void reshape(int x, int y); +static void keyb(unsigned char key, int x, int y); +static void keyb_up(unsigned char key, int x, int y); +static void mouse(int bn, int st, int x, int y); +static void motion(int x, int y); +static void sball_motion(int x, int y, int z); +static void sball_rotate(int x, int y, int z); + +int main(int argc, char **argv) +{ + glutInitWindowSize(1024, 600); + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + glutCreateWindow("VR Chess"); + + glutDisplayFunc(display); + glutIdleFunc(idle); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyb); + glutKeyboardUpFunc(keyb_up); + glutMouseFunc(mouse); + glutMotionFunc(motion); + glutSpaceballMotionFunc(sball_motion); + glutSpaceballRotateFunc(sball_rotate); + + if(!init()) { + return 1; + } + atexit(cleanup); + + glutMainLoop(); + return 0; +} + +static bool init() +{ + glewInit(); + + if(!game_init()) { + return false; + } + return true; +} + +static void cleanup() +{ + game_cleanup(); +} + +static void display() +{ + unsigned int msec = glutGet(GLUT_ELAPSED_TIME); + + game_update(msec); + game_render(0); + + glutSwapBuffers(); +} + +static void idle() +{ + glutPostRedisplay(); +} + +static void reshape(int x, int y) +{ + game_reshape(x, y); +} + +static void keyb(unsigned char key, int x, int y) +{ + game_keyboard(key, true, x, y); +} + +static void keyb_up(unsigned char key, int x, int y) +{ + game_keyboard(key, false, x, y); +} + +static void mouse(int bn, int st, int x, int y) +{ + game_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y); +} + +static void motion(int x, int y) +{ + game_motion(x, y); +} + +#define SBALL_MOVE_SCALE 0.00025 +#define SBALL_ROT_SCALE 0.01 + +static void sball_motion(int x, int y, int z) +{ + game_6dof_move(x * SBALL_MOVE_SCALE, y * SBALL_MOVE_SCALE, z * SBALL_MOVE_SCALE); +} + +static void sball_rotate(int x, int y, int z) +{ + game_6dof_rotate(x * SBALL_ROT_SCALE, y * SBALL_ROT_SCALE, z * SBALL_ROT_SCALE); +} diff -r cd7755e4663a -r 879194e4b1f0 src/texture.cc --- a/src/texture.cc Fri Apr 25 05:43:26 2014 +0300 +++ b/src/texture.cc Fri Apr 25 05:44:09 2014 +0300 @@ -1,77 +1,77 @@ -#include "texture.h" -#include "opengl.h" - -Texture::Texture() -{ - tex = 0; - type = GL_TEXTURE_2D; -} - -Texture::~Texture() -{ - destroy(); -} - -void Texture::create2d(int xsz, int ysz) -{ - destroy(); - - type = GL_TEXTURE_2D; - img.create(xsz, ysz); - - if(!tex) { - glGenTextures(1, &tex); - } - glBindTexture(type, tex); - glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(type, 0, GL_RGBA, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); -} - -void Texture::destroy() -{ - if(tex) { - glDeleteTextures(1, &tex); - } -} - -void Texture::set_image(const Image &img) -{ - this->img = img; - create2d(img.get_width(), img.get_height()); - - glTexSubImage2D(type, 0, 0, 0, img.get_width(), img.get_height(), - GL_RGBA, GL_UNSIGNED_BYTE, img.get_pixels()); -} - -Image &Texture::get_image() -{ - return img; -} - -const Image &Texture::get_image() const -{ - return img; -} - -unsigned int Texture::get_texture_id() const -{ - return tex; -} - -void Texture::bind(int tunit) const -{ - glActiveTextureARB(GL_TEXTURE0_ARB + tunit); - glBindTexture(type, tex); - glActiveTextureARB(GL_TEXTURE0_ARB); -} - -bool Texture::load(const char *fname) -{ - Image image; - if(!image.load(fname)) { - return false; - } - set_image(image); - return true; -} \ No newline at end of file +#include "texture.h" +#include "opengl.h" + +Texture::Texture() +{ + tex = 0; + type = GL_TEXTURE_2D; +} + +Texture::~Texture() +{ + destroy(); +} + +void Texture::create2d(int xsz, int ysz) +{ + destroy(); + + type = GL_TEXTURE_2D; + img.create(xsz, ysz); + + if(!tex) { + glGenTextures(1, &tex); + } + glBindTexture(type, tex); + glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(type, 0, GL_RGBA, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); +} + +void Texture::destroy() +{ + if(tex) { + glDeleteTextures(1, &tex); + } +} + +void Texture::set_image(const Image &img) +{ + this->img = img; + create2d(img.get_width(), img.get_height()); + + glTexSubImage2D(type, 0, 0, 0, img.get_width(), img.get_height(), + GL_RGBA, GL_UNSIGNED_BYTE, img.get_pixels()); +} + +Image &Texture::get_image() +{ + return img; +} + +const Image &Texture::get_image() const +{ + return img; +} + +unsigned int Texture::get_texture_id() const +{ + return tex; +} + +void Texture::bind(int tunit) const +{ + glActiveTextureARB(GL_TEXTURE0_ARB + tunit); + glBindTexture(type, tex); + glActiveTextureARB(GL_TEXTURE0_ARB); +} + +bool Texture::load(const char *fname) +{ + Image image; + if(!image.load(fname)) { + return false; + } + set_image(image); + return true; +} diff -r cd7755e4663a -r 879194e4b1f0 src/texture.h --- a/src/texture.h Fri Apr 25 05:43:26 2014 +0300 +++ b/src/texture.h Fri Apr 25 05:44:09 2014 +0300 @@ -1,29 +1,29 @@ -#ifndef TEXTURE_H_ -#define TEXTURE_H_ - -#include "image.h" - -class Texture { -private: - Image img; - unsigned int tex; - unsigned int type; - -public: - Texture(); - ~Texture(); - - void create2d(int xsz, int ysz); - void destroy(); - - void set_image(const Image &img); - Image &get_image(); - const Image &get_image() const; - - unsigned int get_texture_id() const; - void bind(int tunit = 0) const; - - bool load(const char *fname); -}; - -#endif // TEXTURE_H_ \ No newline at end of file +#ifndef TEXTURE_H_ +#define TEXTURE_H_ + +#include "image.h" + +class Texture { +private: + Image img; + unsigned int tex; + unsigned int type; + +public: + Texture(); + ~Texture(); + + void create2d(int xsz, int ysz); + void destroy(); + + void set_image(const Image &img); + Image &get_image(); + const Image &get_image() const; + + unsigned int get_texture_id() const; + void bind(int tunit = 0) const; + + bool load(const char *fname); +}; + +#endif // TEXTURE_H_