February 27, 2013

Martell Malone Martell Malone
Lab Rat
42 posts

glPopAttrib and glPushAttrib on GLES for rendering fbo to a qquickitem

 

Hi guys,

I’ve extended QQuickitem to create an area where I can call open gl calls directly.

Only problem is on GLES/ANGLE platforms I cant push and pop like so

This is the preprocess in my QSGSimpleTextureNode extended class

  1. void ColorNode::preprocess()
  2. {
  3.     if(m_fbo == NULL) return; //will happen a few times
  4.  
  5.     QOpenGLContext::currentContext()->functions()->glUseProgram(0);
  6.     glPopAttrib();
  7.     m_fbo->bind();
  8.  
  9.  
  10.    //CCDirector::sharedDirector()->mainLoop();
  11.    opengl calls here
  12.  
  13.     glPushAttrib(GL_ALL_ATTRIB_BITS);
  14.     m_fbo->release();
  15.  
  16. m_fbo->toImage().save("name.png","png");
  17.  
  18.  
  19. }

Any ideas?

4 replies

February 27, 2013

SGaist SGaist
Mad Scientist
6979 posts

Hi,

If i’m not wrong, your calls are reversed, glPushXXX should be call before glPopXXX, otherwise you will have an “underflow” of what you’re trying to push/pop.

 Signature 

Need programers to hire ? www.edeltech.ch

March 1, 2013

Martell Malone Martell Malone
Lab Rat
42 posts

I didn’t write this code.
I think it is done this way because the qml window is already drawing something to screen via gl.

This code above works though I’ve tested it.

The problem is that the funstions glpush and glpop doesn’t exsist on GLES systems so how do we do it?

March 1, 2013

SGaist SGaist
Mad Scientist
6979 posts

Sorry, i misread your post, you’ll have to handle these attribute yourself (they are part of the fixed pipe which is not there anymore in gles)

But for normal OpenGL, having pop before push looks wrong even if it works.

 Signature 

Need programers to hire ? www.edeltech.ch

March 1, 2013

Martell Malone Martell Malone
Lab Rat
42 posts

How do I handle these attributes?

You are right I thought it was strange also.
Here is my explanation.

Lets say we have a text list.
qt pushes the view of the text list on to the stack.
It will then draw the surrounding window.
it will pop it off at the end and draw it to the area we want our qquickitem.
To ensure the text list is drawn last.

so what we are doing is popping it off early modify it and push it back for qt to draw it at a later stage.
At least that’s what I can gather from qquickitem

now my question is how does qt do this for GLES systems because it must do it somehow?

 
  ‹‹ [SOLVED] QtQuick.LocalStorage 2.0 on Blackberry Playbook      How to enable threaded scene graph rendering on Windows? ››

You must log in to post a reply. Not a member yet? Register here!