当前位置:网站首页>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;
}
边栏推荐
- Const decorated member function problem
- Typescript入门教程(B站黑马程序员)
- Several errors encountered when installing opencv
- 软件测试工程师发展规划路线
- text 文本数据增强方法 data argumentation
- Set shell script execution error to exit automatically
- Pytorch LSTM实现流程(可视化版本)
- MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
- MySQL26-性能分析工具的使用
- MySQL combat optimization expert 05 production experience: how to plan the database machine configuration in the real production environment?
猜你喜欢

Unicode decodeerror: 'UTF-8' codec can't decode byte 0xd0 in position 0 successfully resolved

MySQL实战优化高手04 借着更新语句在InnoDB存储引擎中的执行流程,聊聊binlog是什么?

Redis集群方案应该怎么做?都有哪些方案?

If someone asks you about the consistency of database cache, send this article directly to him

Emotional classification of 1.6 million comments on LSTM based on pytoch

Adaptive Bezier curve network for real-time end-to-end text recognition

Super detailed steps for pushing wechat official account H5 messages

颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香

Not registered via @enableconfigurationproperties, marked (@configurationproperties use)

The underlying logical architecture of MySQL
随机推荐
MySQL combat optimization expert 07 production experience: how to conduct 360 degree dead angle pressure test on the database in the production environment?
16 medical registration system_ [order by appointment]
How to make shell script executable
Solve the problem of remote connection to MySQL under Linux in Windows
Time in TCP state_ The role of wait?
How to build an interface automation testing framework?
Mysql28 database design specification
MySQL实战优化高手12 Buffer Pool这个内存数据结构到底长个什么样子?
MySQL实战优化高手07 生产经验:如何对生产环境中的数据库进行360度无死角压测?
MySQL30-事务基础知识
The underlying logical architecture of MySQL
Windchill配置远程Oracle数据库连接
A necessary soft skill for Software Test Engineers: structured thinking
用于实时端到端文本识别的自适应Bezier曲线网络
MySQL combat optimization expert 10 production experience: how to deploy visual reporting system for database monitoring system?
Pytorch RNN actual combat case_ MNIST handwriting font recognition
Mysql23 storage engine
Just remember Balabala
Bytetrack: multi object tracking by associating every detection box paper reading notes ()
Export virtual machines from esxi 6.7 using OVF tool