Add small example

This commit is contained in:
2020-03-18 22:42:04 +01:00
parent d15fb54804
commit b50cb62ac3
16 changed files with 386 additions and 23 deletions

View File

@@ -0,0 +1,19 @@
#ifndef OPENGLGRAPHICS_H
#define OPENGLGRAPHICS_H
#include <string>
#include <epoxy/gl.h>
#include <opengl-playground/openglshader.hpp>
class OpenGlGraphics
{
public:
OpenGlGraphics(OpenGlShaderProgram &prog);
~OpenGlGraphics();
virtual void realize() = 0;
virtual void render() = 0;
protected:
OpenGlShaderProgram shaderprog;
};
#endif // OPENGLGRAPHICS_H

View File

@@ -12,6 +12,9 @@ class OpenGlShaderProgram
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);
private:
bool compiled;
GLuint shader_program;

View File

@@ -0,0 +1,27 @@
#ifndef TEXTURED_RECTANGLE_H
#define TEXTURED_RECTANGLE_H
#include <opengl-playground/openglgraphics.hpp>
#include <epoxy/gl.h>
class TexturedRectangle : OpenGlGraphics
{
public:
TexturedRectangle(float x0, float y0, float x1, float y1, OpenGlShaderProgram &shaderprog);
void realize();
void render();
void setZoom(float zoom);
float getZoom();
void setOffset(float x_off, float y_off);
float getOffsetX();
float getOffsetY();
private:
float pos1[2];
float pos2[2];
float x_offset;
float y_offset;
float zoom;
GLuint vao;
};
#endif // TEXTURED_RECTANGLE_H