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

Go to the source code of this file.

Functions

void gl_texgen (GLcontext *ctx, GLint n, GLfloat obj[][4], GLfloat eye[][4], GLfloat normal[][3], GLfloat texcoord[][4])
 
void gl_set_texture_sampler (struct gl_texture_object *t)
 
void gl_texture_pixels (GLcontext *ctx, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat r[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
 

Function Documentation

◆ gl_set_texture_sampler()

void gl_set_texture_sampler ( struct gl_texture_object t)

Definition at line 1319 of file texture.c.

1320{
1321 if (!t->Complete) {
1322 t->SampleFunc = NULL;
1323 }
1324 else {
1325 GLboolean needLambda = (t->MinFilter != t->MagFilter);
1326
1327 if (needLambda) {
1328 /* Compute min/mag filter threshold */
1329 if (t->MagFilter==GL_LINEAR
1330 && (t->MinFilter==GL_NEAREST_MIPMAP_NEAREST ||
1331 t->MinFilter==GL_LINEAR_MIPMAP_NEAREST)) {
1332 t->MinMagThresh = 0.5F;
1333 }
1334 else {
1335 t->MinMagThresh = 0.0F;
1336 }
1337 }
1338
1339 switch (t->Dimensions) {
1340 case 1:
1341 if (needLambda) {
1342 t->SampleFunc = sample_lambda_1d;
1343 }
1344 else if (t->MinFilter==GL_LINEAR) {
1345 t->SampleFunc = sample_linear_1d;
1346 }
1347 else {
1348 ASSERT(t->MinFilter==GL_NEAREST);
1349 t->SampleFunc = sample_nearest_1d;
1350 }
1351 break;
1352 case 2:
1353 if (needLambda) {
1354 t->SampleFunc = sample_lambda_2d;
1355 }
1356 else if (t->MinFilter==GL_LINEAR) {
1357 t->SampleFunc = sample_linear_2d;
1358 }
1359 else {
1360 ASSERT(t->MinFilter==GL_NEAREST);
1361 if (t->WrapS==GL_REPEAT && t->WrapT==GL_REPEAT
1362 && t->Image[0]->Border==0 && t->Image[0]->Format==GL_RGB) {
1363 t->SampleFunc = opt_sample_rgb_2d;
1364 }
1365 else if (t->WrapS==GL_REPEAT && t->WrapT==GL_REPEAT
1366 && t->Image[0]->Border==0 && t->Image[0]->Format==GL_RGBA) {
1367 t->SampleFunc = opt_sample_rgba_2d;
1368 }
1369 else
1370 t->SampleFunc = sample_nearest_2d;
1371 }
1372 break;
1373 default:
1374 gl_problem(NULL, "invalid dimensions in gl_set_texture_sampler");
1375 }
1376 }
1377}
#define NULL
Definition: types.h:112
void gl_problem(const GLcontext *ctx, const char *s)
Definition: context.c:1394
static void sample_lambda_2d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:1180
static void opt_sample_rgba_2d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lamda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:1281
static void sample_linear_2d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:1162
static void sample_nearest_1d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:676
static void sample_nearest_2d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:1147
static void opt_sample_rgb_2d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lamda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:1246
static void sample_linear_1d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:691
static void sample_lambda_1d(const struct gl_texture_object *tObj, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat u[], const GLfloat lambda[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[])
Definition: texture.c:710
#define GL_NEAREST_MIPMAP_NEAREST
Definition: gl.h:667
#define GL_LINEAR
Definition: gl.h:421
#define GL_RGB
Definition: gl.h:502
#define GL_NEAREST
Definition: gl.h:678
#define GL_RGBA
Definition: gl.h:503
#define GL_LINEAR_MIPMAP_NEAREST
Definition: gl.h:669
#define GL_REPEAT
Definition: gl.h:679
GLdouble GLdouble t
Definition: gl.h:2047
unsigned char GLboolean
Definition: gl.h:151
#define ASSERT(a)
Definition: mode.c:44

Referenced by gl_update_texture_state().

◆ gl_texgen()

void gl_texgen ( GLcontext ctx,
GLint  n,
GLfloat  obj[][4],
GLfloat  eye[][4],
GLfloat  normal[][3],
GLfloat  texcoord[][4] 
)

Definition at line 163 of file texture.c.

166{
167 /* special case: S and T sphere mapping */
168 if (ctx->Texture.TexGenEnabled==(S_BIT|T_BIT)
169 && ctx->Texture.GenModeS==GL_SPHERE_MAP
170 && ctx->Texture.GenModeT==GL_SPHERE_MAP) {
171 GLint i;
172 for (i=0;i<n;i++) {
173 GLfloat u[3], two_nu, m, fx, fy, fz;
174 COPY_3V( u, eye[i] );
175 NORMALIZE_3FV( u );
176 two_nu = 2.0F * DOT3(normal[i],u);
177 fx = u[0] - normal[i][0] * two_nu;
178 fy = u[1] - normal[i][1] * two_nu;
179 fz = u[2] - normal[i][2] * two_nu;
180 m = 2.0F * GL_SQRT( fx*fx + fy*fy + (fz+1.0F)*(fz+1.0F) );
181 if (m==0.0F) {
182 texcoord[i][0] = 0.5F;
183 texcoord[i][1] = 0.5F;
184 }
185 else {
186 GLfloat mInv = 1.0F / m;
187 texcoord[i][0] = fx * mInv + 0.5F;
188 texcoord[i][1] = fy * mInv + 0.5F;
189 }
190 }
191 return;
192 }
193
194 /* general solution */
195 if (ctx->Texture.TexGenEnabled & S_BIT) {
196 GLint i;
197 switch (ctx->Texture.GenModeS) {
198 case GL_OBJECT_LINEAR:
199 for (i=0;i<n;i++) {
200 texcoord[i][0] = DOT4( obj[i], ctx->Texture.ObjectPlaneS );
201 }
202 break;
203 case GL_EYE_LINEAR:
204 for (i=0;i<n;i++) {
205 texcoord[i][0] = DOT4( eye[i], ctx->Texture.EyePlaneS );
206 }
207 break;
208 case GL_SPHERE_MAP:
209 for (i=0;i<n;i++) {
210 GLfloat u[3], two_nu, m, fx, fy, fz;
211 COPY_3V( u, eye[i] );
212 NORMALIZE_3FV( u );
213 two_nu = 2.0*DOT3(normal[i],u);
214 fx = u[0] - normal[i][0] * two_nu;
215 fy = u[1] - normal[i][1] * two_nu;
216 fz = u[2] - normal[i][2] * two_nu;
217 m = 2.0F * GL_SQRT( fx*fx + fy*fy + (fz+1.0)*(fz+1.0) );
218 if (m==0.0F) {
219 texcoord[i][0] = 0.5F;
220 }
221 else {
222 texcoord[i][0] = fx / m + 0.5F;
223 }
224 }
225 break;
226 default:
227 gl_problem(ctx, "Bad S texgen");
228 return;
229 }
230 }
231
232 if (ctx->Texture.TexGenEnabled & T_BIT) {
233 GLint i;
234 switch (ctx->Texture.GenModeT) {
235 case GL_OBJECT_LINEAR:
236 for (i=0;i<n;i++) {
237 texcoord[i][1] = DOT4( obj[i], ctx->Texture.ObjectPlaneT );
238 }
239 break;
240 case GL_EYE_LINEAR:
241 for (i=0;i<n;i++) {
242 texcoord[i][1] = DOT4( eye[i], ctx->Texture.EyePlaneT );
243 }
244 break;
245 case GL_SPHERE_MAP:
246 for (i=0;i<n;i++) {
247 GLfloat u[3], two_nu, m, fx, fy, fz;
248 COPY_3V( u, eye[i] );
249 NORMALIZE_3FV( u );
250 two_nu = 2.0*DOT3(normal[i],u);
251 fx = u[0] - normal[i][0] * two_nu;
252 fy = u[1] - normal[i][1] * two_nu;
253 fz = u[2] - normal[i][2] * two_nu;
254 m = 2.0F * GL_SQRT( fx*fx + fy*fy + (fz+1.0)*(fz+1.0) );
255 if (m==0.0F) {
256 texcoord[i][1] = 0.5F;
257 }
258 else {
259 texcoord[i][1] = fy / m + 0.5F;
260 }
261 }
262 break;
263 default:
264 gl_problem(ctx, "Bad T texgen");
265 return;
266 }
267 }
268
269 if (ctx->Texture.TexGenEnabled & R_BIT) {
270 GLint i;
271 switch (ctx->Texture.GenModeR) {
272 case GL_OBJECT_LINEAR:
273 for (i=0;i<n;i++) {
274 texcoord[i][2] = DOT4( obj[i], ctx->Texture.ObjectPlaneR );
275 }
276 break;
277 case GL_EYE_LINEAR:
278 for (i=0;i<n;i++) {
279 texcoord[i][2] = DOT4( eye[i], ctx->Texture.EyePlaneR );
280 }
281 break;
282 default:
283 gl_problem(ctx, "Bad R texgen");
284 return;
285 }
286 }
287
288 if (ctx->Texture.TexGenEnabled & Q_BIT) {
289 GLint i;
290 switch (ctx->Texture.GenModeQ) {
291 case GL_OBJECT_LINEAR:
292 for (i=0;i<n;i++) {
293 texcoord[i][3] = DOT4( obj[i], ctx->Texture.ObjectPlaneQ );
294 }
295 break;
296 case GL_EYE_LINEAR:
297 for (i=0;i<n;i++) {
298 texcoord[i][3] = DOT4( eye[i], ctx->Texture.EyePlaneQ );
299 }
300 break;
301 default:
302 gl_problem(ctx, "Bad Q texgen");
303 return;
304 }
305 }
306}
#define S_BIT
Definition: types.h:891
#define R_BIT
Definition: types.h:890
#define Q_BIT
Definition: types.h:889
#define T_BIT
Definition: types.h:892
float GLfloat
Definition: gl.h:161
#define GL_SPHERE_MAP
Definition: gl.h:675
#define GL_OBJECT_LINEAR
Definition: gl.h:671
int GLint
Definition: gl.h:156
#define GL_EYE_LINEAR
Definition: gl.h:673
GLdouble n
Definition: glext.h:7729
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
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 * u
Definition: glfuncs.h:240
#define DOT4(a, b)
Definition: macros.h:171
#define COPY_3V(DST, SRC)
Definition: macros.h:98
#define DOT3(a, b)
Definition: macros.h:167
#define NORMALIZE_3FV(V)
Definition: mmath.h:68
#define GL_SQRT(X)
Definition: mmath.h:63
@ normal
Definition: optimize.h:166
GLfixed fx
Definition: tritemp.h:484
GLfixed fy
Definition: tritemp.h:490

Referenced by gl_transform_vb_part2().

◆ gl_texture_pixels()

void gl_texture_pixels ( GLcontext ctx,
GLuint  n,
const GLfloat  s[],
const GLfloat  t[],
const GLfloat  r[],
const GLfloat  lambda[],
GLubyte  red[],
GLubyte  green[],
GLubyte  blue[],
GLubyte  alpha[] 
)

Definition at line 1678 of file texture.c.

1683{
1684 GLubyte tred[PB_SIZE];
1685 GLubyte tgreen[PB_SIZE];
1686 GLubyte tblue[PB_SIZE];
1687 GLubyte talpha[PB_SIZE];
1688
1689 if (!ctx->Texture.Current || !ctx->Texture.Current->SampleFunc)
1690 return;
1691
1692 /* Sample the texture. */
1693 (*ctx->Texture.Current->SampleFunc)( ctx->Texture.Current, n,
1694 s, t, r, lambda,
1695 tred, tgreen, tblue, talpha );
1696
1698 ctx->Texture.Current->Image[0]->Format,
1699 ctx->Texture.EnvMode,
1700 red, green, blue, alpha,
1701 tred, tgreen, tblue, talpha );
1702}
static void apply_texture(GLcontext *ctx, GLuint n, GLint format, GLenum env_mode, GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[], GLubyte Rt[], GLubyte Gt[], GLubyte Bt[], GLubyte At[])
Definition: texture.c:1396
unsigned char GLubyte
Definition: gl.h:157
GLclampf green
Definition: gl.h:1740
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLclampf GLclampf blue
Definition: gl.h:1740
#define red
Definition: linetest.c:67
#define PB_SIZE
Definition: pb.h:52

Referenced by gl_flush_pb(), and gl_write_texture_span().