Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Singleton: OpenGL
- class OpenGL
- {
- public:
- static OpenGL& get_instance();
- OpenGL(OpenGL const&)= delete;
- void operator=(OpenGL const&) = delete;
- void init(void);
- //methods
- enum class ProjectionMode {PROJECTION_MODE_UNSET, PROJECTION_MODE_2D};
- // GLenum get_gl_primitive(PrimitiveType type);
- // GLenum get_gl_buffer(BufferType type);
- // void draw_indexed_command(DrawCommandIndexed cmd);
- // void draw_draw_command(DrawCommand cmd);
- void set_projection_mode(ProjectionMode mode);
- //void update_projection_data(float new_window_width, float new_window_height);
- std::string load_shader_from_file(const std::string& shader_path);
- void update_projection(float new_window_width, float new_window_height);
- void update_uniform_projection();
- void set_color(float r, float g, float b);
- void set_viewport_size(float width, float height);
- //draw functions
- void draw_rectangle(float x, float y, float width, float height);
- //TODO: implement
- void draw_circle();
- OpenGL();
- private:
- static OpenGL* instance;
- //OpenGL state
- struct glstate state;
- // when user doesn't provide any projection mode
- // this default one will be used
- GLsizei window_width, window_height = 0;
- ProjectionMode current_projection_mode = ProjectionMode::PROJECTION_MODE_UNSET;
- glm::mat4x4 projection_matrix;
- ~OpenGL(){};
- };
- OpenGL::OpenGL()
- {
- //keep getting segfault here
- state.program = glCreateProgram();
- state.projection = glm::ortho(0.0f, 800.0f, 600.0f, 0.0f, -1.0f, 1.0f);
- state.r = 1.0;
- state.g = 1.0;
- state.b = 1.0;
- state.draw_calls_batched = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement