 |
BARE2D
|
|
Go to the documentation of this file.
8 :
Glyph(destRect, uvRect,
Texture, Depth, colour, angle, COR), bumpmap(Bumpmap) {
13 :
BasicRenderer(fragShader, vertShader, perspectiveWidth, perspectiveHeight) {
20 GLint textureUniform = 0;
23 GLint bumpUniform = 1;
31 glm::mat4 projectionMatrix =
m_camera->getCameraMatrix();
52 for(
unsigned int i = 0; i <
m_batches.size(); i++) {
63 glDrawArrays(GL_TRIANGLES, (GLint)
m_batches[i].offset, (GLsizei)
m_batches[i].numVertices);
73 void BumpyRenderer::draw(glm::vec4 destRect, glm::vec4 uvRect, GLuint texture,
float depth,
Colour colour,
float angle, glm::vec2 COR) {
77 void BumpyRenderer::draw(glm::vec4 destRect, glm::vec4 uvRect, GLuint texture, GLuint bumpmap,
float depth,
Colour colour,
float angle, glm::vec2 COR) {
79 if(!
m_camera->isRectInViewspace(destRect))
83 m_glyphs.push_back(
new BumpyGlyph(destRect, uvRect, texture, bumpmap, depth, colour, angle, COR));
89 std::vector<Vertex> vertices;
92 vertices.resize(
m_glyphs.size() * 6);
107 vertices[vertex++] =
m_glyphs[0]->topLeft;
108 vertices[vertex++] =
m_glyphs[0]->bottomLeft;
109 vertices[vertex++] =
m_glyphs[0]->bottomRight;
110 vertices[vertex++] =
m_glyphs[0]->bottomRight;
111 vertices[vertex++] =
m_glyphs[0]->topRight;
112 vertices[vertex++] =
m_glyphs[0]->topLeft;
119 for(
unsigned int glyph = 1; glyph <
m_glyphs.size(); glyph++) {
132 vertices[vertex++] =
m_glyphs[glyph]->topLeft;
133 vertices[vertex++] =
m_glyphs[glyph]->bottomLeft;
134 vertices[vertex++] =
m_glyphs[glyph]->bottomRight;
135 vertices[vertex++] =
m_glyphs[glyph]->bottomRight;
136 vertices[vertex++] =
m_glyphs[glyph]->topRight;
137 vertices[vertex++] =
m_glyphs[glyph]->topLeft;
152 glBufferData(GL_ARRAY_BUFFER, vertices.size() *
sizeof(
Vertex),
nullptr, GL_DYNAMIC_DRAW);
155 glBufferSubData(GL_ARRAY_BUFFER, 0, vertices.size() *
sizeof(
Vertex), vertices.data());
void setUniformMatrix(const std::string uniform, bool transpose, T *data, unsigned int num=1)
Similar to setUniform.
Just holds vertex data for convenience.
void use()
Activates this shader program for the renderer to use.
void unbind()
Unbinds the vao.
void unuse()
Deactivates this shader program.
virtual void initUniforms() override
Initializes all uniforms, such as colour attachments, depth attachments, etc.
void bindTexture(GLenum target, GLenum texture)
Binds a texture to target in the currently active texture slot.
virtual void createRenderBatches() override
Constructs all of the render batches from data given by, say, draw() calls.
virtual void preRender() override
Does stuff inside of the render function, within the shader's use.
The texture struct holds very basic stuff - the filepath, width, height, and ID,.
virtual void draw(glm::vec4 destRect, glm::vec4 uvRect, GLuint texture, float depth, Colour colour=Colour(255, 255, 255, 255), float angle=0.0f, glm::vec2 COR=glm::vec2(0.5f))
std::vector< Glyph * > m_glyphs
std::vector< GLuint > m_batchBumpmaps
std::shared_ptr< Camera2D > m_camera
void bind()
Binds this vertex array object.
void unbindVBO()
Unbinds this VAO's VBO.
The glyph represents a renderbatch's primitive data, which is created from each draw call in the basi...
void setActiveTexture(GLenum texture)
Sets the active texture "slot". This can be GL_TEXTURE0 to GL_TEXTURE8 (I think. Check the literature...
void setUniform(const std::string uniform, T *data, unsigned int num=1)
A generalized wrapper to find and set a uniform for this shader.
BumpyRenderer(std::string &fragShader, std::string &vertShader, unsigned int perspectiveWidth=2, unsigned int perspectiveHeight=2)
virtual void render() override
Actually renders the contents to the screen!
void bindVBO()
Binds the VAO's VBO.
BumpyGlyph(glm::vec4 &destRect, glm::vec4 &uvRect, GLuint &Texture, GLuint &Bumpmap, float &Depth, Colour &colour, float &angle, glm::vec2 &COR)
This is a glyph, but with bumpmap (for lighting etc.).
static GLContext * getContext()
std::vector< RenderBatch > m_batches
An RGBA 8-bit colour value.
void throwFatalError(BAREError err, std::string message)
Throws an error (fatal). Also calls displayErrors and exits the program.