ReactOS 0.4.15-dev-7654-g6bc40d3
colortab.c File Reference
#include "colortab.h"
#include "context.h"
#include "macros.h"
Include dependency graph for colortab.c:

Go to the source code of this file.

Functions

static GLboolean power_of_two (GLint k)
 
static GLint decode_internal_format (GLint format)
 
void gl_ColorTable (GLcontext *ctx, GLenum target, GLenum internalFormat, struct gl_image *table)
 
void gl_ColorSubTable (GLcontext *ctx, GLenum target, GLsizei start, struct gl_image *data)
 
void gl_GetColorTable (GLcontext *ctx, GLenum target, GLenum format, GLenum type, GLvoid *table)
 
void gl_GetColorTableParameterfv (GLcontext *ctx, GLenum target, GLenum pname, GLfloat *params)
 
void gl_GetColorTableParameteriv (GLcontext *ctx, GLenum target, GLenum pname, GLint *params)
 

Function Documentation

◆ decode_internal_format()

static GLint decode_internal_format ( GLint  format)
static

Definition at line 72 of file colortab.c.

73{
74 switch (format) {
75 case GL_ALPHA:
76 case GL_ALPHA4:
77 case GL_ALPHA8:
78 case GL_ALPHA12:
79 case GL_ALPHA16:
80 return GL_ALPHA;
81 case 1:
82 case GL_LUMINANCE:
83 case GL_LUMINANCE4:
84 case GL_LUMINANCE8:
85 case GL_LUMINANCE12:
86 case GL_LUMINANCE16:
87 return GL_LUMINANCE;
88 case 2:
96 return GL_LUMINANCE_ALPHA;
97 case GL_INTENSITY:
98 case GL_INTENSITY4:
99 case GL_INTENSITY8:
100 case GL_INTENSITY12:
101 case GL_INTENSITY16:
102 return GL_INTENSITY;
103 case 3:
104 case GL_RGB:
105 case GL_R3_G3_B2:
106 case GL_RGB4:
107 case GL_RGB5:
108 case GL_RGB8:
109 case GL_RGB10:
110 case GL_RGB12:
111 case GL_RGB16:
112 return GL_RGB;
113 case 4:
114 case GL_RGBA:
115 case GL_RGBA2:
116 case GL_RGBA4:
117 case GL_RGB5_A1:
118 case GL_RGBA8:
119 case GL_RGB10_A2:
120 case GL_RGBA12:
121 case GL_RGBA16:
122 return GL_RGBA;
123 default:
124 return -1; /* error */
125 }
126}
#define GL_RGBA12
Definition: gl.h:764
#define GL_R3_G3_B2
Definition: gl.h:752
#define GL_RGB10
Definition: gl.h:756
#define GL_ALPHA8
Definition: gl.h:734
#define GL_RGBA8
Definition: gl.h:762
#define GL_INTENSITY8
Definition: gl.h:749
#define GL_ALPHA12
Definition: gl.h:735
#define GL_ALPHA4
Definition: gl.h:733
#define GL_RGB16
Definition: gl.h:758
#define GL_LUMINANCE8
Definition: gl.h:738
#define GL_LUMINANCE_ALPHA
Definition: gl.h:485
#define GL_RGB5
Definition: gl.h:754
#define GL_INTENSITY
Definition: gl.h:747
#define GL_LUMINANCE4_ALPHA4
Definition: gl.h:741
#define GL_RGB5_A1
Definition: gl.h:761
#define GL_RGBA2
Definition: gl.h:759
#define GL_RGB8
Definition: gl.h:755
#define GL_LUMINANCE
Definition: gl.h:484
#define GL_LUMINANCE12_ALPHA4
Definition: gl.h:744
#define GL_RGB4
Definition: gl.h:753
#define GL_RGB
Definition: gl.h:502
#define GL_LUMINANCE12_ALPHA12
Definition: gl.h:745
#define GL_INTENSITY16
Definition: gl.h:751
#define GL_LUMINANCE16_ALPHA16
Definition: gl.h:746
#define GL_RGB10_A2
Definition: gl.h:763
#define GL_LUMINANCE12
Definition: gl.h:739
#define GL_RGBA
Definition: gl.h:503
#define GL_LUMINANCE8_ALPHA8
Definition: gl.h:743
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define GL_LUMINANCE4
Definition: gl.h:737
#define GL_INTENSITY12
Definition: gl.h:750
#define GL_RGB12
Definition: gl.h:757
#define GL_LUMINANCE6_ALPHA2
Definition: gl.h:742
#define GL_ALPHA
Definition: gl.h:483
#define GL_LUMINANCE16
Definition: gl.h:740
#define GL_RGBA16
Definition: gl.h:765
#define GL_ALPHA16
Definition: gl.h:736
#define GL_INTENSITY4
Definition: gl.h:748
#define GL_RGBA4
Definition: gl.h:760

Referenced by gl_ColorTable().

◆ gl_ColorSubTable()

void gl_ColorSubTable ( GLcontext ctx,
GLenum  target,
GLsizei  start,
struct gl_image data 
)

Definition at line 187 of file colortab.c.

189{
190 /* XXX TODO */
191 gl_problem(ctx, "glColorSubTableEXT not implemented");
192}
void gl_problem(const GLcontext *ctx, const char *s)
Definition: context.c:1394

Referenced by execute_list(), and init_exec_pointers().

◆ gl_ColorTable()

void gl_ColorTable ( GLcontext ctx,
GLenum  target,
GLenum  internalFormat,
struct gl_image table 
)

Definition at line 129 of file colortab.c.

131{
132 struct gl_texture_object *texObj;
134
135 if (INSIDE_BEGIN_END(ctx)) {
136 gl_error( ctx, GL_INVALID_OPERATION, "glGetBooleanv" );
137 return;
138 }
139
140 switch (target) {
141 case GL_TEXTURE_1D:
142 texObj = ctx->Texture.Current1D;
143 break;
144 case GL_TEXTURE_2D:
145 texObj = ctx->Texture.Current2D;
146 break;
148 texObj = ctx->Texture.Proxy1D;
149 proxy = GL_TRUE;
150 break;
152 texObj = ctx->Texture.Proxy2D;
153 proxy = GL_TRUE;
154 break;
155 default:
156 gl_error(ctx, GL_INVALID_ENUM, "glColorTableEXT(target)");
157 return;
158 }
159
160 /* internalformat = just like glTexImage */
161
162 if (table->Width < 1 || table->Width > MAX_TEXTURE_PALETTE_SIZE
163 || !power_of_two(table->Width)) {
164 gl_error(ctx, GL_INVALID_VALUE, "glColorTableEXT(width)");
165 if (proxy) {
166 texObj->PaletteSize = 0;
167 texObj->PaletteIntFormat = 0;
168 texObj->PaletteFormat = 0;
169 }
170 return;
171 }
172
173 /* per-texture object palette */
174 texObj->PaletteSize = table->Width;
177 if (!proxy) {
178 MEMCPY(texObj->Palette, table->Data, table->Width*table->Components);
179 if (ctx->Driver.UpdateTexturePalette) {
180 (*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
181 }
182 }
183}
static GLboolean power_of_two(GLint k)
Definition: colortab.c:60
static GLint decode_internal_format(GLint format)
Definition: colortab.c:72
#define MAX_TEXTURE_PALETTE_SIZE
Definition: config.h:122
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
int proxy
Definition: main.c:67
#define GL_TRUE
Definition: gl.h:174
#define GL_INVALID_VALUE
Definition: gl.h:695
#define GL_PROXY_TEXTURE_2D
Definition: gl.h:727
#define GL_INVALID_OPERATION
Definition: gl.h:696
#define GL_FALSE
Definition: gl.h:173
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_PROXY_TEXTURE_1D
Definition: gl.h:726
unsigned char GLboolean
Definition: gl.h:151
#define GL_INVALID_ENUM
Definition: gl.h:694
GLenum internalFormat
Definition: glext.h:8404
GLenum target
Definition: glext.h:7315
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
#define INSIDE_BEGIN_END(CTX)
Definition: macros.h:135
GLuint PaletteSize
Definition: types.h:1104
GLenum PaletteIntFormat
Definition: types.h:1105
GLubyte Palette[MAX_TEXTURE_PALETTE_SIZE *4]
Definition: types.h:1103
GLenum PaletteFormat
Definition: types.h:1106

Referenced by execute_list(), and init_exec_pointers().

◆ gl_GetColorTable()

void gl_GetColorTable ( GLcontext ctx,
GLenum  target,
GLenum  format,
GLenum  type,
GLvoid table 
)

Definition at line 196 of file colortab.c.

198{
199 if (INSIDE_BEGIN_END(ctx)) {
200 gl_error( ctx, GL_INVALID_OPERATION, "glGetBooleanv" );
201 return;
202 }
203
204 switch (target) {
205 case GL_TEXTURE_1D:
206 break;
207 case GL_TEXTURE_2D:
208 break;
210 break;
211 default:
212 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableEXT(target)");
213 return;
214 }
215
216 gl_problem(ctx, "glGetColorTableEXT not implemented!");
217}
#define GL_TEXTURE_3D_EXT
Definition: glext.h:2471

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_GetColorTableParameterfv()

void gl_GetColorTableParameterfv ( GLcontext ctx,
GLenum  target,
GLenum  pname,
GLfloat params 
)

Definition at line 221 of file colortab.c.

223{
224 GLint iparams[10];
225
227 *params = (GLfloat) iparams[0];
228}
void gl_GetColorTableParameteriv(GLcontext *ctx, GLenum target, GLenum pname, GLint *params)
Definition: colortab.c:232
float GLfloat
Definition: gl.h:161
int GLint
Definition: gl.h:156
GLenum pname
Definition: glext.h:5645
GLenum const GLfloat * params
Definition: glext.h:5645

◆ gl_GetColorTableParameteriv()

void gl_GetColorTableParameteriv ( GLcontext ctx,
GLenum  target,
GLenum  pname,
GLint params 
)

Definition at line 232 of file colortab.c.

234{
235 struct gl_texture_object *texObj;
236
237 if (INSIDE_BEGIN_END(ctx)) {
238 gl_error( ctx, GL_INVALID_OPERATION, "glGetColorTableParameter" );
239 return;
240 }
241
242 switch (target) {
243 case GL_TEXTURE_1D:
244 texObj = ctx->Texture.Current1D;
245 break;
246 case GL_TEXTURE_2D:
247 texObj = ctx->Texture.Current2D;
248 break;
249 default:
250 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
251 return;
252 }
253
254 switch (pname) {
256 if (texObj)
257 *params = texObj->PaletteIntFormat;
258 break;
260 if (texObj)
261 *params = texObj->PaletteSize;
262 break;
264 *params = 8;
265 break;
267 *params = 8;
268 break;
270 *params = 8;
271 break;
273 *params = 8;
274 break;
276 *params = 8;
277 break;
279 *params = 8;
280 break;
281 default:
282 gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter" );
283 return;
284 }
285}
#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT
Definition: colortab.h:45
#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT
Definition: colortab.h:44
#define GL_COLOR_TABLE_GREEN_SIZE_EXT
Definition: colortab.h:41
#define GL_COLOR_TABLE_BLUE_SIZE_EXT
Definition: colortab.h:42
#define GL_COLOR_TABLE_ALPHA_SIZE_EXT
Definition: colortab.h:43
#define GL_COLOR_TABLE_WIDTH_EXT
Definition: colortab.h:39
#define GL_COLOR_TABLE_FORMAT_EXT
Definition: colortab.h:38
#define GL_COLOR_TABLE_RED_SIZE_EXT
Definition: colortab.h:40

Referenced by gl_GetColorTableParameterfv(), init_dlist_pointers(), and init_exec_pointers().

◆ power_of_two()

static GLboolean power_of_two ( GLint  k)
static

Definition at line 60 of file colortab.c.

61{
62 GLint i, m = 1;
63 for (i=0; i<32; i++) {
64 if (k == m)
65 return GL_TRUE;
66 m = m << 1;
67 }
68 return GL_FALSE;
69}
const GLfloat * m
Definition: glext.h:10848
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 i
Definition: glfuncs.h:248
int k
Definition: mpi.c:3369

Referenced by gl_ColorTable().