Add small example
This commit is contained in:
19
include/opengl-playground/openglgraphics.hpp
Normal file
19
include/opengl-playground/openglgraphics.hpp
Normal 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
|
@@ -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;
|
||||
|
27
include/opengl-playground/textured-rectangle.hpp
Normal file
27
include/opengl-playground/textured-rectangle.hpp
Normal 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
|
Reference in New Issue
Block a user