21 #ifndef KJB_CPP_OPENGL_TEXTURE
22 #define KJB_CPP_OPENGL_TEXTURE
31 #ifdef KJB_HAVE_OPENGL
38 typedef unsigned int GLunum;
79 Texture(
const Texture& other);
81 int get_width()
const;
83 int get_height()
const;
85 int get_num_cols()
const;
87 int get_num_rows()
const;
100 Self& operator=(
const Self& src);
117 Texture& set(
GLenum target,
int level, GLint internal_format, GLsizei width, GLsizei
height,
int border,
GLenum format,
const GLfloat* data = 0);
119 Texture& set(
GLenum target,
int level, GLint internal_format, GLsizei width, GLsizei
height,
int border,
GLenum format,
const GLint* data = 0);
121 Texture& set(
GLenum target,
int level, GLint internal_format, GLsizei width, GLsizei
height,
int border,
GLenum format,
const GLuint* data = 0);
123 Texture& set(
GLenum target,
int level, GLint internal_format, GLsizei width, GLsizei
height,
int border,
GLenum format,
const GLubyte* data = 0);
125 Texture& set(
GLenum target,
int level, GLint internal_format, GLsizei width, GLsizei
height,
int border,
GLenum format,
const GLushort* data = 0);
138 Texture& set(GLsizei width, GLsizei
height,
GLenum format,
const T* data = 0)
140 return set(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, data);
147 Self& allocate(
GLenum internal_format, GLsizei width, GLsizei
height);
164 Texture& set(
const Image& img);
190 Texture& set(
const Matrix& mat);
202 Texture& set(
const Matrix& mat,
GLenum target,
GLenum level, GLint border);
205 Self& set_float(
const Matrix& mat,
GLenum target = GL_TEXTURE_2D);
226 Self& set_packed_float(
const Matrix& mat,
GLenum target = GL_TEXTURE_2D);
234 template <
class Matrix_type>
235 Self& set_mask_4ui(
const Matrix_type& mat,
GLenum target = GL_TEXTURE_2D)
237 GLubyte* array = create_gl_mask_4ui(mat);
239 set(target, 0, GL_RGBA8, mat.get_num_cols(), mat.get_num_rows(), 0, GL_RGBA, array);
276 static int max_color_attachments();
297 static float* create_gl_array(
const Matrix& mat);
308 template <
class Matrix_type>
309 static GLubyte* create_gl_mask_4ui(
const Matrix_type& mat)
311 GLubyte* array =
new GLubyte[mat.get_length() * 4];
312 GLubyte* cur = array;
314 const int num_rows = mat.get_num_rows();
315 const int num_cols = mat.get_num_cols();
317 for(
int row = num_rows - 1; row >= 0; row--)
318 for(
int col = 0; col < num_cols; col++)
320 *cur++ = (mat(row, col) == 0 ? 0 : 255);
321 *cur++ = (mat(row, col) == 0 ? 0 : 255);
322 *cur++ = (mat(row, col) == 0 ? 0 : 255);
323 *cur++ = (mat(row, col) == 0 ? 0 : 255);
334 GLint internal_format,
341 static std::map<int, int> ref_count_;
348 void draw_fullscreen_textured_quad(
const Texture& texture);
Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionalit...
This class implements matrices, in the linear-algebra sense, restricted to integer-valued elements...
Definition: l_int_matrix.h:71
height
Definition: APPgetLargeConnectedEdges.m:33
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
Code for a wrapper class around the C struct KJB_Image.