3 #ifndef AGL_RENDERER_H_
4 #define AGL_RENDERER_H_
12 #include "agl/image.h"
89 float aspect,
float near,
float far);
112 void ortho(
float minx,
float maxx,
113 float miny,
float maxy,
float minz,
float maxz);
133 void lookAt(
const glm::vec3& lookfrom,
134 const glm::vec3& lookat,
135 const glm::vec3& up = glm::vec3(0.0f, 1.0f, 0.0f));
175 const std::string& vs,
const std::string& fs);
236 void loadRenderTexture(
const std::string& name,
int slot,
237 int width,
int height);
257 void setUniform(
const std::string& name,
float x,
float y,
float z);
262 void setUniform(
const std::string& name,
float x,
float y,
float z,
float w);
267 void setUniform(
const std::string& name,
const glm::vec2 &v);
272 void setUniform(
const std::string& name,
const glm::vec3 &v);
277 void setUniform(
const std::string& name,
const glm::vec4 &v);
282 void setUniform(
const std::string& name,
const glm::mat4 &m);
287 void setUniform(
const std::string& name,
const glm::mat3 &m);
292 void setUniform(
const std::string& name,
float val);
297 void setUniform(
const std::string& name,
int val);
302 void setUniform(
const std::string& name,
bool val);
307 void setUniform(
const std::string& name, GLuint val);
319 void texture(
const std::string& uniformName,
const std::string& textureName);
331 void cubemap(
const std::string& uniformName,
const std::string& texName);
343 const std::string& filename,
int slot);
353 void loadCubemap(
const std::string& name,
const std::string& dir,
int slot);
359 const std::vector<std::string>& names,
int slot);
365 const std::vector<Image>& images,
int slot);
415 void scale(
const glm::vec3& xyz);
438 void rotate(
float angleRad,
const glm::vec3& axis);
477 void sprite(
const glm::vec3& pos,
const glm::vec4& color,
float size);
487 void line(
const glm::vec3& p1,
const glm::vec3& p2,
488 const glm::vec3& c1,
const glm::vec3& c2);
497 void text(
const std::string&
text,
float x,
float y);
586 void skybox(
float size = 10.0);
603 void initBillboards();
610 BlendMode _blendMode;
617 std::map<std::string, Texture> _textures;
620 struct RenderTexture {
629 std::map<std::string, RenderTexture> _renderTextures;
630 std::string _activeRenderTexture;
633 class Shader* _currentShader;
634 std::map<std::string, class Shader*> _shaders;
635 std::list<Shader*> _shaderStack;
638 std::list<glm::mat4> _stack;
642 glm::mat4 _projectionMatrix;
643 glm::mat4 _viewMatrix;
648 class Cylinder* _cone;
649 class Capsule* _capsule;
650 class Cylinder* _cylinder;
651 class Teapot* _teapot;
654 class Sphere* _sphere;
655 class SkyBox* _skybox;
662 GLuint mVboLinePosId;
663 GLuint mVboLineColorId;
668 unsigned int _fontColor;
673 #endif // AGL_RENDERER_H_
void text(const std::string &text, float x, float y)
Draws text using the current font size and color.
Definition: renderer.cpp:291
bool initialized() const
Return whether the Renderer is ready for drawing.
Definition: renderer.cpp:88
void torus()
Draws a torus.
Definition: renderer.cpp:422
void identity()
Clear the current transform.
Definition: renderer.cpp:386
void cone()
Draws a cone centered at the origin, with the tip towards +Z.
Definition: renderer.cpp:426
glm::vec3 cameraPosition() const
Get the current camera position.
Definition: renderer.cpp:93
void plane()
Draws a plane.
Definition: renderer.cpp:410
void loadShader(const std::string &name, const std::string &vs, const std::string &fs)
Load a GLSL shader from files.
Definition: renderer.cpp:637
void setUniform(const std::string &name, float x, float y, float z)
Set a uniform parameter in the currently active shader.
Definition: renderer.cpp:482
void scale(const glm::vec3 &xyz)
Scale an object.
Definition: renderer.cpp:390
void blendMode(BlendMode mode)
Mode for combining colors when drawing.
Definition: renderer.cpp:226
void init()
Initialize this class for drawing.
Definition: renderer.cpp:97
void beginRenderTexture(const std::string &targetName)
Render to a texture instead of to the screen @targetName The name of the texture target.
Definition: renderer.cpp:654
void texture(const std::string &uniformName, const std::string &textureName)
Set a uniform sampler parameter in the currently active shader.
Definition: renderer.cpp:259
glm::mat4 viewMatrix() const
Get the current view matrix.
Definition: renderer.h:156
void capsule()
Draws a capsule with endpoints at (0,0,0) and (0,0,1). The cap radius is 0.25 and the width is 0....
Definition: renderer.cpp:418
void cleanupShaders()
Clear all active shaders.
Definition: renderer.cpp:454
void mesh(const Mesh &m)
Draws a custom mesh.
Definition: renderer.cpp:438
float textHeight()
Get the height of a string (font metrics)
Definition: renderer.cpp:285
void cubemap(const std::string &uniformName, const std::string &texName)
Set a uniform sampler parameter in the currently active shader.
Definition: renderer.cpp:359
void fontColor(const glm::vec4 &color)
Set font color for drawing text.
Definition: renderer.cpp:268
void translate(const glm::vec3 &xyz)
Translate an object.
Definition: renderer.cpp:394
void ortho(float minx, float maxx, float miny, float maxy, float minz, float maxz)
Set the current projection to an orthographic view.
Definition: renderer.cpp:248
void line(const glm::vec3 &p1, const glm::vec3 &p2, const glm::vec3 &c1, const glm::vec3 &c2)
Draws a sprite using a point billboard.
Definition: renderer.cpp:311
The Renderer class draws meshes to the screen using shaders.
Definition: renderer.h:37
void loadTexture(const std::string &name, const std::string &filename, int slot)
Load a texture from a file.
Definition: renderer.cpp:603
void skybox(float size=10.0)
Draws a skybox (typically with a cubemap)
Definition: renderer.cpp:367
void lookAt(const glm::vec3 &lookfrom, const glm::vec3 &lookat, const glm::vec3 &up=glm::vec3(0.0f, 1.0f, 0.0f))
Set the camera position and orientation.
Definition: renderer.cpp:253
void beginShader(const std::string &shaderName)
Set active shader to use for rendering.
Definition: renderer.cpp:460
void teapot()
Draws a teapot with largest side with width 1.
Definition: renderer.cpp:406
float textWidth(const std::string &text)
Get the width of a string (font metrics)
Definition: renderer.cpp:280
glm::mat4 projectionMatrix() const
Get the current projection matrix.
Definition: renderer.h:149
void rotate(float angleRad, const glm::vec3 &axis)
Rotates an object.
Definition: renderer.cpp:398
Implements loading, modifying, and saving RGBA images.
Definition: image.h:27
void endShader()
Clear active shader to use for rendering.
Definition: renderer.cpp:468
void sprite(const glm::vec3 &pos, const glm::vec4 &color, float size)
Draws a sprite using a point billboard.
Definition: renderer.cpp:344
void perspective(float fovRadians, float aspect, float near, float far)
Set the current projection to a perspective view.
Definition: renderer.cpp:243
void endRenderTexture()
Revert to rendering to the screen.
Definition: renderer.cpp:667
void cylinder()
Draws a teapot with largest side with width 1.
Definition: renderer.cpp:414
Global utilities and common third party includes.
void sphere()
Draws a sphere centered at the origin with radius 0.5.
Definition: renderer.cpp:434
void pop()
Pop the current matrix off the matrix stack.
Definition: renderer.cpp:380
void transform(const glm::mat4 &trs)
Transforms an object by the given matrix.
Definition: renderer.cpp:402
Base class for meshes.
Definition: mesh.h:18
void cube()
Draws a cube centered at the origin with width, height, and depth equal to 1.0.
Definition: renderer.cpp:430
void fontSize(int s)
Set font size for drawing text.
Definition: renderer.cpp:276
void cleanup()
Cleanup all resources used for drawing.
Definition: renderer.cpp:55
void loadCubemap(const std::string &name, const std::string &dir, int slot)
Load a cube map.
void push()
Push the current matrix onto the matrix stack.
Definition: renderer.cpp:376