source: opengl-game/opengl-game.hpp

feature/imgui-sdl
Last change on this file was d8cf709, checked in by Dmitry Portnoy <dportnoy@…>, 3 years ago

Change UIEvent to also include the original event from the UI library the game gui is currently using, such as SDL or GLFW.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#ifndef _OPENGL_GAME_H
2#define _OPENGL_GAME_H
3
4#include <glm/glm.hpp>
5
6// TODO: Rewrite this to work with the new version of IMGUI
7#include "IMGUI/imgui.h"
8#include "imgui_impl_glfw_gl3.h"
9
10#include "game-gui-glfw.hpp"
11#include "graphics-pipeline_opengl.hpp"
12
13// TODO: Figure out if these structs should be defined in the OpenGLGame class
14
15enum ObjectType {
16 TYPE_SHIP,
17 TYPE_ASTEROID,
18 TYPE_LASER,
19 TYPE_EXPLOSION,
20};
21
22struct 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
45struct ParticleEffect : SceneObject {
46 vector<GLfloat> particleVelocities;
47 vector<GLfloat> particleTimes;
48 GLfloat startTime;
49 GLfloat duration;
50};
51
52class OpenGLGame {
53 public:
54 OpenGLGame();
55 ~OpenGLGame();
56
57 void run(int width, int height, unsigned char guiFlags);
58
59 private:
60 GameGui* gui;
61 Viewport viewport;
62
63 vector<GraphicsPipeline_OpenGL> graphicsPipelines;
64
65 GLFWwindow* window;
66
67 bool initWindow(int width, int height, unsigned char guiFlags);
68 void initOpenGL();
69 void mainLoop();
70 void renderScene();
71 void renderUI();
72 void cleanup();
73};
74
75void 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
85#endif // _OPENGL_GAME_H
Note: See TracBrowser for help on using the repository browser.