/** * Initialize texture state for the given context. */ GLboolean _mesa_init_texture(struct gl_context *ctx) { GLuint u; /* Texture group */ ctx->Texture.CurrentUnit = 0; /* multitexture */ /* Appendix F.2 of the OpenGL ES 3.0 spec says: * * "OpenGL ES 3.0 requires that all cube map filtering be * seamless. OpenGL ES 2.0 specified that a single cube map face be * selected and used for filtering." * * Unfortunatley, a call to _mesa_is_gles3 below will only work if * the driver has already computed and set ctx->Version, however drivers * seem to call _mesa_initialize_context (which calls this) early * in the CreateContext hook and _mesa_compute_version much later (since * it needs information about available extensions). So, we will * enable seamless cubemaps by default since GLES2. This should work * for most implementations and drivers that don't support seamless * cubemaps for GLES2 can still disable it. */ ctx->Texture.CubeMapSeamless = ctx->API == API_OPENGLES2; for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) init_texture_unit(ctx, u); /* After we're done initializing the context's texture state the default * texture objects' refcounts should be at least * MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1. */ assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount >= MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1); /* Allocate proxy textures */ if (!alloc_proxy_textures( ctx )) return GL_FALSE; /* GL_ARB_texture_buffer_object */ _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, ctx->Shared->NullBufferObj); ctx->Texture.NumCurrentTexUsed = 0; return GL_TRUE; }
/** * Initialize texture state for the given context. */ GLboolean _mesa_init_texture(struct gl_context *ctx) { GLuint u; /* Texture group */ ctx->Texture.CurrentUnit = 0; /* multitexture */ /* Appendix F.2 of the OpenGL ES 3.0 spec says: * * "OpenGL ES 3.0 requires that all cube map filtering be * seamless. OpenGL ES 2.0 specified that a single cube map face be * selected and used for filtering." * * Unfortunatley, a call to _mesa_is_gles3 below will only work if * the driver has already computed and set ctx->Version, however drivers * seem to call _mesa_initialize_context (which calls this) early * in the CreateContext hook and _mesa_compute_version much later (since * it needs information about available extensions). So, we will * enable seamless cubemaps by default since GLES2. This should work * for most implementations and drivers that don't support seamless * cubemaps for GLES2 can still disable it. */ ctx->Texture.CubeMapSeamless = ctx->API == API_OPENGLES2; for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; GLuint tex; /* initialize current texture object ptrs to the shared default objects */ for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { _mesa_reference_texobj(&texUnit->CurrentTex[tex], ctx->Shared->DefaultTex[tex]); } texUnit->_BoundTextures = 0; } for (u = 0; u < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); u++) { struct gl_fixedfunc_texture_unit *texUnit = &ctx->Texture.FixedFuncUnit[u]; texUnit->EnvMode = GL_MODULATE; ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 ); texUnit->Combine = default_combine_state; texUnit->_EnvMode = default_combine_state; texUnit->_CurrentCombine = & texUnit->_EnvMode; texUnit->TexGenEnabled = 0x0; texUnit->GenS.Mode = GL_EYE_LINEAR; texUnit->GenT.Mode = GL_EYE_LINEAR; texUnit->GenR.Mode = GL_EYE_LINEAR; texUnit->GenQ.Mode = GL_EYE_LINEAR; texUnit->GenS._ModeBit = TEXGEN_EYE_LINEAR; texUnit->GenT._ModeBit = TEXGEN_EYE_LINEAR; texUnit->GenR._ModeBit = TEXGEN_EYE_LINEAR; texUnit->GenQ._ModeBit = TEXGEN_EYE_LINEAR; /* Yes, these plane coefficients are correct! */ ASSIGN_4V( texUnit->GenS.ObjectPlane, 1.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenT.ObjectPlane, 0.0, 1.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenR.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenQ.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenS.EyePlane, 1.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); } /* After we're done initializing the context's texture state the default * texture objects' refcounts should be at least * MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1. */ assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount >= MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1); /* Allocate proxy textures */ if (!alloc_proxy_textures( ctx )) return GL_FALSE; /* GL_ARB_texture_buffer_object */ _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, ctx->Shared->NullBufferObj); ctx->Texture.NumCurrentTexUsed = 0; return GL_TRUE; }