# HG changeset patch # User John Tsiombikas # Date 1423063415 -7200 # Node ID 14e743b532896abb96d587d978305d1a6d6aa981 component system test diff -r 000000000000 -r 14e743b53289 src/comp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/comp.h Wed Feb 04 17:23:35 2015 +0200 @@ -0,0 +1,18 @@ +#ifndef COMP_H_ +#define COMP_H_ + +#include + +class Component { +public: + Component() {} + virtual ~Component() {} +}; + +class CompPRS : public Component { +public: + Vector3 pos, scale; + Quaternion rot; +}; + +#endif // COMP_H_ diff -r 000000000000 -r 14e743b53289 src/comp_phys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/comp_phys.h Wed Feb 04 17:23:35 2015 +0200 @@ -0,0 +1,20 @@ +#ifndef COMP_PHYS_H_ +#define COMP_PHYS_H_ + +#include +#include "comp.h" + +class CompRigid : public CompPRS { +public: + float mass, elast, friction; + Vector3 pos, vel; + + CompRigid() + { + mass = 1.0; + elast = 0.5; + friction = 0.0; + } +}; + +#endif // COMP_PHYS_H_ diff -r 000000000000 -r 14e743b53289 src/test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test.cc Wed Feb 04 17:23:35 2015 +0200 @@ -0,0 +1,95 @@ +#include +#include +#include + +#ifndef __APPLE__ +#include +#else +#include +#endif + +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 mouse(int bn, int st, int x, int y); +static void motion(int x, int y); + + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitWindowSize(800, 600); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + glutCreateWindow("component system test"); + + glutDisplayFunc(display); + glutIdleFunc(idle); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyb); + glutMouseFunc(mouse); + glutMotionFunc(motion); + + if(!init()) { + return 1; + } + atexit(cleanup); + + glutMainLoop(); + return 0; +} + +static bool init() +{ + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + + return true; +} + +static void cleanup() +{ +} + +static void display() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glutSwapBuffers(); + assert(glGetError() == GL_NO_ERROR); +} + +static void idle() +{ + glutPostRedisplay(); +} + +static void reshape(int x, int y) +{ + glViewport(0, 0, x, y); + + glMatrixMode(GL_PROJECION); + glLoadIdentity(); + gluPerspective(50.0, (float)x / (float)y, 0.5, 500.0); +} + +static void keyb(unsigned char key, int x, int y) +{ + switch(key) { + case 27: + exit(0); + } +} + +static int bnstate[16]; +static int prev_x, prev_y; + +static void mouse(int bn, int st, int x, int y) +{ +} + +static void motion(int x, int y) +{ +}