[Resolved]GL_INVALID_OPERATION, Could not glTexImage2D

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

[Resolved]GL_INVALID_OPERATION, Could not glTexImage2D

Post by DtD »

I am working on an Irrlicht 1.7.1 implementation of the Berkelium library http://berkelium.org/ (which is used for rendering HTML web pages using the Google Chrome backend)

So far it is working great, but I am having issues getting my "resize view" code to work. Basically I have a webpage with a button that invokes a method to resize the texture, internal image buffer, and Berkelium's render window.

For whatever reason, I get this error with OpenGL:

Code: Select all

GL_INVALID_OPERATION
Could not glTexImage2D
The texture also proceeds to become solid white.
Which I have narrowed down to coming from the error check in COpenGLTexture.cpp on line 351 when I call ITexture::unlock()

Here is the constructor for my PageRenderer class along with the function that (re)creates the texture/image.

Code: Select all

  // Page Render Class
  PageRenderer::PageRenderer(irr::core::dimension2du size,bool transparent) : size(size), texture(0), image(0)
  {
   ares->log("Creating Berkelium page renderer");
   webView = Berkelium::Window::create();
   assert(webView);
   webView->setDelegate(this);
   webView->setTransparent(transparent);
   createTexture(size);
  }
  //Create the image+texture also update webwindow size.
  void PageRenderer::createTexture(irr::core::dimension2du newSize)
  {
   //irr::core::dimension2du oldSize = size;
   size = newSize;
   if (texture) {ares->getDriver()->removeTexture(texture);}
   if (image) {image->drop();}
   image = ares->getDriver()->createImage(irr::video::ECF_A8R8G8B8,size);
   texture = ares->getDriver()->addTexture(L"internalwebrender",image);
   webView->resize(size.Width,size.Height);
  }
Here is the part of the render code that is getting angry:

Code: Select all

    char* imagebuffer;
//[...]
    //Full render (It happens during partial render too, but I left that out to be brief
    imagebuffer = (char*)image->lock();
    ares->log("Full render locked.");
    memcpy(imagebuffer,sourceBuffer,size.Width*size.Height*(image->getBitsPerPixel()/8));
    ares->log("Full render complete.");
//[...]
    void* texbuffer = texture->lock(false,0);
   memcpy(texbuffer,imagebuffer,size.Width*size.Height*(image->getBytesPerPixel()));
//Also tried memcpy(texbuffer,imagebuffer,image->getImageDataSizeInBytes()); to no avail.
   texture->unlock();//This line is when the error appears
   image->unlock();
Any help would be awesome here, maybe I'm just doing something dumb.
I'd also like to point out my memcpy throws an exception in the software renderers for some reason 0.o Also, the issue happens on both my Intel GMA laptop and ATI Radeon HD4890 desktop.

BTW> I can put the whole source for the renderer and GUI class up if you think it'd help. I plan to release them eventually once the system is done.

Oh! Almost forgot, if I remove the line "if (texture) {ares->getDriver()->removeTexture(texture);}" the error stops, but this obviously causes a huge memory leak. I should also point out that I am using NPOT textures right now.

~David
Last edited by DtD on Mon Apr 05, 2010 12:39 am, edited 1 time in total.
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

Just wanted to say the issue is resolved, seems to be some kind of weird thread glitch maybe? Visual Studio reports it is the main thread, but I tweaked the way it makes the new textures and it works great now.
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Post by gabdab »

Any chance you sharing the code ?
Post Reply