如何在此代码中禁用纹理
How can I disable the texture in this code?
我正在与Vuforia一起玩,这是OpenGL代码,但我真的不知道一切的作用。我只想在此禁用纹理,因为我从.obj
文件生成的代码不包含纹理文件。
我只是想让某人告诉我每个块的作用以及如何清除纹理,因此我的模型完全是白色的(或白色的阴影,如果很容易做到)。
// Clear colour and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render video background
[appRenderer renderVideoBackground];
glEnable(GL_DEPTH_TEST);
// We must detect if background reflection is active and adjust the culling direction.
// If the reflection is active, this means the pose matrix has been reflected as well,
// therefore standard counter clockwise face culling will result in "inside out" models.
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
for (int i = 0; i < state.getNumTrackableResults(); ++i) {
// Get the trackable
const Vuforia::TrackableResult* result = state.getTrackableResult(i);
Vuforia::Matrix44F modelViewMatrix = Vuforia::Tool::convertPose2GLMatrix(result->getPose());
// OpenGL 2
Vuforia::Matrix44F modelViewProjection;
VuforiaApplicationUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]);
VuforiaApplicationUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]);
VuforiaApplicationUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]);
glUseProgram(shaderProgramID);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)teapotVertices);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)teapotNormals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)teapotTexCoords);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, augmentationTexture[i].textureID);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (const GLfloat*)&modelViewProjection.data[0]);
glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/);
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*)teapotIndices);
glDisableVertexAttribArray(vertexHandle);
glDisableVertexAttribArray(normalHandle);
glDisableVertexAttribArray(textureCoordHandle);
VuforiaApplicationUtils::checkGlError("EAGLView renderFrameVuforia");
}
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDrawElements
调用似乎很重要,但是如果我不需要纹理,我会通过什么?我启用并禁用VertexAttribArray
吗?那怎么办?
最简单的方法是编辑使用纹理使用白色的着色器代码。它应该类似于用texture2D(texture, coord)
替换CC_4
另外,您可以使用glTexImage2d
上载可以在包含以下数据的1x1缓冲区中创建的白色纹理:
GLubyte texdata[1 * 1 * 4] = {0xFF, 0xFF, 0xFF, 0xFF};
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- OpenInventor从9.8升级到10.4.2后,GLSL纹理返回零
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 无法将Android WebView渲染到C 和Java代码之间共享的外部纹理中
- 如何在此代码中禁用纹理
- Opengl C++:纹理代码纹理所有具有相同纹理的模型
- 这段代码中的顶点和纹理坐标代表什么?