Domanda

Sto cercando di portare un precedente progetto alle nuove classi QT5 OpenGL. Voglio rendere una consistenza usando un fbo. Il codice precedente ha utilizzato più trame di trame che sto allegando al FBO On-Demand. Quindi, avrei un certo oggetto texture, eseguire il rendering, collegare un'altra consistenza ed eseguire un'operazione diversa e avere l'uscita resa alla trama appena collegata, e così via.

Mi stavo chiedendo come dovrei fare a fare questo usando le classi QT5 OpenGL. Ad esempio, non riesco a capire come allegare un determinato oggetto QOpenGLTexture a un QOpenGLFrameBufferObject in modo che io possa renderlo. Posso vedere che c'è un metodo texture() e un metodo takeTexture(). Ma entrambi restituiscono solo l'ID della trama. Inoltre, come posso cambiare l'unità di trama attiva? Ad esempio, voglio campionare da due trame nel mio programma di shader. Quindi, ho bisogno di legare due trame a diverse unità di texture.

Per chiarire, il problema principale che sto avendo con la nuova API è che non vedo alcun metodo in QOpenGLFrameBufferObject che restituirebbe un oggetto QOpenGLTexture. Esiste solo il metodo toImage() e i metodi texture() e takeTexture(). Immagino di poter solo costruire un QOpenGLTexture usando il QImage restituito da toImage(). Ma non sono sicuro se sarebbe efficiente.

Per quanto riguarda texture() e takeTexture(), non vedo come i valori di ritorno possono essere utilizzati utilizzando le nuove classi.

È stato utile?

Soluzione

Sì, Qopenglframebufferobject Predates preda Qopengltexture e come tale, non utilizza o esporre Qopengltexture.Va aggiunto, ma in realtà, Qopenglfbo deve essere appena riscritto per supportare più allegati.

A parte questo, qual è il problema a usare manualmente GL chiama?

GLuint textureId = fbo->texture();
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, textureId);

glActiveTexture(GL_TEXTURE9);
glBindTexture(GL_TEXTURE_3D, anotherTexture);

QOpenGLTexture *yetAnother = getTexture();
yetAnother->bind(2);

program->setUniformValue("samplerForTheFBOTexture", GL_TEXTURE4 - GL_TEXTURE0);
program->setUniformValue("my3dSampler", GL_TEXTURE9 - GL_TEXTURE0);
program->setUniformValue("anotherSampler", 2);
// or use layout (binding = ) in GLSL
.

ecc.

Altri suggerimenti

I added a feature request to the Qt bugtracker to support multiple render targets (MRT) for the QOpenGLFramebufferObject. It is currently in progress and it seems only the code review is pending.

https://bugreports.qt.io/browse/QTBUG-39235

So stay tuned for change logs of future Qt versions.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top