为什么我的彩色立方体不能与GL_BLEND一起使用? [英] Why does my colored cube not work with GL_BLEND?

查看:130
本文介绍了为什么我的彩色立方体不能与GL_BLEND一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用GL_BLEND时,我的多维数据集未按预期呈现。

  glEnable(GL_CULL_FACE); 
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);

我也有一个类似的问题,在前面绘制一些半透明的顶点,


相关:的代码,以及用于实际绘制立方体



正在绘制的立方体如下:

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

glPushMatrix();
glLoadIdentity();

// ...做一些翻译,旋转等...

drawCube();

glPopMatrix();

// ...交换缓冲区...


方案

您可以在绘制多维数据集之前尝试禁用所有照明:

  glDisable(GL_LIGHTING) 


My cube isn't rendering as expected when I use GL_BLEND.

glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

I'm also having a similar problem with drawing some semi-opaque vertices in front, which could well be related.

Related: Why do my semi-opaque vertices make background objects brighter in OpenGL?

Here's what it's supposed to look like:

And here's what it actually looks like:

Please see the code used to create the colored cube, and the code used to actually draw the cube.

The cube is being drawn like so:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();
glLoadIdentity();

// ... do some translation, rotation, etc ...

drawCube();

glPopMatrix();

// ... swap the buffers ...

解决方案

You could try disabling all lighting before drawing the cube:

glDisable(GL_LIGHTING);

这篇关于为什么我的彩色立方体不能与GL_BLEND一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆