[d02c25f] | 1 | #ifndef _OPENGL_GAME_H
|
---|
| 2 | #define _OPENGL_GAME_H
|
---|
| 3 |
|
---|
[83b5b4b] | 4 | #include <glm/glm.hpp>
|
---|
| 5 |
|
---|
[d8cf709] | 6 | // TODO: Rewrite this to work with the new version of IMGUI
|
---|
[f133da0] | 7 | #include "IMGUI/imgui.h"
|
---|
| 8 | #include "imgui_impl_glfw_gl3.h"
|
---|
| 9 |
|
---|
[d02c25f] | 10 | #include "game-gui-glfw.hpp"
|
---|
[3de31cf] | 11 | #include "graphics-pipeline_opengl.hpp"
|
---|
[d02c25f] | 12 |
|
---|
[0b1b52d] | 13 | // TODO: Figure out if these structs should be defined in the OpenGLGame class
|
---|
| 14 |
|
---|
| 15 | enum ObjectType {
|
---|
| 16 | TYPE_SHIP,
|
---|
| 17 | TYPE_ASTEROID,
|
---|
| 18 | TYPE_LASER,
|
---|
| 19 | TYPE_EXPLOSION,
|
---|
| 20 | };
|
---|
| 21 |
|
---|
| 22 | struct SceneObject {
|
---|
| 23 | unsigned int id;
|
---|
| 24 | ObjectType type;
|
---|
| 25 | bool deleted;
|
---|
| 26 |
|
---|
| 27 | // Currently, model_transform should only have translate, and rotation and scale need to be done in model_base since
|
---|
| 28 | // they need to be done when the object is at the origin. I should change this to have separate scale, rotate, and translate
|
---|
| 29 | // matrices for each object that can be updated independently and then applied to the object in that order.
|
---|
| 30 | // TODO: Actually, to make this as generic as possible, each object should have a matrix stack to support,
|
---|
| 31 | // for instance, applying a rotate, then a translate, then another rotate. Think about and implement the best approach.
|
---|
| 32 | glm::mat4 model_mat, model_base, model_transform;
|
---|
| 33 | glm::mat4 translate_mat; // beginning of doing what's mentioned above
|
---|
| 34 | unsigned int num_points;
|
---|
| 35 | GLuint vertex_vbo_offset;
|
---|
| 36 | GLuint ubo_offset;
|
---|
| 37 | vector<GLfloat> points;
|
---|
| 38 | vector<GLfloat> colors;
|
---|
| 39 | vector<GLfloat> texcoords;
|
---|
| 40 | vector<GLfloat> normals;
|
---|
| 41 | glm::vec3 bounding_center;
|
---|
| 42 | GLfloat bounding_radius;
|
---|
| 43 | };
|
---|
| 44 |
|
---|
| 45 | struct ParticleEffect : SceneObject {
|
---|
| 46 | vector<GLfloat> particleVelocities;
|
---|
| 47 | vector<GLfloat> particleTimes;
|
---|
| 48 | GLfloat startTime;
|
---|
| 49 | GLfloat duration;
|
---|
| 50 | };
|
---|
| 51 |
|
---|
[d02c25f] | 52 | class OpenGLGame {
|
---|
| 53 | public:
|
---|
| 54 | OpenGLGame();
|
---|
| 55 | ~OpenGLGame();
|
---|
| 56 |
|
---|
[b6e60b4] | 57 | void run(int width, int height, unsigned char guiFlags);
|
---|
[d02c25f] | 58 |
|
---|
| 59 | private:
|
---|
[d8cb15e] | 60 | GameGui* gui;
|
---|
[83b5b4b] | 61 | Viewport viewport;
|
---|
[3de31cf] | 62 |
|
---|
| 63 | vector<GraphicsPipeline_OpenGL> graphicsPipelines;
|
---|
| 64 |
|
---|
[d8cb15e] | 65 | GLFWwindow* window;
|
---|
| 66 |
|
---|
[b6e60b4] | 67 | bool initWindow(int width, int height, unsigned char guiFlags);
|
---|
[d8cb15e] | 68 | void initOpenGL();
|
---|
| 69 | void mainLoop();
|
---|
[f133da0] | 70 | void renderScene();
|
---|
| 71 | void renderUI();
|
---|
[d8cb15e] | 72 | void cleanup();
|
---|
[d02c25f] | 73 | };
|
---|
| 74 |
|
---|
[92cbc6a] | 75 | void APIENTRY opengl_debug_callback(
|
---|
| 76 | GLenum source,
|
---|
| 77 | GLenum type,
|
---|
| 78 | GLuint id,
|
---|
| 79 | GLenum severity,
|
---|
| 80 | GLsizei length,
|
---|
| 81 | const GLchar* message,
|
---|
| 82 | const void* userParam
|
---|
| 83 | );
|
---|
| 84 |
|
---|
[d02c25f] | 85 | #endif // _OPENGL_GAME_H |
---|