当前位置:网站首页>API learning of OpenGL (2001) gltexgen
API learning of OpenGL (2001) gltexgen
2022-07-06 10:36:00 【hankern】
Used to calculate texture coordinates .
opengl es 3.2 and opengl 4.5 This function is no longer supported , I don't know from which version it doesn't support .(This article describes legacy OpenGL APIs that have been removed from core OpenGL 3.1 and above (they are only deprecated in OpenGL 3.0). It is recommended that you not use this functionality in your programs. Consider using the OpenGL Shading Language instead. Mathematics of glTexGen - OpenGL Wikihttps://www.khronos.org/opengl/wiki/Mathematics_of_glTexGen)
void glTexGenf(GLenum coord, GLenum pname, GLfloat param);
void glTexGenfv(GLenum coord, GLenum pname, GLfloat *param); The first parameter specifies the texture axis , It can be GL_S,GL_T,GL_R or GL_Q. The second parameter must be GL_TEXTURE_SPHERE,GL_OBJECT_PLANE or GL_EYE_PLANE. The last parameter sets the method or mode of texture generation .glTexGen There are also corresponding GLint and GLdouble Pattern .
Parameters coord Must be GL_S、GL_T、GL_R or GL_Q
pname Parameter is GL_TEXTURE_GEN_MODE、GL_OBJECT_PLANE or GL_EYE_PLANE,
If it is GL_TEXTURE_GEN_MODE,param It's an integer , namely GL_OBJECT_PLANE,GL_EYE_PLANE,GL_SPHERE_MAP,GL_REFLECTION,GL_NORMAL_MAP One of ;
If pname Take other possible values ,param It's a pointer to an array .
GL_OBJECT_LINEAR
g = p1 xo + p2 yo + p3 zo + p4 wo
glTexGen(GL_S, GL_OBJECT_LINEAR, {ps0,ps1,ps2,ps3})
glTexGen(GL_T, GL_OBJECT_LINEAR, {pt0,pt1,pt2,pt3})
And the following are equivalent
vec4 sPlane = vec4(ps0,ps1,ps2,ps3);
vec4 tPlane = vec4(pt0,pt1,pt2,pt3);
kOutBaseTCoord.s = dot(vec4(POSITION, 1.0), sPlane);
kOutBaseTCoord.t = dot(vec4(POSITION, 1.0), tPlane);
GL_EYE_LINEAR
myEyePlane_S = VectorTimesMatrix(myPlane_S, InverseModelviewMatrix);
myEyePlane_T = VectorTimesMatrix(myPlane_T, InverseModelviewMatrix);
// Now that we have myEyePlane_S and myEyePlane_T...
for(i = 0; i < total; i++)
{
myEyeVertex = MatrixTimesVector(ModelviewMatrix, myVertex[i]);
myTexCoord[i].s = dot4D(myEyeVertex, myEyePlane_S);
myTexCoord[i].t = dot4D(myEyeVertex, myEyePlane_T);
}
GL_SPHERE_MAP
for(i = 0; i < total; i++)
{
myEyeVertex = MatrixTimesVector(ModelviewMatrix, myVertex[i]);
myEyeVertex = Normalize(myEyeVertex);
myEyeNormal = VectorTimesMatrix(myNormal[i], InverseModelviewMatrix);
reflectionVector = myEyeVertex - myEyeNormal * 2.0 * dot3D(myEyeVertex, myEyeNormal);
reflectionVector.z += 1.0;
m = 1.0 / (2.0 * sqrt(dot3D(reflectionVector, reflectionVector)));
// I am emphasizing that we write to s and t. Used to sample a 2D texture.
myTexCoord[i].s = reflectionVector.x * m + 0.5;
myTexCoord[i].t = reflectionVector.y * m + 0.5;
}
GL_REFLECTION_MAP
for(i = 0; i < total; i++)
{
myEyeVertex = MatrixTimesVector(ModelviewMatrix, myVertex[i]);
myEyeVertex = Normalize(myEyeVertex);
myEyeNormal = VectorTimesMatrix(myNormal[i], InverseModelviewMatrix);
dotResult = 2.0 * dot3D(myEyeVertex, myEyeNormal);
// I am emphasizing that we write to s and t and r. Used to sample a cubemap.
myTexCoord[i].s = myEyeVertex.x - myEyeNormal.x * dotResult;
myTexCoord[i].t = myEyeVertex.y - myEyeNormal.y * dotResult;
myTexCoord[i].r = myEyeVertex.z - myEyeNormal.z * dotResult;
}
边栏推荐
- Google login prompt error code 12501
- MySQL23-存儲引擎
- Windchill configure remote Oracle database connection
- Opencv uses freetype to display Chinese
- MySQL combat optimization expert 04 uses the execution process of update statements in the InnoDB storage engine to talk about what binlog is?
- Mysql28 database design specification
- 15 medical registration system_ [appointment registration]
- 高并发系统的限流方案研究,其实限流实现也不复杂
- MySQL实战优化高手09 生产经验:如何为生产环境中的数据库部署监控系统?
- MySQL底层的逻辑架构
猜你喜欢
Pytoch LSTM implementation process (visual version)
MySQL23-存儲引擎
Mysql25 index creation and design principles
MySQL combat optimization expert 03 uses a data update process to preliminarily understand the architecture design of InnoDB storage engine
Implement sending post request with form data parameter
Jar runs with error no main manifest attribute
[after reading the series of must know] one of how to realize app automation without programming (preparation)
MySQL实战优化高手12 Buffer Pool这个内存数据结构到底长个什么样子?
Water and rain condition monitoring reservoir water and rain condition online monitoring
Use xtrabackup for MySQL database physical backup
随机推荐
Mysql30 transaction Basics
Ueeditor internationalization configuration, supporting Chinese and English switching
MySQL25-索引的创建与设计原则
MySQL storage engine
[after reading the series of must know] one of how to realize app automation without programming (preparation)
Water and rain condition monitoring reservoir water and rain condition online monitoring
MySQL27-索引优化与查询优化
Google login prompt error code 12501
PyTorch RNN 实战案例_MNIST手写字体识别
Complete web login process through filter
C language string function summary
Sed text processing
A necessary soft skill for Software Test Engineers: structured thinking
UEditor国际化配置,支持中英文切换
Mysql23 storage engine
[paper reading notes] - cryptographic analysis of short RSA secret exponents
数据库中间件_Mycat总结
颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
MySQL combat optimization expert 12 what does the memory data structure buffer pool look like?
MySQL learning diary (II)