我正在尝试创建一个2d纹理以显示在我的Qt / OpenGL应用程序上。然后我创建了一个填充屏幕以放置它的Quad,但我得到的是一个没有任何错误的白色屏幕。有人看到我的代码有什么问题吗?
#include "AppGLWidget.h"
#include <iostream>
AppGLWidget::AppGLWidget(QWidget *parent) : QGLWidget(parent),
mnRange(100),
mcDisplayedImage(512,512,QImage::Format_ARGB32)
{
mcDisplayedImage.fill(qRgb(100,0,0));
mcDisplayedImage = QGLWidget::convertToGLFormat(mcDisplayedImage);
int value;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
}
AppGLWidget::~AppGLWidget(void)
{
}
void AppGLWidget::initializeGL() {
glClearColor(0, 1, 0, 1);
glPushMatrix();
glOrtho(0, size().width(), size().height(), 0, -1, 1);
glViewport(0, 0, (GLint)size().width(), (GLint)size().height());
glDisable(GL_DEPTH_TEST);
glShadeModel(GL_FLAT);
glEnable(GL_TEXTURE_2D);
glGenTextures(1,&mcTextureObj);
glBindTexture(GL_TEXTURE_2D,mcTextureObj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mcDisplayedImage.width(), mcDisplayedImage.height(), 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glDisable(GL_TEXTURE_2D);
// check OpenGL error
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR) {
std::cerr << "OpenGL error: " << err << std::endl;
}
}
void AppGLWidget::resizeGL(int w, int h)
{
glPopMatrix();
glPushMatrix();
glOrtho(0, w, h, 0, -1, 1);
glViewport(0, 0, w, h);
}
void AppGLWidget::paintGL() {
glBindTexture(GL_TEXTURE_2D, mcTextureObj);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mcDisplayedImage.width(), mcDisplayedImage.height(),
GL_RGBA, GL_UNSIGNED_BYTE, mcDisplayedImage.bits());
glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,lnHeight);
glTexCoord2i(0,1); glVertex2i(0,0);
glTexCoord2i(1,1); glVertex2i(lnWidth,0);
glTexCoord2i(1,0); glVertex2i(lnWidth,lnHeight);
glEnd();
// check OpenGL error
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR) {
std::cerr << "OpenGL error: " << err << std::endl;
}
}
答案 0 :(得分:2)
GL_TEXTURE_2D
需要glEnable()
来呈现。
现在你glDisable()
initializeGL()
将其留在SELECT a.eid, a.cid, b.e_date
FROM table_A a
JOIN table_B b ON a.eid = b.eid
JOIN table_A_trans c ON a.cid = c.cid
WHERE c.someDateColumn <= '2014-06-01
AND a.eid NOT IN(123,124,200)
并保持这种状态。