source: opengl-game/opengl-game.hpp@ cc4a8b5

feature/imgui-sdl points-test
Last change on this file since cc4a8b5 was 0b1b52d, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

In openglgame, port over the functionality to specify and initialize varying attributes

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