From 9b83919815f6a6ce5d73da1c28483970d0ca5589 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 14:22:28 -0600 Subject: added dev/MinGfx/ --- .../docs/html/classmingfx_1_1_texture2_d.html | 540 +++++++++++++++++++++ 1 file changed, 540 insertions(+) create mode 100644 dev/MinGfx/docs/html/classmingfx_1_1_texture2_d.html (limited to 'dev/MinGfx/docs/html/classmingfx_1_1_texture2_d.html') diff --git a/dev/MinGfx/docs/html/classmingfx_1_1_texture2_d.html b/dev/MinGfx/docs/html/classmingfx_1_1_texture2_d.html new file mode 100644 index 0000000..a72804d --- /dev/null +++ b/dev/MinGfx/docs/html/classmingfx_1_1_texture2_d.html @@ -0,0 +1,540 @@ + + + + + + + +MinGfx Toolkit: mingfx::Texture2D Class Reference + + + + + + + + + + + + +
+
+ + + + + + +
+
MinGfx Toolkit +  1.0 +
+
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
+
mingfx::Texture2D Class Reference
+
+
+

Detailed Description

+

A wrapper around a 2D texture that supports loading images from files or setting texture color data directly.

+

Example:

Texture2D tex1;
+
Texture2D tex2(GL_CLAMP_TO_EDGE);
+
+
void MyGraphicsApp::InitOpenGL() {
+
std::vector<std::string> search_path;
+
search_path.push_back(".");
+
search_path.push_back("./data");
+
search_path.push_back("./shaders");
+
tex1.InitFromFile(Platform::FindFile("earth-2k.png", search_path));
+
tex2.InitFromFile(Platform::FindFile("toon-ramp.png", search_path));
+
}
+
static std::string FindFile(const std::string &basename, const std::vector< std::string > &searchpath)
+
Texture2D(GLenum wrapMode=GL_REPEAT, GLenum filterMode=GL_LINEAR)
Creates an empty texture. Optional parameters can be provided to set the texture wrap mode and filter...
+
+

Definition at line 42 of file texture2d.h.

+
+

#include <texture2d.h>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

 Texture2D (GLenum wrapMode=GL_REPEAT, GLenum filterMode=GL_LINEAR)
 Creates an empty texture. Optional parameters can be provided to set the texture wrap mode and filter mode. More...
 
virtual ~Texture2D ()
 
bool InitFromFile (const std::string &filename)
 Call this from within the InitOpenGL() function since it will initialize not just the Texture2D's internal data but also an OpenGL texture to be stored on the graphics card. Internally, this uses the stbi library to load images. It supports png, jpg, bmp, and other file formats. More...
 
bool InitFromBytes (int width, int height, const unsigned char *data)
 Call this from within the InitOpenGL() function since it will initialize not just the Texture2D's internal data but also an OpenGL texture to be stored on the graphics card. With this version of Init, you may pass in your own pointer to color data. The data argument must point to an array of 4-channel color data stored as unsigned chars in RGBA format. You are responsible for managing the memory for this array. If you will never call Pixel(), then it is safe to free data as soon as this function returns. Otherwise, you need to make sure data does not change in memory until you destroy the Texture2D object. More...
 
bool InitFromFloats (int width, int height, const float *data)
 Call this from within the InitOpenGL() function since it will initialize not just the Texture2D's internal data but also an OpenGL texture to be stored on the graphics card. With this version of Init, you may pass in your own pointer to color data. The data argument must point to an array of 4-channel color data stored as floats in RGBA format. You are responsible for managing the memory for this array. If you will never call Pixel(), then it is safe to free data as soon as this function returns. Otherwise, you need to make sure data does not change in memory until you destroy the Texture2D object. More...
 
bool UpdateFromBytes (const unsigned char *data)
 This function may be called to re-read the texture data from an array formated the same as in InitFromBytes. The width and height of the texture must remain the same. More...
 
bool UpdateFromFloats (const float *data)
 This function may be called to re-read the texture data from an array formated the same as in InitFromFloats. The width and height of the texture must remain the same. More...
 
bool initialized () const
 Returns true if the texture data has been successfully transferred to OpenGL. More...
 
int width () const
 Returns the width in pixels of the texture. More...
 
int height () const
 Returns the height in pixels of the texture. More...
 
GLuint opengl_id () const
 Returns the unsigned int used as the texture handle by OpenGL. More...
 
GLenum wrap_mode () const
 Returns an enumerated constant for the OpenGL wrap mode used by the texture. More...
 
GLenum filter_mode () const
 Returns an enumerated constant for the OpenGL filter mode used by the texture. More...
 
void set_wrap_mode (GLenum wrapMode)
 Uses the OpenGL texture wrap mode arguments. More...
 
void set_filter_mode (GLenum filterMode)
 Uses the OpenGL texture filter mode arguments. More...
 
Color Pixel (int x, int y) const
 Returns the color at the specified pixel. The top left corner of the image is (0,0) and the bottom right is (width()-1, height()-1). More...
 
+

Constructor & Destructor Documentation

+ +

◆ Texture2D()

+ +
+
+ + + + + + + + + + + + + + + + + + +
mingfx::Texture2D::Texture2D (GLenum wrapMode = GL_REPEAT,
GLenum filterMode = GL_LINEAR 
)
+
+ +

Creates an empty texture. Optional parameters can be provided to set the texture wrap mode and filter mode.

+ +
+
+ +

◆ ~Texture2D()

+ +
+
+ + + + + +
+ + + + + + + +
virtual mingfx::Texture2D::~Texture2D ()
+
+virtual
+
+ +
+
+

Member Function Documentation

+ +

◆ filter_mode()

+ +
+
+ + + + + + + +
GLenum mingfx::Texture2D::filter_mode () const
+
+ +

Returns an enumerated constant for the OpenGL filter mode used by the texture.

+ +
+
+ +

◆ height()

+ +
+
+ + + + + + + +
int mingfx::Texture2D::height () const
+
+ +

Returns the height in pixels of the texture.

+ +
+
+ +

◆ InitFromBytes()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
bool mingfx::Texture2D::InitFromBytes (int width,
int height,
const unsigned char * data 
)
+
+ +

Call this from within the InitOpenGL() function since it will initialize not just the Texture2D's internal data but also an OpenGL texture to be stored on the graphics card. With this version of Init, you may pass in your own pointer to color data. The data argument must point to an array of 4-channel color data stored as unsigned chars in RGBA format. You are responsible for managing the memory for this array. If you will never call Pixel(), then it is safe to free data as soon as this function returns. Otherwise, you need to make sure data does not change in memory until you destroy the Texture2D object.

+ +
+
+ +

◆ InitFromFile()

+ +
+
+ + + + + + + + +
bool mingfx::Texture2D::InitFromFile (const std::string & filename)
+
+ +

Call this from within the InitOpenGL() function since it will initialize not just the Texture2D's internal data but also an OpenGL texture to be stored on the graphics card. Internally, this uses the stbi library to load images. It supports png, jpg, bmp, and other file formats.

+ +
+
+ +

◆ InitFromFloats()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
bool mingfx::Texture2D::InitFromFloats (int width,
int height,
const float * data 
)
+
+ +

Call this from within the InitOpenGL() function since it will initialize not just the Texture2D's internal data but also an OpenGL texture to be stored on the graphics card. With this version of Init, you may pass in your own pointer to color data. The data argument must point to an array of 4-channel color data stored as floats in RGBA format. You are responsible for managing the memory for this array. If you will never call Pixel(), then it is safe to free data as soon as this function returns. Otherwise, you need to make sure data does not change in memory until you destroy the Texture2D object.

+ +
+
+ +

◆ initialized()

+ +
+
+ + + + + + + +
bool mingfx::Texture2D::initialized () const
+
+ +

Returns true if the texture data has been successfully transferred to OpenGL.

+ +
+
+ +

◆ opengl_id()

+ +
+
+ + + + + + + +
GLuint mingfx::Texture2D::opengl_id () const
+
+ +

Returns the unsigned int used as the texture handle by OpenGL.

+ +
+
+ +

◆ Pixel()

+ +
+
+ + + + + + + + + + + + + + + + + + +
Color mingfx::Texture2D::Pixel (int x,
int y 
) const
+
+ +

Returns the color at the specified pixel. The top left corner of the image is (0,0) and the bottom right is (width()-1, height()-1).

+ +
+
+ +

◆ set_filter_mode()

+ +
+
+ + + + + + + + +
void mingfx::Texture2D::set_filter_mode (GLenum filterMode)
+
+ +

Uses the OpenGL texture filter mode arguments.

+ +
+
+ +

◆ set_wrap_mode()

+ +
+
+ + + + + + + + +
void mingfx::Texture2D::set_wrap_mode (GLenum wrapMode)
+
+ +

Uses the OpenGL texture wrap mode arguments.

+ +
+
+ +

◆ UpdateFromBytes()

+ +
+
+ + + + + + + + +
bool mingfx::Texture2D::UpdateFromBytes (const unsigned char * data)
+
+ +

This function may be called to re-read the texture data from an array formated the same as in InitFromBytes. The width and height of the texture must remain the same.

+ +
+
+ +

◆ UpdateFromFloats()

+ +
+
+ + + + + + + + +
bool mingfx::Texture2D::UpdateFromFloats (const float * data)
+
+ +

This function may be called to re-read the texture data from an array formated the same as in InitFromFloats. The width and height of the texture must remain the same.

+ +
+
+ +

◆ width()

+ +
+
+ + + + + + + +
int mingfx::Texture2D::width () const
+
+ +

Returns the width in pixels of the texture.

+ +
+
+ +

◆ wrap_mode()

+ +
+
+ + + + + + + +
GLenum mingfx::Texture2D::wrap_mode () const
+
+ +

Returns an enumerated constant for the OpenGL wrap mode used by the texture.

+ +
+
+
The documentation for this class was generated from the following file: +
+ + + + + -- cgit v1.2.3