Add imgui

This commit is contained in:
2020-03-21 22:38:10 +01:00
parent b22be7d6a5
commit 4a7e0ac82a
178 changed files with 73595 additions and 94 deletions

View File

@@ -4,16 +4,21 @@
#include <string>
#include <epoxy/gl.h>
#include <opengl-playground/openglshader.hpp>
#include <glm/glm.hpp>
#include <memory>
class OpenGlGraphics
{
public:
OpenGlGraphics(OpenGlShaderProgram &prog);
OpenGlGraphics(std::shared_ptr<OpenGlShaderProgram> shader_prog);
~OpenGlGraphics();
virtual void realize() = 0;
virtual void render() = 0;
void setModelMatrix(const glm::mat4 &model_matrix);
glm::mat4 getModelMatrix();
protected:
OpenGlShaderProgram shaderprog;
std::shared_ptr<OpenGlShaderProgram> shaderprog;
glm::mat4 model_matrix;
};
#endif // OPENGLGRAPHICS_H

View File

@@ -3,19 +3,27 @@
#include <string>
#include <epoxy/gl.h>
#include <glm/glm.hpp>
class OpenGlShaderProgram
{
public:
OpenGlShaderProgram(std::string vertex_file, std::string geometry_file, std::string fragment_file);
~OpenGlShaderProgram();
void setProjectionView(const glm::mat4 &projection, const glm::mat4 &view);
glm::mat4 getProjection();
glm::mat4 getView();
int compile();
void unload();
int use();
int getUniformLoc(const std::string &uniform);
void setUniformFloat(const std::string &uniform, float value);
void setUniformVec2(const std::string &uniform, float *vector);
void setUniformMat4(const std::string &uniform, const glm::mat4 &matrix);
private:
glm::mat4 proj;
glm::mat4 view;
glm::mat4 proj_view;
bool compiled;
GLuint shader_program;
std::string vertex_file;

View File

@@ -12,6 +12,8 @@ class SdlMainWindow : public MainWindow
void show();
void swapBuffer();
void activateGlContext();
SDL_Window *getWindow();
SDL_GLContext getContext();
private:
SDL_Window *window;
SDL_GLContext context;

View File

@@ -3,11 +3,12 @@
#include <opengl-playground/openglgraphics.hpp>
#include <epoxy/gl.h>
#include <memory>
class TexturedRectangle : OpenGlGraphics
{
public:
TexturedRectangle(float x0, float y0, float x1, float y1, OpenGlShaderProgram &shaderprog);
TexturedRectangle(float x0, float y0, float x1, float y1, std::shared_ptr<OpenGlShaderProgram> shaderprog);
void realize();
void render();
void setZoom(float zoom);
@@ -16,6 +17,7 @@ class TexturedRectangle : OpenGlGraphics
float getOffsetX();
float getOffsetY();
private:
void calculateModelMatrix();
float pos1[2];
float pos2[2];
float x_offset;