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