ReactOS 0.4.15-dev-5666-gc548b97
teximage.h File Reference
#include "types.h"
Include dependency graph for teximage.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct gl_texture_imagegl_alloc_texture_image (void)
 
void gl_free_texture_image (struct gl_texture_image *teximage)
 
struct gl_imagegl_unpack_texsubimage (GLcontext *ctx, GLint width, GLint height, GLenum format, GLenum type, const GLvoid *pixels)
 
struct gl_texture_imagegl_unpack_texture (GLcontext *ctx, GLint dimensions, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
 
struct gl_texture_imagegl_unpack_texture3D (GLcontext *ctx, GLint dimensions, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
 
void gl_tex_image_1D (GLcontext *ctx, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
 
void gl_tex_image_2D (GLcontext *ctx, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
 
void gl_tex_image_3D (GLcontext *ctx, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint height, GLint depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
 
void gl_TexImage1D (GLcontext *ctx, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, struct gl_image *teximage)
 
void gl_TexImage2D (GLcontext *ctx, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, struct gl_image *teximage)
 
void gl_GetTexImage (GLcontext *ctx, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)
 
void gl_TexSubImage1D (GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, struct gl_image *image)
 
void gl_TexSubImage2D (GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, struct gl_image *image)
 
void gl_CopyTexImage1D (GLcontext *ctx, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border)
 
void gl_CopyTexImage2D (GLcontext *ctx, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
 
void gl_CopyTexSubImage1D (GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)
 
void gl_CopyTexSubImage2D (GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
 

Function Documentation

◆ gl_alloc_texture_image()

struct gl_texture_image * gl_alloc_texture_image ( void  )

Definition at line 331 of file teximage.c.

332{
333 return (struct gl_texture_image *) calloc( 1, sizeof(struct gl_texture_image) );
334}
#define calloc
Definition: rosglue.h:14

Referenced by alloc_proxy_textures(), image_to_texture(), and make_null_texture().

◆ gl_CopyTexImage1D()

void gl_CopyTexImage1D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLenum  internalformat,
GLint  x,
GLint  y,
GLsizei  width,
GLint  border 
)

Definition at line 1599 of file teximage.c.

1604{
1605 GLint format;
1606 struct gl_image *teximage;
1607
1608 if (INSIDE_BEGIN_END(ctx)) {
1609 gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexImage1D" );
1610 return;
1611 }
1612 if (target!=GL_TEXTURE_1D) {
1613 gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" );
1614 return;
1615 }
1617 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(level)" );
1618 return;
1619 }
1620 if (border!=0 && border!=1) {
1621 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(border)" );
1622 return;
1623 }
1625 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(width)" );
1626 return;
1627 }
1629 if (format<0 || (internalformat>=1 && internalformat<=4)) {
1630 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(format)" );
1631 return;
1632 }
1633
1634 teximage = read_color_image( ctx, x, y, width, 1, format );
1635 if (!teximage) {
1636 gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D" );
1637 return;
1638 }
1639
1641 border, GL_RGBA, GL_UNSIGNED_BYTE, teximage );
1642
1643 /* teximage was freed in gl_TexImage1D */
1644}
#define MAX_TEXTURE_SIZE
Definition: config.h:93
#define MAX_TEXTURE_LEVELS
Definition: config.h:90
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
#define GL_INVALID_VALUE
Definition: gl.h:695
GLint level
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define GL_INVALID_OPERATION
Definition: gl.h:696
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_RGBA
Definition: gl.h:503
GLint GLint internalformat
Definition: gl.h:1546
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
int GLint
Definition: gl.h:156
#define GL_OUT_OF_MEMORY
Definition: gl.h:699
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_INVALID_ENUM
Definition: gl.h:694
GLenum target
Definition: glext.h:7315
#define INSIDE_BEGIN_END(CTX)
Definition: macros.h:135
static struct gl_image * read_color_image(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLint format)
Definition: teximage.c:1493
void gl_TexImage1D(GLcontext *ctx, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, struct gl_image *image)
Definition: teximage.c:1049
static GLint decode_internal_format(GLint format)
Definition: teximage.c:195

Referenced by execute_list(), and init_exec_pointers().

◆ gl_CopyTexImage2D()

void gl_CopyTexImage2D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLenum  internalformat,
GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height,
GLint  border 
)

Definition at line 1648 of file teximage.c.

1652{
1653 GLint format;
1654 struct gl_image *teximage;
1655
1656 if (INSIDE_BEGIN_END(ctx)) {
1657 gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexImage2D" );
1658 return;
1659 }
1660 if (target!=GL_TEXTURE_2D) {
1661 gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
1662 return;
1663 }
1665 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(level)" );
1666 return;
1667 }
1668 if (border!=0 && border!=1) {
1669 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(border)" );
1670 return;
1671 }
1673 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(width)" );
1674 return;
1675 }
1677 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(height)" );
1678 return;
1679 }
1681 if (format<0 || (internalformat>=1 && internalformat<=4)) {
1682 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(format)" );
1683 return;
1684 }
1685
1686 teximage = read_color_image( ctx, x, y, width, height, format );
1687 if (!teximage) {
1688 gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D" );
1689 return;
1690 }
1691
1693 border, GL_RGBA, GL_UNSIGNED_BYTE, teximage );
1694
1695 /* teximage was freed in gl_TexImage2D */
1696}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_TEXTURE_2D
Definition: gl.h:645
void gl_TexImage2D(GLcontext *ctx, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, struct gl_image *image)
Definition: teximage.c:1133

Referenced by execute_list(), and init_exec_pointers().

◆ gl_CopyTexSubImage1D()

void gl_CopyTexSubImage1D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  xoffset,
GLint  x,
GLint  y,
GLsizei  width 
)

Definition at line 1783 of file teximage.c.

1786{
1787 struct gl_texture_image *teximage;
1788
1789 if (INSIDE_BEGIN_END(ctx)) {
1790 gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexSubImage1D" );
1791 return;
1792 }
1793 if (target!=GL_TEXTURE_1D) {
1794 gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
1795 return;
1796 }
1798 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage1D(level)" );
1799 return;
1800 }
1801 if (width<0) {
1802 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage1D(width)" );
1803 return;
1804 }
1805
1806 teximage = ctx->Texture.Current1D->Image[level];
1807
1808 if (teximage) {
1809 if (xoffset < -((GLint)teximage->Border)) {
1810 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage1D(xoffset)" );
1811 return;
1812 }
1813 /* NOTE: we're adding the border here, not subtracting! */
1814 if (xoffset+width > teximage->Width+teximage->Border) {
1816 "glCopyTexSubImage1D(xoffset+width)" );
1817 return;
1818 }
1819 if (teximage->Data) {
1820 copy_tex_sub_image( ctx, teximage, width, 1, x, y, xoffset, 0);
1821 }
1822 }
1823 else {
1824 gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexSubImage1D" );
1825 }
1826}
GLint GLint xoffset
Definition: gl.h:1547
GLubyte * Data
Definition: types.h:303
GLuint Width
Definition: types.h:296
GLuint Border
Definition: types.h:295
static void copy_tex_sub_image(GLcontext *ctx, struct gl_texture_image *dest, GLint width, GLint height, GLint srcx, GLint srcy, GLint dstx, GLint dsty)
Definition: teximage.c:1705

Referenced by execute_list(), and init_exec_pointers().

◆ gl_CopyTexSubImage2D()

void gl_CopyTexSubImage2D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  xoffset,
GLint  yoffset,
GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height 
)

Definition at line 1830 of file teximage.c.

1834{
1835 struct gl_texture_image *teximage;
1836
1837 if (INSIDE_BEGIN_END(ctx)) {
1838 gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D" );
1839 return;
1840 }
1841 if (target!=GL_TEXTURE_2D) {
1842 gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
1843 return;
1844 }
1846 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(level)" );
1847 return;
1848 }
1849 if (width<0) {
1850 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(width)" );
1851 return;
1852 }
1853 if (height<0) {
1854 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(height)" );
1855 return;
1856 }
1857
1858 teximage = ctx->Texture.Current2D->Image[level];
1859
1860 if (teximage) {
1861 if (xoffset < -((GLint)teximage->Border)) {
1862 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(xoffset)" );
1863 return;
1864 }
1865 if (yoffset < -((GLint)teximage->Border)) {
1866 gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(yoffset)" );
1867 return;
1868 }
1869 /* NOTE: we're adding the border here, not subtracting! */
1870 if (xoffset+width > teximage->Width+teximage->Border) {
1872 "glCopyTexSubImage2D(xoffset+width)" );
1873 return;
1874 }
1875 if (yoffset+height > teximage->Height+teximage->Border) {
1877 "glCopyTexSubImage2D(yoffset+height)" );
1878 return;
1879 }
1880
1881 if (teximage->Data) {
1882 copy_tex_sub_image( ctx, teximage, width, height,
1883 x, y, xoffset, yoffset);
1884 }
1885 }
1886 else {
1887 gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D" );
1888 }
1889}
GLint GLint GLint yoffset
Definition: gl.h:1547
GLuint Height
Definition: types.h:297

Referenced by execute_list(), and init_exec_pointers().

◆ gl_free_texture_image()

void gl_free_texture_image ( struct gl_texture_image teximage)

Definition at line 338 of file teximage.c.

339{
340 if (teximage->Data) {
341 free( teximage->Data );
342 }
343 free( teximage );
344}
#define free
Definition: debug_ros.c:5

Referenced by alloc_proxy_textures(), gl_free_texture_object(), gl_TexImage1D(), gl_TexImage2D(), gl_TexSubImage1D(), gl_TexSubImage2D(), and image_to_texture().

◆ gl_GetTexImage()

void gl_GetTexImage ( GLcontext ctx,
GLenum  target,
GLint  level,
GLenum  format,
GLenum  type,
GLvoid pixels 
)

Definition at line 1213 of file teximage.c.

1215{
1216 gl_problem(ctx, "glGetTexImage not implemented");
1217 /* TODO */
1218}
void gl_problem(const GLcontext *ctx, const char *s)
Definition: context.c:1394

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_tex_image_1D()

void gl_tex_image_1D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  internalformat,
GLsizei  width,
GLint  border,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)

◆ gl_tex_image_2D()

void gl_tex_image_2D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  internalformat,
GLsizei  width,
GLint  height,
GLint  border,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)

◆ gl_tex_image_3D()

void gl_tex_image_3D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  internalformat,
GLsizei  width,
GLint  height,
GLint  depth,
GLint  border,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)

◆ gl_TexImage1D()

void gl_TexImage1D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  internalformat,
GLsizei  width,
GLint  border,
GLenum  format,
GLenum  type,
struct gl_image teximage 
)

Definition at line 1049 of file teximage.c.

1053{
1054 if (INSIDE_BEGIN_END(ctx)) {
1055 gl_error( ctx, GL_INVALID_OPERATION, "glTexImage1D" );
1056 return;
1057 }
1058
1059 if (target==GL_TEXTURE_1D) {
1060 struct gl_texture_image *teximage;
1062 format, type, width, border )) {
1063 /* error in texture image was detected */
1064 return;
1065 }
1066
1067 /* free current texture image, if any */
1068 if (ctx->Texture.Current1D->Image[level]) {
1069 gl_free_texture_image( ctx->Texture.Current1D->Image[level] );
1070 }
1071
1072 /* make new texture from source image */
1073 if (image) {
1075 }
1076 else {
1078 width, 1, 1, border);
1079 }
1080
1081 /* install new texture image */
1082 ctx->Texture.Current1D->Image[level] = teximage;
1083 ctx->Texture.Current1D->Dirty = GL_TRUE;
1084 ctx->Texture.AnyDirty = GL_TRUE;
1085 ctx->NewState |= NEW_TEXTURING;
1086
1087 /* free the source image */
1088 if (image && image->RefCount==0) {
1089 /* if RefCount>0 then image must be in a display list */
1091 }
1092
1093 /* tell driver about change */
1094 if (ctx->Driver.TexImage) {
1095 (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D,
1096 ctx->Texture.Current1D,
1097 level, internalformat, teximage );
1098 }
1099 }
1100 else if (target==GL_PROXY_TEXTURE_1D) {
1101 /* Proxy texture: check for errors and update proxy state */
1103 format, type, width, border )) {
1104 if (level>=0 && level<MAX_TEXTURE_LEVELS) {
1105 MEMSET( ctx->Texture.Proxy1D->Image[level], 0,
1106 sizeof(struct gl_texture_image) );
1107 }
1108 }
1109 else {
1110 ctx->Texture.Proxy1D->Image[level]->Format = internalformat;
1111 ctx->Texture.Proxy1D->Image[level]->Border = border;
1112 ctx->Texture.Proxy1D->Image[level]->Width = width;
1113 ctx->Texture.Proxy1D->Image[level]->Height = 1;
1114 }
1115 if (image && image->RefCount==0) {
1116 /* if RefCount>0 then image must be in a display list */
1118 }
1119 }
1120 else {
1121 gl_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
1122 return;
1123 }
1124}
void gl_free_image(struct gl_image *image)
Definition: image.c:661
#define NEW_TEXTURING
Definition: types.h:1234
#define GL_TRUE
Definition: gl.h:174
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_PROXY_TEXTURE_1D
Definition: gl.h:726
#define MEMSET(DST, VAL, N)
Definition: macros.h:241
static GLboolean texture_1d_error_check(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLenum format, GLenum type, GLint width, GLint border)
Definition: teximage.c:888
static struct gl_texture_image * make_null_texture(GLcontext *ctx, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border)
Definition: teximage.c:813
void gl_free_texture_image(struct gl_texture_image *teximage)
Definition: teximage.c:338
static struct gl_texture_image * image_to_texture(GLcontext *ctx, const struct gl_image *image, GLenum internalFormat, GLint border)
Definition: teximage.c:357

Referenced by execute_list(), gl_CopyTexImage1D(), and init_exec_pointers().

◆ gl_TexImage2D()

void gl_TexImage2D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  internalformat,
GLsizei  width,
GLsizei  height,
GLint  border,
GLenum  format,
GLenum  type,
struct gl_image teximage 
)

Definition at line 1133 of file teximage.c.

1138{
1139 if (INSIDE_BEGIN_END(ctx)) {
1140 gl_error( ctx, GL_INVALID_OPERATION, "glTexImage2D" );
1141 return;
1142 }
1143
1144 if (target==GL_TEXTURE_2D) {
1145 struct gl_texture_image *teximage;
1147 format, type, width, height, border )) {
1148 /* error in texture image was detected */
1149 return;
1150 }
1151
1152 /* free current texture image, if any */
1153 if (ctx->Texture.Current2D->Image[level]) {
1154 gl_free_texture_image( ctx->Texture.Current2D->Image[level] );
1155 }
1156
1157 /* make new texture from source image */
1158 if (image) {
1160 }
1161 else {
1163 width, height, 1, border);
1164 }
1165
1166 /* install new texture image */
1167 ctx->Texture.Current2D->Image[level] = teximage;
1168 ctx->Texture.Current2D->Dirty = GL_TRUE;
1169 ctx->Texture.AnyDirty = GL_TRUE;
1170 ctx->NewState |= NEW_TEXTURING;
1171
1172 /* free the source image */
1173 if (image && image->RefCount==0) {
1174 /* if RefCount>0 then image must be in a display list */
1176 }
1177
1178 /* tell driver about change */
1179 if (ctx->Driver.TexImage) {
1180 (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D,
1181 ctx->Texture.Current2D,
1182 level, internalformat, teximage );
1183 }
1184 }
1185 else if (target==GL_PROXY_TEXTURE_2D) {
1186 /* Proxy texture: check for errors and update proxy state */
1188 format, type, width, height, border )) {
1189 if (level>=0 && level<MAX_TEXTURE_LEVELS) {
1190 MEMSET( ctx->Texture.Proxy2D->Image[level], 0,
1191 sizeof(struct gl_texture_image) );
1192 }
1193 }
1194 else {
1195 ctx->Texture.Proxy2D->Image[level]->Format = internalformat;
1196 ctx->Texture.Proxy2D->Image[level]->Border = border;
1197 ctx->Texture.Proxy2D->Image[level]->Width = width;
1198 ctx->Texture.Proxy2D->Image[level]->Height = height;
1199 }
1200 if (image && image->RefCount==0) {
1201 /* if RefCount>0 then image must be in a display list */
1203 }
1204 }
1205 else {
1206 gl_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" );
1207 return;
1208 }
1209}
#define GL_PROXY_TEXTURE_2D
Definition: gl.h:727
static GLboolean texture_2d_error_check(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLenum format, GLenum type, GLint width, GLint height, GLint border)
Definition: teximage.c:962

Referenced by execute_list(), gl_CopyTexImage2D(), and init_exec_pointers().

◆ gl_TexSubImage1D()

void gl_TexSubImage1D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  xoffset,
GLsizei  width,
GLenum  format,
GLenum  type,
struct gl_image image 
)

Definition at line 1249 of file teximage.c.

1253{
1254 struct gl_texture_image *destTex;
1255
1256 if (target!=GL_TEXTURE_1D) {
1257 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" );
1258 return;
1259 }
1261 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(level)" );
1262 return;
1263 }
1264
1265 destTex = ctx->Texture.Current1D->Image[level];
1266 if (!destTex) {
1267 gl_error( ctx, GL_INVALID_OPERATION, "glTexSubImage1D" );
1268 return;
1269 }
1270
1271 if (xoffset < -((GLint)destTex->Border)) {
1272 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage1D(xoffset)" );
1273 return;
1274 }
1275 if (xoffset + width > destTex->Width + destTex->Border) {
1276 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage1D(xoffset+width)" );
1277 return;
1278 }
1279
1280 if (image) {
1281 /* unpacking must have been error-free */
1282 GLint texcomponents = components_in_intformat(destTex->Format);
1283
1284 if (image->Type==GL_UNSIGNED_BYTE && texcomponents==image->Components) {
1285 /* Simple case, just byte copy image data into texture image */
1286 /* row by row. */
1287 GLubyte *dst = destTex->Data + texcomponents * xoffset;
1288 GLubyte *src = (GLubyte *) image->Data;
1289 MEMCPY( dst, src, width * texcomponents );
1290 }
1291 else {
1292 /* General case, convert image pixels into texels, scale, bias, etc */
1293 struct gl_texture_image *subTexImg = image_to_texture(ctx, image,
1294 destTex->IntFormat, destTex->Border);
1295 GLubyte *dst = destTex->Data + texcomponents * xoffset;
1296 GLubyte *src = subTexImg->Data;
1297 MEMCPY( dst, src, width * texcomponents );
1298 gl_free_texture_image(subTexImg);
1299 }
1300
1301 /* if the image's reference count is zero, delete it now */
1302 if (image->RefCount==0) {
1304 }
1305
1306 ctx->Texture.Current1D->Dirty = GL_TRUE;
1307 ctx->Texture.AnyDirty = GL_TRUE;
1308
1309 /* tell driver about change */
1310 if (ctx->Driver.TexSubImage) {
1311 (*ctx->Driver.TexSubImage)( ctx, GL_TEXTURE_1D,
1312 ctx->Texture.Current1D, level,
1313 xoffset,0,width,1,
1314 ctx->Texture.Current1D->Image[level]->IntFormat,
1315 destTex );
1316 }
1317 else {
1318 if (ctx->Driver.TexImage) {
1319 (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D,
1320 ctx->Texture.Current1D,
1321 level, ctx->Texture.Current1D->Image[level]->IntFormat,
1322 destTex );
1323 }
1324 }
1325 }
1326 else {
1327 /* if no image, an error must have occured, do more testing now */
1329
1330 if (width<0) {
1331 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage1D(width)" );
1332 return;
1333 }
1335 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(format)" );
1336 return;
1337 }
1341 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(format)" );
1342 return;
1343 }
1345 if (size<=0) {
1346 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(type)" );
1347 return;
1348 }
1349 /* if we get here, probably ran out of memory during unpacking */
1350 gl_error( ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D" );
1351 }
1352}
GLint gl_sizeof_type(GLenum type)
Definition: image.c:163
unsigned char GLubyte
Definition: gl.h:157
#define GL_BITMAP
Definition: gl.h:497
#define GL_DEPTH_COMPONENT
Definition: gl.h:307
#define GL_COLOR_INDEX
Definition: gl.h:479
#define GL_STENCIL_INDEX
Definition: gl.h:458
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLenum GLenum GLuint components
Definition: glext.h:9620
GLenum GLenum dst
Definition: glext.h:6340
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
GLenum Format
Definition: types.h:290
GLenum IntFormat
Definition: types.h:294
static GLint components_in_intformat(GLint format)
Definition: teximage.c:266

Referenced by execute_list(), and init_exec_pointers().

◆ gl_TexSubImage2D()

void gl_TexSubImage2D ( GLcontext ctx,
GLenum  target,
GLint  level,
GLint  xoffset,
GLint  yoffset,
GLsizei  width,
GLsizei  height,
GLenum  format,
GLenum  type,
struct gl_image image 
)

Definition at line 1356 of file teximage.c.

1362{
1363 struct gl_texture_image *destTex;
1364
1365 if (target!=GL_TEXTURE_2D) {
1366 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
1367 return;
1368 }
1370 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(level)" );
1371 return;
1372 }
1373
1374 destTex = ctx->Texture.Current2D->Image[level];
1375 if (!destTex) {
1376 gl_error( ctx, GL_INVALID_OPERATION, "glTexSubImage2D" );
1377 return;
1378 }
1379
1380 if (xoffset < -((GLint)destTex->Border)) {
1381 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(xoffset)" );
1382 return;
1383 }
1384 if (yoffset < -((GLint)destTex->Border)) {
1385 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(yoffset)" );
1386 return;
1387 }
1388 if (xoffset + width > destTex->Width + destTex->Border) {
1389 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(xoffset+width)" );
1390 return;
1391 }
1392 if (yoffset + height > destTex->Height + destTex->Border) {
1393 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(yoffset+height)" );
1394 return;
1395 }
1396
1397 if (image) {
1398 /* unpacking must have been error-free */
1399 GLint texcomponents = components_in_intformat(destTex->Format);
1400
1401 if (image->Type==GL_UNSIGNED_BYTE && texcomponents==image->Components) {
1402 /* Simple case, just byte copy image data into texture image */
1403 /* row by row. */
1404 GLubyte *dst = destTex->Data
1405 + (yoffset * destTex->Width + xoffset) * texcomponents;
1406 GLubyte *src = (GLubyte *) image->Data;
1407 GLint j;
1408 for (j=0;j<height;j++) {
1409 MEMCPY( dst, src, width * texcomponents );
1410 dst += destTex->Width * texcomponents * sizeof(GLubyte);
1411 src += width * texcomponents * sizeof(GLubyte);
1412 }
1413 }
1414 else {
1415 /* General case, convert image pixels into texels, scale, bias, etc */
1416 struct gl_texture_image *subTexImg = image_to_texture(ctx, image,
1417 destTex->IntFormat, destTex->Border);
1418 GLubyte *dst = destTex->Data
1419 + (yoffset * destTex->Width + xoffset) * texcomponents;
1420 GLubyte *src = subTexImg->Data;
1421 GLint j;
1422 for (j=0;j<height;j++) {
1423 MEMCPY( dst, src, width * texcomponents );
1424 dst += destTex->Width * texcomponents * sizeof(GLubyte);
1425 src += width * texcomponents * sizeof(GLubyte);
1426 }
1427 gl_free_texture_image(subTexImg);
1428 }
1429
1430 /* if the image's reference count is zero, delete it now */
1431 if (image->RefCount==0) {
1433 }
1434
1435 ctx->Texture.Current2D->Dirty = GL_TRUE;
1436 ctx->Texture.AnyDirty = GL_TRUE;
1437
1438 /* tell driver about change */
1439 if (ctx->Driver.TexSubImage) {
1440 (*ctx->Driver.TexSubImage)( ctx, GL_TEXTURE_2D, ctx->Texture.Current2D, level,
1442 ctx->Texture.Current2D->Image[level]->IntFormat,
1443 destTex );
1444 }
1445 else {
1446 if (ctx->Driver.TexImage) {
1447 (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D, ctx->Texture.Current2D,
1448 level, ctx->Texture.Current2D->Image[level]->IntFormat,
1449 destTex );
1450 }
1451 }
1452 }
1453 else {
1454 /* if no image, an error must have occured, do more testing now */
1456
1457 if (width<0) {
1458 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(width)" );
1459 return;
1460 }
1461 if (height<0) {
1462 gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(height)" );
1463 return;
1464 }
1466 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(format)" );
1467 return;
1468 }
1472 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(format)" );
1473 return;
1474 }
1476 if (size<=0) {
1477 gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(type)" );
1478 return;
1479 }
1480 /* if we get here, probably ran out of memory during unpacking */
1481 gl_error( ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D" );
1482 }
1483}
GLint gl_components_in_format(GLenum format)
Definition: image.c:193
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define for
Definition: utility.h:88

Referenced by execute_list(), and init_exec_pointers().

◆ gl_unpack_texsubimage()

struct gl_image * gl_unpack_texsubimage ( GLcontext ctx,
GLint  width,
GLint  height,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)

Definition at line 1229 of file teximage.c.

1231{
1233 return NULL;
1234 }
1235
1237 return NULL;
1238 }
1239
1240 if (gl_sizeof_type(type)<=0) {
1241 return NULL;
1242 }
1243
1245}
#define NULL
Definition: types.h:112
struct gl_image * gl_unpack_image(GLcontext *ctx, GLint width, GLint height, GLenum srcFormat, GLenum srcType, const GLvoid *pixels)
Definition: image.c:314
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546

Referenced by _mesa_TexSubImage1D(), and _mesa_TexSubImage2D().

◆ gl_unpack_texture()

struct gl_texture_image * gl_unpack_texture ( GLcontext ctx,
GLint  dimensions,
GLenum  target,
GLint  level,
GLint  internalformat,
GLsizei  width,
GLsizei  height,
GLint  border,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)

◆ gl_unpack_texture3D()

struct gl_texture_image * gl_unpack_texture3D ( GLcontext ctx,
GLint  dimensions,
GLenum  target,
GLint  level,
GLint  internalformat,
GLsizei  width,
GLsizei  height,
GLsizei  depth,
GLint  border,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)