182 texcoord[
i][0] = 0.5F;
183 texcoord[
i][1] = 0.5F;
187 texcoord[
i][0] =
fx * mInv + 0.5F;
188 texcoord[
i][1] =
fy * mInv + 0.5F;
195 if (
ctx->Texture.TexGenEnabled &
S_BIT) {
197 switch (
ctx->Texture.GenModeS) {
200 texcoord[
i][0] =
DOT4(
obj[
i],
ctx->Texture.ObjectPlaneS );
205 texcoord[
i][0] =
DOT4( eye[
i],
ctx->Texture.EyePlaneS );
219 texcoord[
i][0] = 0.5F;
222 texcoord[
i][0] =
fx /
m + 0.5F;
232 if (
ctx->Texture.TexGenEnabled &
T_BIT) {
234 switch (
ctx->Texture.GenModeT) {
237 texcoord[
i][1] =
DOT4(
obj[
i],
ctx->Texture.ObjectPlaneT );
242 texcoord[
i][1] =
DOT4( eye[
i],
ctx->Texture.EyePlaneT );
256 texcoord[
i][1] = 0.5F;
259 texcoord[
i][1] =
fy /
m + 0.5F;
269 if (
ctx->Texture.TexGenEnabled &
R_BIT) {
271 switch (
ctx->Texture.GenModeR) {
274 texcoord[
i][2] =
DOT4(
obj[
i],
ctx->Texture.ObjectPlaneR );
279 texcoord[
i][2] =
DOT4( eye[
i],
ctx->Texture.EyePlaneR );
288 if (
ctx->Texture.TexGenEnabled &
Q_BIT) {
290 switch (
ctx->Texture.GenModeQ) {
293 texcoord[
i][3] =
DOT4(
obj[
i],
ctx->Texture.ObjectPlaneQ );
298 texcoord[
i][3] =
DOT4( eye[
i],
ctx->Texture.EyePlaneQ );
364#define frac(x) ((GLfloat)(x)-floor((GLfloat)x))
384 switch (
img->Format) {
400 texel =
img->Data +
i * 2;
405 texel =
img->Data +
i * 3;
411 texel =
img->Data +
i * 4;
458 switch (
img->Format) {
473 texel =
img->Data +
i * 2;
478 texel =
img->Data +
i * 3;
484 texel =
img->Data +
i * 4;
509 GLint i0border, i1border;
514 i1 = (i0 + 1) & (
width-1);
515 i0border = i1border = 0;
520 i0border = (i0<0) | (i0>=
width);
521 i1border = (i1<0) | (i1>=
width);
527 i0border = i1border = 0;
539 GLubyte red0, green0, blue0, alpha0;
540 GLubyte red1, green1, blue1, alpha1;
561 *
red = (w0*red0 +
w1*red1) >> 8;
562 *
green = (w0*green0 +
w1*green1) >> 8;
563 *
blue = (w0*blue0 +
w1*blue1) >> 8;
564 *
alpha = (w0*alpha0 +
w1*alpha1) >> 8;
582 if (
level>widthlog2 ) {
604 if (
level>widthlog2 ) {
627 GLubyte red0, green0, blue0, alpha0;
628 GLubyte red1, green1, blue1, alpha1;
633 s, &red0, &green0, &blue0, &alpha0 );
635 s, &red1, &green1, &blue1, &alpha1 );
636 *
red = (1.0F-
f)*red0 +
f*red1;
637 *
green = (1.0F-
f)*green0 +
f*green1;
638 *
blue = (1.0F-
f)*blue0 +
f*blue1;
639 *
alpha = (1.0F-
f)*alpha0 +
f*alpha1;
658 GLubyte red0, green0, blue0, alpha0;
659 GLubyte red1, green1, blue1, alpha1;
664 s, &red0, &green0, &blue0, &alpha0 );
666 s, &red1, &green1, &blue1, &alpha1 );
667 *
red = (1.0F-
f)*red0 +
f*red1;
668 *
green = (1.0F-
f)*green0 +
f*green1;
669 *
blue = (1.0F-
f)*blue0 +
f*blue1;
670 *
alpha = (1.0F-
f)*alpha0 +
f*alpha1;
796 switch (
img->Format) {
886 switch (
img->Format) {
898 *
red =
img->Data[
j * imgWidth +
i ];
901 texel =
img->Data + ((
j * imgWidth +
i) << 1);
906 texel =
img->Data + (
j * imgWidth +
i) * 3;
912 texel =
img->Data + ((
j * imgWidth +
i) << 2);
936 GLint i0, j0, i1, j1;
937 GLint i0border, j0border, i1border, j1border;
943 i1 = (i0 + 1) & (
width-1);
944 i0border = i1border = 0;
949 i0border = (i0<0) | (i0>=
width);
950 i1border = (i1<0) | (i1>=
width);
956 j1 = (j0 + 1) & (
height-1);
957 j0border = j1border = 0;
962 j0border = (j0<0) | (j0>=
height);
963 j1border = (j1<0) | (j1>=
height);
971 i0border = i1border = 0;
972 j0border = j1border = 0;
988 GLubyte red00, green00, blue00, alpha00;
989 GLubyte red10, green10, blue10, alpha10;
990 GLubyte red01, green01, blue01, alpha01;
991 GLubyte red11, green11, blue11, alpha11;
993 if (i0border | j0border) {
1000 get_2d_texel( tObj,
img, i0, j0, &red00, &green00, &blue00, &alpha00);
1002 if (i1border | j0border) {
1009 get_2d_texel( tObj,
img, i1, j0, &red10, &green10, &blue10, &alpha10);
1011 if (i0border | j1border) {
1018 get_2d_texel( tObj,
img, i0, j1, &red01, &green01, &blue01, &alpha01);
1020 if (i1border | j1border) {
1027 get_2d_texel( tObj,
img, i1, j1, &red11, &green11, &blue11, &alpha11);
1030 *
red = (w00*red00 + w10*red10 + w01*red01 + w11*red11 ) >> 8;
1031 *
green = (w00*green00 + w10*green10 + w01*green01 + w11*green11) >> 8;
1032 *
blue = (w00*blue00 + w10*blue10 + w01*blue01 + w11*blue11 ) >> 8;
1033 *
alpha = (w00*alpha00 + w10*alpha10 + w01*alpha01 + w11*alpha11) >> 8;
1098 GLubyte red0, green0, blue0, alpha0;
1099 GLubyte red1, green1, blue1, alpha1;
1104 &red0, &green0, &blue0, &alpha0 );
1106 &red1, &green1, &blue1, &alpha1 );
1107 *
red = (1.0F-
f)*red0 +
f*red1;
1108 *
green = (1.0F-
f)*green0 +
f*green1;
1109 *
blue = (1.0F-
f)*blue0 +
f*blue1;
1110 *
alpha = (1.0F-
f)*alpha0 +
f*alpha1;
1129 GLubyte red0, green0, blue0, alpha0;
1130 GLubyte red1, green1, blue1, alpha1;
1135 &red0, &green0, &blue0, &alpha0 );
1137 &red1, &green1, &blue1, &alpha1 );
1138 *
red = (1.0F-
f)*red0 +
f*red1;
1139 *
green = (1.0F-
f)*green0 +
f*green1;
1140 *
blue = (1.0F-
f)*blue0 +
f*blue1;
1141 *
alpha = (1.0F-
f)*alpha0 +
f*alpha1;
1254 GLint colMask =
img->Width-1, rowMask =
img->Height-1;
1289 GLint colMask =
img->Width-1, rowMask =
img->Height-1;
1322 t->SampleFunc =
NULL;
1325 GLboolean needLambda = (
t->MinFilter !=
t->MagFilter);
1332 t->MinMagThresh = 0.5F;
1335 t->MinMagThresh = 0.0F;
1339 switch (
t->Dimensions) {
1362 &&
t->Image[0]->Border==0 &&
t->Image[0]->Format==
GL_RGB) {
1366 &&
t->Image[0]->Border==0 &&
t->Image[0]->Format==
GL_RGBA) {
1374 gl_problem(
NULL,
"invalid dimensions in gl_set_texture_sampler");
1402 GLint Rc, Gc, Bc, Ac;
1404 if (!
ctx->Visual->EightBitColor) {
1406 GLfloat rscale = 255.0 *
ctx->Visual->InvRedScale;
1407 GLfloat gscale = 255.0 *
ctx->Visual->InvGreenScale;
1408 GLfloat bscale = 255.0 *
ctx->Visual->InvBlueScale;
1409 GLfloat ascale = 255.0 *
ctx->Visual->InvAlphaScale;
1422#define PROD(A,B) (((GLint)(A) * ((GLint)(B)+1)) >> 8)
1589 Rc = (
GLint) (
ctx->Texture.EnvColor[0] * 255.0F);
1590 Gc = (
GLint) (
ctx->Texture.EnvColor[1] * 255.0F);
1591 Bc = (
GLint) (
ctx->Texture.EnvColor[2] * 255.0F);
1592 Ac = (
GLint) (
ctx->Texture.EnvColor[3] * 255.0F);
1604 GLint Lt = Rt[
i],
s = 255 - Lt;
1614 GLint Lt = Rt[
i],
s = 255 - Lt;
1661 if (!
ctx->Visual->EightBitColor) {
1663 GLfloat rscale =
ctx->Visual->RedScale * (1.0F/ 255.0F);
1664 GLfloat gscale =
ctx->Visual->GreenScale * (1.0F/ 255.0F);
1665 GLfloat bscale =
ctx->Visual->BlueScale * (1.0F/ 255.0F);
1666 GLfloat ascale =
ctx->Visual->AlphaScale * (1.0F/ 255.0F);
1689 if (!
ctx->Texture.Current || !
ctx->Texture.Current->SampleFunc)
1693 (*
ctx->Texture.Current->SampleFunc)(
ctx->Texture.Current,
n,
1695 tred, tgreen, tblue, talpha );
1698 ctx->Texture.Current->Image[0]->Format,
1699 ctx->Texture.EnvMode,
1701 tred, tgreen, tblue, talpha );
void gl_problem(const GLcontext *ctx, const char *s)
void gl_texgen(GLcontext *ctx, GLint n, GLfloat obj[][4], GLfloat eye[][4], GLfloat normal[][3], GLfloat texcoord[][4])
static void sample_1d_linear_mipmap_nearest(const struct gl_texture_object *tObj, GLfloat s, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
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[])
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[])
static void sample_2d_nearest_mipmap_nearest(const struct gl_texture_object *tObj, GLfloat s, GLfloat t, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
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[])
static void sample_2d_linear_mipmap_nearest(const struct gl_texture_object *tObj, GLfloat s, GLfloat t, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
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[])
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[])
static void sample_1d_nearest_mipmap_linear(const struct gl_texture_object *tObj, GLfloat s, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void sample_2d_linear(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLfloat s, GLfloat t, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
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[])
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[])
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[])
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[])
static void palette_sample(const struct gl_texture_object *tObj, GLubyte index, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
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[])
static void sample_2d_nearest(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLfloat s, GLfloat t, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void get_1d_texel(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLint i, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void sample_1d_nearest_mipmap_nearest(const struct gl_texture_object *tObj, GLfloat s, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void sample_1d_linear(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLfloat s, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void get_2d_texel(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLint i, GLint j, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void sample_1d_nearest(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLfloat s, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void sample_1d_linear_mipmap_linear(const struct gl_texture_object *tObj, GLfloat s, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void sample_2d_linear_mipmap_linear(const struct gl_texture_object *tObj, GLfloat s, GLfloat t, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
static void sample_2d_nearest_mipmap_linear(const struct gl_texture_object *tObj, GLfloat s, GLfloat t, GLfloat lambda, GLubyte *red, GLubyte *green, GLubyte *blue, GLubyte *alpha)
void gl_set_texture_sampler(struct gl_texture_object *t)
#define GL_NEAREST_MIPMAP_NEAREST
#define GL_LUMINANCE_ALPHA
GLclampf GLclampf GLclampf alpha
#define GL_NEAREST_MIPMAP_LINEAR
#define GL_LINEAR_MIPMAP_LINEAR
#define GL_LINEAR_MIPMAP_NEAREST
GLint GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble r
GLint GLint GLsizei width
GLboolean GLboolean GLboolean b
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
GLboolean GLboolean GLboolean GLboolean a
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
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
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
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
#define COPY_3V(DST, SRC)
struct gl_texture_image * Image[MAX_TEXTURE_LEVELS]
GLubyte Palette[MAX_TEXTURE_PALETTE_SIZE *4]
#define CLAMP(f, min, max)