Getting openGL error when attempting glEnable(GL_TEXTURE_2D); on ios
-
wrote on 29 Oct 2014, 21:42 last edited by
I am having a rather bad day on Ios today. I am trying to get textures to show up on my geometry and all I've gotten for hours is a black cube! (btw, the desktop version of this works fine)
I put CheckForGLError checks in and I've traced the first error to the code:
@glEnable(GL_TEXTURE_2D);@
Here's my basic setup up the point where I call this:
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);QGLFormat format;
format.setVersion(3,3);
format.setProfile( QGLFormat::CoreProfile );
format.setDepth(true);
format.setRgba(true);
m_context = new QGLContext(format);m_model = new ModelView(format, this);
m_model->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
ui->OGLLayer->addWidget(m_model);
m_model->showMaximized();AnkhWorld::singleton().setMainWindow(this);
AnkhWorld::singleton().firstRun();
}
@Here's where I initialize the openGL view:
@
void ModelView::initializeGL()
{
ScopeGLCheck("initializeGL begin");
NStatus status;
initializeOpenGLFunctions();ScopeGLCheck("initializeGL called");
glEnable(GL_TEXTURE_2D); // FIRST OPENGL ERROR OCCURS HERE
ScopeGLCheck("Set texture called");
uw::engine->firstRun();
ScopeGLCheck("engine first run called");
m_viewport = (ViewPortToy*) uw::harbor->fetchToy(MODEL_VIEWPORT, uw::hToyViewPort);
m_camera = (CameraToy*) uw::harbor->fetchToy(MAIN_CAMERA, uw::hToyCamera);
if( !m_viewport || !m_camera )
Q_ASSERT_X( 0, "InitializeGL", "Viewport or camera is not initialized.");nm::nVector2_F viewWidthHeight( this->width(), this->height());
m_viewport->setViewDimensions(viewWidthHeight);
m_viewportDirty = true;
m_lastWidth = 0;
m_lastHeight = 0;// Put the Camera at a fixed spot on startup. Initialize the trackball for this viewport. A
// Trackball manages all scene navigation
nm::nVector3_F cameraPosition( 20.f, 20.f, 20.f);
nm::nVector3_F focusPosition( 0.f, 0.f, 0.f);
m_trackball = new Trackball(m_viewport, m_camera, focusPosition, cameraPosition);// initialize the camera's view matrix
m_viewport->handleViewPortDirty(true);AnkhWorld::singleton().firstRunAfterOGLSetup();
}
@Everything points to I'm missing some secret ingredient to setup the opengl window for Ios. Don't know what I'm looking for though
-
wrote on 29 Oct 2014, 22:05 last edited by
I'm going to amend this. I did some further poking around and found someone say this:
bq. In a modern core profile, there is no "fixed-function pipeline" (i.e. built-in shader generator). glEnable( GL_TEXTURE_2D) is a directive to the fixed-function pipeline's shader generator that you want to include code to support that texture unit.
bq. Delete it. You're writing the shader so you decide directly which texture units you're going to reference. Just glActiveTexture to activate the right texture unit, glBindTexture, then glUniform1i to set the texture unit index on the appropriate sampler uniform.
With that said, I still have GL errors down when I attempt to load the texture into the GPU on ios. This next piece of code is where I get the next error:
@ m_oglTexture = new QOpenGLTexture(QOpenGLTexture::Target2D);
ScopeGLCheck("GPUTextureOGL() allocate");
m_oglTexture->setData(_image->mirrored(), QOpenGLTexture::DontGenerateMipMaps); //(QOpenGLTexture::MipMapGeneration) !_generateMips);
ScopeGLCheck("GPUTextureOGL() setData"); // <-ERROR IS HERE
m_oglTexture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
m_oglTexture->setMagnificationFilter(QOpenGLTexture::Linear);
m_oglTexture->setWrapMode(QOpenGLTexture::DirectionS, QOpenGLTexture::Repeat);
m_oglTexture->setWrapMode(QOpenGLTexture::DirectionT, QOpenGLTexture::Repeat);
m_valid = true;@
1/2