- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在构建一个用户可以从内向外看的盒子,天空盒或类似的东西。我这样做是通过取 6 个四边形并用它们创建一个立方体,然后将理论相机放在立方体内部并用图像对立方体进行纹理处理。用户可以使用鼠标环顾四周,立方体会旋转,看起来就像是在移动他们的头。我遇到了在两侧的交叉点出现白线的问题,我尝试拉入四边形,同时保持实际四边形的大小相同。我已经确定清晰的颜色是黑色,但我仍然看到白线。
这是我设置的属性:
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT);
glClearDepth(1);
//S is the side length of the cube
float s = 5;
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_POLYGON_SMOOTH, GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
这是创建立方体的代码:
float s = 5; //S is the side length of each quad
glNewList(m_cube, GL_COMPILE);
{
glPushMatrix();
{
glEnable(GL_TEXTURE_2D);
glPushMatrix();
{
glBegin(GL_QUADS);
{
//front
{
glTexCoord2f(0.5f, (1.0f / 3.0f));
// glColor3f(1, 0, 0);
glVertex3f(((s / 2.0f)), ((s / 2.0f)),
-((s / 2.0f))); //1
glTexCoord2f(0.25f, (1.0f / 3.0f));
// glColor3f(1, 1, 0);
glVertex3f(-((s / 2.0f)), ((s / 2.0f)),
-((s / 2.0f))); //2
glTexCoord2f(0.25f, (2.0f / 3.0f));
// glColor3f(1, 0, 1);
glVertex3f(-((s / 2.0f)), -((s / 2.0f)),
-((s / 2.0f))); //3
glTexCoord2f(0.5f, (2.0f / 3.0f));
// glColor3f(1, 1, 1);
glVertex3f(((s / 2.0f)), -((s / 2.0f)),
-((s / 2.0f))); //4
}
//left
{
glTexCoord2f(0.25f, (1.0f / 3.0f));
// glColor3f(1, 0, 0);
glVertex3f(-((s / 2.0f)), ((s / 2.0f)),
-((s / 2.0f))); //2
glTexCoord2f(0.0f, (1.0f / 3.0f));
// glColor3f(1, 1, 0);
glVertex3f(-((s / 2.0f)), ((s / 2.0f)),
((s / 2.0f))); //5
glTexCoord2f(0.0f, (2.0f / 3.0f));
// glColor3f(1, 0, 1);
glVertex3f(-((s / 2.0f)), -((s / 2.0f)),
((s / 2.0f))); //6
glTexCoord2f(0.25f, (2.0f / 3.0f));
// glColor3f(1, 1, 1);
glVertex3f(-((s / 2.0f)), -((s / 2.0f)),
-((s / 2.0f))); //3
}
//right
{
glTexCoord2f(0.75f, (1.0f / 3.0f));
// glColor3f(1, 0, 0);
glVertex3f(((s / 2.0f)), ((s / 2.0f)),
((s / 2.0f))); //7
glTexCoord2f(0.5f, (1.0f / 3.0f));
// glColor3f(1, 1, 0);
glVertex3f(((s / 2.0f)), ((s / 2.0f)),
-((s / 2.0f))); //1
glTexCoord2f(0.5f, (2.0f / 3.0f));
// glColor3f(1, 0, 1);
glVertex3f(((s / 2.0f)), -((s / 2.0f)),
-((s / 2.0f))); //4
glTexCoord2f(0.75f, (2.0f / 3.0f));
// glColor3f(1, 1, 1);
glVertex3f(((s / 2.0f)), -((s / 2.0f)),
((s / 2.0f))); //8
}
//back
{
glTexCoord2f(1.0f, (1.0f / 3.0f));
// glColor3f(1, 0, 0);
glVertex3f(-((s / 2.0f)), ((s / 2.0f)),
((s / 2.0f))); //5
glTexCoord2f(0.75f, (1.0f / 3.0f));
// glColor3f(1, 1, 0);
glVertex3f(((s / 2.0f)), ((s / 2.0f)),
((s / 2.0f))); //7
glTexCoord2f(0.75f, (2.0f / 3.0f));
// glColor3f(1, 0, 1);
glVertex3f(((s / 2.0f)), -((s / 2.0f)),
((s / 2.0f))); //8
glTexCoord2f(1.0f, (2.0f / 3.0f));
// glColor3f(1, 1, 1);
glVertex3f(-((s / 2.0f)), -((s / 2.0f)),
((s / 2.0f))); //6
}
//top
{
glTexCoord2f(.5f, 1.0f);
// glColor3f(1, 0, 0);
glVertex3f(((s / 2.0f)), -((s / 2.0f)),
((s / 2.0f))); //7
glTexCoord2f(0.25f, 1.0f);
// glColor3f(1, 1, 0);
glVertex3f(-((s / 2.0f)), -((s / 2.0f)),
((s / 2.0f))); //5
glTexCoord2f(0.25f, (2.0f / 3.0f));
// glColor3f(1, 0, 1);
glVertex3f(-((s / 2.0f)), -((s / 2.0f)),
-((s / 2.0f))); //2
glTexCoord2f(.5f, (2.0f / 3.0f));
// glColor3f(1, 1, 1);
glVertex3f(((s / 2.0f)), -((s / 2.0f)),
-((s / 2.0f))); //1
}
//bottom
{
glTexCoord2f(.5f, (1.0f / 3.0f));
// glColor3f(1, 0, 0);
glVertex3f(((s / 2.0f)), ((s / 2.0f)),
-((s / 2.0f))); //4
glTexCoord2f(0.25f, (1.0f / 3.0f));
// glColor3f(1, 1, 0);
glVertex3f(-((s / 2.0f)), ((s / 2.0f)),
-((s / 2.0f))); //3
glTexCoord2f(0.25f, 0.0f);
// glColor3f(1, 0, 1);
glVertex3f(-((s / 2.0f)), ((s / 2.0f)),
((s / 2.0f))); //6
glTexCoord2f(.5f, 0.0f);
// glColor3f(1, 1, 1);
glVertex3f(((s / 2.0f)), ((s / 2.0f)),
((s / 2.0f))); //8
}
}
glEnd();
}
glPopMatrix();
glDisable(GL_TEXTURE_2D);
}
glPopMatrix();
}
glEndList();
这是设置相机的代码:
float near_ = 1f;
float far_ = 10.0f;
float halfHeight = near_ * (Radian(m_fov)) / 2.0f;
float halfWidth = (static_cast<float>((m_width)) / static_cast<float>((m_height))) * halfHeight;
glViewport(0, 0, m_width, m_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-halfWidth, halfWidth, -halfHeight, halfHeight, near_, far_);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
这是呈现到屏幕的代码:
void VideoStreamer::render()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float pitch = clamp(Degree(m_pitch), Degree(-(80.f)), Degree(80.f));
float yaw = wrap(m_yaw, Degree(0), Degree(360));
float roll = wrap(m_roll, Degree(0), Degree(360));
glPushMatrix();
{
glLineWidth(5);
glPushMatrix();
{
if (1)
{
glRotatef(pitch, 1.0, 0.0, 0.0);
glRotatef(yaw, 0.0, 1.0, 0.0);
glRotatef(roll, 0.0, 0.0, 1.0);
}
glCallList((m_cube));
}
glPopMatrix();
}
glPopMatrix();
SDL_GL_SwapBuffers();
}//end render
这是正在发生的事情的屏幕截图,注意蓝色和黑色四边形之间的白线:
这是我正在使用的纹理,分辨率为 600x450,但线条出现在多种分辨率下:
我的问题是:如何去掉那条白线?
编辑:白线只出现在顶部和底部与左右相交的地方
编辑:更新代码以反射(reflect)建议
最佳答案
您所看到的只是纹理中确实有白色。因此,面部边界上的碎片最终会从白色部分获取(如果您在纹理上启用线性过滤器类型,您会更清楚地看到这一点)。
你可以做些什么来修复它:
关于c++ - 去除opengl中2个四边形相交处的白线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12373605/
这个问题已经有答案了: What is the difference between a variable, object, and reference? [duplicate] (5 个回答) 已关
我正在使用以下代码来学习java套接字编程。它的作用是,client.java 程序从用户那里获取一个号码并将其发送到 sever.java。然后服务器将其乘以2并发回给客户端。在我的客户端程序中,它
我编写了一个自己开发的串行端口类,为了简单起见,我使用了阻塞/同步/非重叠。我浏览了所有 MSDN 文档,这对我来说很困难。 我在从端口打开、传输或接收字节方面没有任何问题。所有操作都是同步并且没有线
//Not finished -- disregard function evaluate() { var cdate = new Date(); var cday = cdate.getDa
我已经尝试过了,但它有效 例如: x= 523.897 y= x[0:"."] print y 我只想打印 523。如何让 Python 抓取字符串直到某个字母或数字? 最佳答案 行 y = x[0:
我想移动拐 Angular 处的方框(从左上角开始水平移动 Angular 落到右上角然后你去到右下角。 function myMove() { var elem = document.getEl
如何让侧边栏停止在第二个侧边栏部分而不是顶部? fiddle http://jsfiddle.net/EvAdP/2/ HTML I'm the header
我刚刚在大学开始我的第二门编程类(class),我们的第一个作业相当简单,旨在基本上检查我们的环境并检查我们是否知道如何通过类(class)网站提交作业。 当我运行我们提供的代码时,它卡在应该提示用户
我目前正忙于我的这个信息学元素(构建一个示例交友网站)。问题是我在把所有东西都放在正确的地方时遇到了一些麻烦。一切都很顺利,直到我的邮箱出现在错误的位置(但是,Dreamweaver 会按照我的意
我想,和你一样hover a GIF shot on Dribbble , 当光标位于元素高度顶部之后/50% 处时显示带有信息的 div。 测试示例 我做了这个,这是有效的,但有点棘手......特
我有一个下拉菜单,并且我已将 mouseenter 设置为选项。因此,如果鼠标位于触发器之外,菜单应该关闭。我正在使用 jQuery 1.8.0。这可能是 CSS 问题吗? 这是我初始化插件的代码。
我正在尝试在 Visual Basic for Applications 中编写一个 hello world 应用程序,即修改 Excel 工作表中的单元格。这是: Sub hello() D
我的应用程序使用 JSF 2.1 和 PrimeFaces。最近,由于一些线程卡住,观察到 CPU 利用率非常高。所有卡住线程的卡住线程转储都指向 javax.faces.component.UICo
在列出 aws cognito 用户时,我的 Node js 应用程序遇到问题。 仅当我有超过 60 个 Cognito 用户时才会出现此问题。 Reference of API 下面是我的代码片段。
我是 ubuntu 用户..我在 php 中有一个执行 python 文件的命令..python 文件设置为可执行文件..所以,我的 php 命令是:- shell_exec("try.py");
我正在尝试将剪贴板内容写入文件,但由于某种原因程序卡住了。 FILE *fp; fp = fopen("tmp.code","w"); fprintf(fp,getclip()); /*writes*
当用户向下滚动时,我使用此代码使侧边栏固定在某个 div 处。问题是我必须手动输入一个阈值数字,这并不总是理想的,因为该部分的位置可能会更改或在各种浏览器和系统之间不一致。我想知道是否有一种方法可以在
我有一个字符串数组,例如 first_page = {{"U","M","Y","Q","I","A","L","D","P"、"F"、"E"、"G"、"T"、"Z"、"V"、"W"、"H"、"O"、
我能否在页面上的特定 px 位置放置一个元素(例如图像),然后让文本围绕它流动? 必要时使用 JS/jquery。 我确实看到了这个Have text flow around an object th
第一次在这里提问。 我有两个简单的 Javascript 函数,1. 生成一个随机字母,2. 在每个单元格中使用单个字母填充 10x10 表格。创建表的主要函数是通过带有 onclick 的简单 HT
我是一名优秀的程序员,十分优秀!