照明我創建了一個小應用程序來顯示單個顆粒:GL_POINT_SPRITE_ARB(產生廣告牌)的問題與在旋轉時
當我周圍的場景中的照明變化和粒子幾乎成爲不可見的旋轉:
是否可以強制設置整個旋轉的照明?
相關代碼:
// init
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glAccum(GL_RETURN, 0.95f);
glClear(GL_ACCUM_BUFFER_BIT);
glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);
glDisable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
float quadratic[3] = { 0.0, 0.0, 0.01337f };
float linear[3] = { 0.0, 1, 0.0 };
float constant[3] = { 0.01, 0.0, 0.0 };
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic);
float maxSize = 0.0f;
glGetFloatv(GL_POINT_SIZE_MAX_ARB, &maxSize);
glPointSize(maxSize);
glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
QImage b("particle.bmp");
QImage t;
t = QGLWidget::convertToGLFormat(b);
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits());
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
而且繪製函數:
// draw function:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glAccum(GL_RETURN, 0.95f);
glClear(GL_ACCUM_BUFFER_BIT);
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
glEnable(GL_POINT_SPRITE_ARB);
glColor4f(1.0f, 1.0f, 0.1f, 0.7f);
glBegin(GL_POINTS);
// Loop over all particles and draw the gl points separately:
glVertex3f(x, y, z);
glEnd();
glDisable(GL_POINT_SPRITE_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glDisable(GL_BLEND);
glAccum(GL_ACCUM, 0.5f);
如果你想自己here's完整的代碼進行測試。我使用libqglviewer進行相機旋轉。
Alt + PrintScreen通常只捕獲活動窗口。 – genpfault 2012-02-08 22:58:50
我知道。屏幕截圖似乎是次要的我。我更新了它們。謝謝! – Pascal 2012-02-09 08:17:23