Bubba-3D  0.9.0
Awesome game engine!
GLSquare.h
1 /*
2  * This file is part of Bubba-3D.
3  *
4  * Bubba-3D is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Bubba-3D is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with Bubba-3D. If not, see http://www.gnu.org/licenses/.
16  */
17 #pragma once
18 
19 #include <GL/glew.h>
20 #include <linmath/float4x4.h>
21 #include <IHudDrawable.h>
22 
23 class ShaderProgram;
24 class HUDGraphic;
25 
30 class GLSquare : public IHudDrawable {
31 public:
32  GLSquare(float posX, float posY, float width, float height, HUDGraphic* image);
33 
34  virtual ~GLSquare();
35 
36  float getX();
37  float getY();
38  float getWidth();
39  float getHeight();
40  HUDGraphic* getGraphic();
41 
42  void setCenterOffset(chag::float3 offset);
43  void setGraphic(HUDGraphic* graphic);
44 
45  void updateGraphic();
46 
47  virtual void render(ShaderProgram* shaderProgram, chag::float4x4* projectionMatrix);
48 
49 protected:
50  float posX;
51  float posY;
52  float width;
53  float height;
54 
55  HUDGraphic* graphic;
56  GLuint vao;
57 
58  ShaderProgram* shaderProgram;
59  chag::float4x4* projectionMatrix;
60  chag::float3 originalPosition;
61 
62  chag::float4x4 getModelMatrix();
63 
64  void init(float posX, float posY, float width, float height, HUDGraphic* image);
65  void fillVertexBuffer();
66  void bindTextureAndDraw(ShaderProgram* shaderProgram, chag::float4x4* projectionMatrix);
67  void updateOriginalPosition();
68 };
Class for maintaining OpenGL shader programs.
Definition: ShaderProgram.h:39
void setCenterOffset(chag::float3 offset)
Definition: GLSquare.cpp:120