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::Texture Class Reference

A wrapper class for a texture for the game engine. More...

#include <Texture.hpp>

Public Member Functions

 Texture (const char *path)
 The default constructor of the Texture class.
 
unsigned GetTexture ()
 Returns the id of the texture.
 

Detailed Description

A wrapper class for a texture for the game engine.

The class takes a path to the texture (preferrably along Assets/), and prepares the texture to be loaded into the GPU. When the game is ready to use the texture via GetTexture(), the texture is loaded into the GPU to be used by the game engine.

Example

Engine::Graphics::Texture texture("Assets/placeholder.png");
class TestObject : public Engine::Node {
void Draw() override {
Engine::Game::getInstance().GetRenderer().UseTexture(texture, GL_TEXTURE0);
Engine::Game::getInstance().GetRenderer().DrawMesh(&mesh);
}
};
Graphics::Renderer & GetRenderer()
Definition Game.cpp:65
void UseTexture(Texture &texture, unsigned int slot=GL_TEXTURE0)
Takes the texture and binds it to the specified slot.
Definition Renderer.cpp:149
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 wrapper class for a texture for the game engine.
Definition Texture.hpp:35
A single node in a game scene.
Definition Node.hpp:43

Constructor & Destructor Documentation

◆ Texture()

Engine::Graphics::Texture::Texture ( const char *  path)

The default constructor of the Texture class.

Takes a path to the texture (preferrably along Assets/), and prepares the texture to be loaded into the GPU.

The texture is not loaded into the GPU until GetTexture is called.

Parameters
pathThe path to the texture

Member Function Documentation

◆ GetTexture()

unsigned Engine::Graphics::Texture::GetTexture ( )

Returns the id of the texture.

This is the id of the texture that is loaded into the GPU according to the renderer. When constructed, the texture is not loaded in immediately, but rather when GetTexture is called.

Returns
The id of the texture

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