 |
raylib-cpp
C++ object-oriented wrapper library for raylib.
|
25 #ifndef RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
26 #define RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
30 #include "./raylib.hpp"
31 #include "./raylib-cpp-utils.hpp"
32 #include "./Vector2.hpp"
33 #include "./Material.hpp"
43 set(::GetTextureDefault());
61 GETTERSETTER(
unsigned int, Id,
id)
62 GETTERSETTER(
int, Width, width)
63 GETTERSETTER(
int, Height, height)
64 GETTERSETTER(
int, Mipmaps, mipmaps)
65 GETTERSETTER(
int, Format, format)
81 return {
static_cast<float>(width),
static_cast<float>(height)};
88 set(::LoadTextureFromImage(image));
101 void Load(
const std::string& fileName) {
102 set(::LoadTexture(fileName.c_str()));
109 ::UnloadTexture(*
this);
116 ::UpdateTexture(*
this, pixels);
124 UpdateTextureRec(*
this, rec, pixels);
132 return ::GetTextureData(*
this);
146 ::GenTextureMipmaps(
this);
154 ::SetTextureFilter(*
this, filterMode);
162 ::SetTextureWrap(*
this, wrapMode);
177 ::DrawTexture(*
this, posX, posY, tint);
182 ::DrawTextureV(*
this, position, tint);
187 ::
Color tint = {255, 255, 255, 255}) {
188 ::DrawTextureEx(*
this, position, rotation, scale, tint);
193 ::Color tint = {255, 255, 255, 255}) {
194 ::DrawTextureRec(*
this, sourceRec, position, tint);
199 ::
Color tint = {255, 255, 255, 255}) {
200 ::DrawTextureQuad(*
this, tiling, offset, quad, tint);
205 float rotation = 0,
::Color tint = {255, 255, 255, 255}) {
206 ::DrawTexturePro(*
this, sourceRec, destRec, origin, rotation, tint);
211 float rotation = 0,
::Color tint = {255, 255, 255, 255}) {
212 ::DrawTextureNPatch(*
this, nPatchInfo, destRec, origin, rotation, tint);
217 ::
Color color = {255, 255, 255, 255}) {
218 ::DrawCubeTexture(*
this, position, width, height, length, color);
223 float rotation = 0,
float scale = 1,
Color tint = {255, 255, 255, 255}) {
224 ::DrawTextureTiled(*
this, sourceRec, destRec, origin, rotation, scale, tint);
232 ::SetMaterialTexture(material, mapType, *
this);
240 return ::GetPixelDataSize(width, height, format);
247 ::SetShapesTexture(*
this, source);
252 inline void set(const ::Texture& texture) {
254 width = texture.width;
255 height = texture.height;
256 mipmaps = texture.mipmaps;
257 format = texture.format;
267 #endif // RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
static int GetPixelDataSize(int width, int height, int format)
Get pixel data size in bytes for certain format.
Provides all the classes associated with raylib-cpp.
Texture & SetWrap(int wrapMode)
Set texture wrapping mode.
Texture & operator=(const Texture &texture)
void LoadTextureCubemap(const ::Image &image, int layoutType)
Load cubemap from image, multiple image cubemap layouts supported.
void set(const ::Texture &texture)
Texture & Draw(int posX, int posY, ::Color tint={255, 255, 255, 255})
Draw a Texture2D.
Texture & Draw(::Vector3 position, float width, float height, float length, ::Color color={255, 255, 255, 255})
inline ::Vector2 GetSize()
Retrieve the width and height of the texture.
Texture & Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, ::Color tint={255, 255, 255, 255})
Texture & SetShapes(::Rectangle source)
Define default texture used to draw shapes.
Texture(const ::Image &image)
Texture & Draw(::Rectangle sourceRec, ::Vector2 position={0, 0}, ::Color tint={255, 255, 255, 255})
void Load(const std::string &fileName)
Load texture from file into GPU memory (VRAM)
Texture & DrawTiled(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, float scale=1, Color tint={255, 255, 255, 255})
void LoadFromImage(const ::Image &image)
Load texture from image data.
Texture(const std::string &fileName)
Load texture from file into GPU memory (VRAM)
Texture & SetFilter(int filterMode)
Set texture scaling filter mode.
Texture & Draw(::Vector2 position, float rotation, float scale=1.0f, ::Color tint={255, 255, 255, 255})
inline ::Image GetData() const
Get pixel data from GPU texture and return an Image.
Texture & Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad, ::Color tint={255, 255, 255, 255})
Texture & Draw()
Draws the texture at the top left corner of the screen.
Texture & UpdateRec(::Rectangle rec, const void *pixels)
Update GPU texture rectangle with new data.
void Unload()
Unload texture from GPU memory (VRAM)
Texture & Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, ::Color tint={255, 255, 255, 255})
Texture & GenMipmaps()
Generate GPU mipmaps for a texture.
Texture & Draw(::Vector2 position, ::Color tint={255, 255, 255, 255})
Texture(const ::Texture &texture)
Texture & SetMaterial(::Material *material, int mapType)
Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
Texture & Update(const void *pixels)
Update GPU texture with new data.