X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Ftexgen.c;h=45f86fd911f02d7f394f521b390000a78852bab7;hb=fa18a427e929ecc04a9980e517db96663debea29;hp=b3ecfc784e3c9239794d2e83211a57e6de84ff13;hpb=124f5875eae0b914d5c679fec6b25633907ad843;p=mesa.git diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c index b3ecfc784e3..45f86fd911f 100644 --- a/src/mesa/main/texgen.c +++ b/src/mesa/main/texgen.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.5 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -18,9 +17,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ /** @@ -37,14 +37,21 @@ #include "main/texgen.h" #include "main/texstate.h" #include "math/m_matrix.h" +#include "main/dispatch.h" /** * Return texgen state for given coordinate */ static struct gl_texgen * -get_texgen(struct gl_texture_unit *texUnit, GLenum coord) +get_texgen(struct gl_context *ctx, struct gl_fixedfunc_texture_unit *texUnit, + GLenum coord) { + if (ctx->API == API_OPENGLES) { + return (coord == GL_TEXTURE_GEN_STR_OES) + ? &texUnit->GenS : NULL; + } + switch (coord) { case GL_S: return &texUnit->GenS; @@ -63,26 +70,25 @@ get_texgen(struct gl_texture_unit *texUnit, GLenum coord) void GLAPIENTRY _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { - struct gl_texture_unit *texUnit; + struct gl_fixedfunc_texture_unit *texUnit; struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) _mesa_debug(ctx, "glTexGen %s %s %.1f(%s)...\n", - _mesa_lookup_enum_by_nr(coord), - _mesa_lookup_enum_by_nr(pname), + _mesa_enum_to_string(coord), + _mesa_enum_to_string(pname), *params, - _mesa_lookup_enum_by_nr((GLenum) (GLint) *params)); + _mesa_enum_to_string((GLenum) (GLint) *params)); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glTexGen(current unit)"); return; } - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx); - texgen = get_texgen(texUnit, coord); + texgen = get_texgen(ctx, texUnit, coord); if (!texgen) { _mesa_error(ctx, GL_INVALID_ENUM, "glTexGen(coord)"); return; @@ -121,7 +127,13 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); return; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + if (ctx->API != API_OPENGL_COMPAT + && (bit & (TEXGEN_REFLECTION_MAP_NV | TEXGEN_NORMAL_MAP_NV)) == 0) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texgen->Mode = mode; texgen->_ModeBit = bit; } @@ -129,9 +141,13 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) case GL_OBJECT_PLANE: { + if (ctx->API != API_OPENGL_COMPAT) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } if (TEST_EQ_4V(texgen->ObjectPlane, params)) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); COPY_4FV(texgen->ObjectPlane, params); } break; @@ -139,6 +155,12 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) case GL_EYE_PLANE: { GLfloat tmp[4]; + + if (ctx->API != API_OPENGL_COMPAT) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + /* Transform plane equation by the inverse modelview matrix */ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); @@ -147,7 +169,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) ctx->ModelviewMatrixStack.Top->inv); if (TEST_EQ_4V(texgen->EyePlane, tmp)) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); COPY_4FV(texgen->EyePlane, tmp); } break; @@ -182,8 +204,47 @@ _mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) void GLAPIENTRY _mesa_TexGend(GLenum coord, GLenum pname, GLdouble param ) { - GLfloat p = (GLfloat) param; - _mesa_TexGenfv( coord, pname, &p ); + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0F; + _mesa_TexGenfv( coord, pname, p ); +} + + +void GLAPIENTRY +_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) +{ + _mesa_GetTexGenfv(GL_S, pname, params); +} + + +void GLAPIENTRY +_es_TexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + if (coord != GL_TEXTURE_GEN_STR_OES) { + GET_CURRENT_CONTEXT(ctx); + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGen[fx](pname)" ); + return; + } + /* set S, T, and R at the same time */ + _mesa_TexGenf(GL_S, pname, param); + _mesa_TexGenf(GL_T, pname, param); + _mesa_TexGenf(GL_R, pname, param); +} + + +void GLAPIENTRY +_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) +{ + if (coord != GL_TEXTURE_GEN_STR_OES) { + GET_CURRENT_CONTEXT(ctx); + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGen[fx]v(pname)" ); + return; + } + /* set S, T, and R at the same time */ + _mesa_TexGenfv(GL_S, pname, params); + _mesa_TexGenfv(GL_T, pname, params); + _mesa_TexGenfv(GL_R, pname, params); } @@ -207,14 +268,20 @@ _mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) void GLAPIENTRY _mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) { - _mesa_TexGenfv(coord, pname, ¶m); + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0F; + _mesa_TexGenfv(coord, pname, p); } void GLAPIENTRY _mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) { - _mesa_TexGeniv( coord, pname, ¶m ); + GLint p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0; + _mesa_TexGeniv( coord, pname, p ); } @@ -222,19 +289,18 @@ _mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) void GLAPIENTRY _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) { - struct gl_texture_unit *texUnit; + struct gl_fixedfunc_texture_unit *texUnit; struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGendv(current unit)"); return; } - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx); - texgen = get_texgen(texUnit, coord); + texgen = get_texgen(ctx, texUnit, coord); if (!texgen) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)"); return; @@ -260,19 +326,18 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) void GLAPIENTRY _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) { - struct gl_texture_unit *texUnit; + struct gl_fixedfunc_texture_unit *texUnit; struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGenfv(current unit)"); return; } - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx); - texgen = get_texgen(texUnit, coord); + texgen = get_texgen(ctx, texUnit, coord); if (!texgen) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)"); return; @@ -283,9 +348,17 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) params[0] = ENUM_TO_FLOAT(texgen->Mode); break; case GL_OBJECT_PLANE: + if (ctx->API != API_OPENGL_COMPAT) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(param)" ); + return; + } COPY_4V(params, texgen->ObjectPlane); break; case GL_EYE_PLANE: + if (ctx->API != API_OPENGL_COMPAT) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(param)" ); + return; + } COPY_4V(params, texgen->EyePlane); break; default: @@ -298,19 +371,18 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) void GLAPIENTRY _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) { - struct gl_texture_unit *texUnit; + struct gl_fixedfunc_texture_unit *texUnit; struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGeniv(current unit)"); return; } - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx); - texgen = get_texgen(texUnit, coord); + texgen = get_texgen(ctx, texUnit, coord); if (!texgen) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)"); return; @@ -321,12 +393,20 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) params[0] = texgen->Mode; break; case GL_OBJECT_PLANE: + if (ctx->API != API_OPENGL_COMPAT) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(param)" ); + return; + } params[0] = (GLint) texgen->ObjectPlane[0]; params[1] = (GLint) texgen->ObjectPlane[1]; params[2] = (GLint) texgen->ObjectPlane[2]; params[3] = (GLint) texgen->ObjectPlane[3]; break; case GL_EYE_PLANE: + if (ctx->API != API_OPENGL_COMPAT) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(param)" ); + return; + } params[0] = (GLint) texgen->EyePlane[0]; params[1] = (GLint) texgen->EyePlane[1]; params[2] = (GLint) texgen->EyePlane[2]; @@ -336,5 +416,3 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); } } - -