Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Engine::Graphics::Shader Class Reference

A class used to load and use shaders. More...

#include <Shader.hpp>

Public Member Functions

 Shader ()
 Default constructor.
 
 Shader (const char *frag)
 Constructor with default vertex shader.
 
 Shader (const char *frag, const char *vert)
 Main constructor for a shader.
 
unsigned int GetShaderProgram ()
 Gets the shader program.
 

Detailed Description

A class used to load and use shaders.

This class is used to load and use shaders in the game engine. The shader takes two files, one for the vertex shader and one for the fragment shader, and compiles them into a GPU program to be used by the game engine to render models. If no shader scripts are provided, it will use the default shader. A fragment shader will be required first.

Example

class TestObject : public Engine::Node {
void Draw() override {
Engine::Game::getInstance().GetRenderer().UseShader(shader);
Engine::Game::getInstance().GetRenderer().DrawMesh(&mesh);
}
};
Graphics::Renderer & GetRenderer()
Definition Game.cpp:65
void UseShader(Shader &shader)
Sets the currently loaded shader.
Definition Renderer.cpp:144
void DrawMesh(Mesh *mesh, Vec3f position={0, 0, 0}, Vec3f scale={1, 1, 1}, Vec3f rotation={0, 0, 0})
Draws a mesh to the canvas.
Definition Renderer.cpp:69
A class used to load and use shaders.
Definition Shader.hpp:37
A single node in a game scene.
Definition Node.hpp:43
Authors
  • Roberto Selles/Henderythmix

Constructor & Destructor Documentation

◆ Shader() [1/3]

Engine::Graphics::Shader::Shader ( )

Default constructor.

uses the default shader files

◆ Shader() [2/3]

Engine::Graphics::Shader::Shader ( const char *  frag)

Constructor with default vertex shader.

Shader program that uses the default vertex shader. Takes in a shader file for the fragment shader

Parameters
fragthe path to the fragment shader

◆ Shader() [3/3]

Engine::Graphics::Shader::Shader ( const char *  frag,
const char *  vert 
)

Main constructor for a shader.

Take in a fragment and vertex shader file to construct a shader.

Parameters
fragthe path to the fragment shader
vertthe path to the vertex shader

Member Function Documentation

◆ GetShaderProgram()

unsigned int Engine::Graphics::Shader::GetShaderProgram ( )

Gets the shader program.

Returns the shader program that was loaded into the GPU. If the shader is not compiled, it will compile the shaderand and then return the shader program.

Returns
the shader program

The documentation for this class was generated from the following files: