How do you use GLSL shaders in an OGRE application without using an material script?

StackOverflow https://stackoverflow.com/questions/17208616

  •  01-06-2022
  •  | 
  •  

Вопрос

I'm developing an application for a virtual reality environment using OGRE, Bullet and Equalizer. My rendering function looks like this:

    root->_fireFrameStarted();
    root->_fireFrameRenderingQueued();
    root->_fireFrameEnded();
    _window->update(false);

The window does not do the buffer swap, because Equalizer does that. This function works fine, we can even use particle systems and all the other fancy stuff OGRE offers.

However, since the projection area in our lab is curved, we have a GLSL module (let's call it Warp) we use in all our applications to distort the rendering output so that it fits our projection wall. We accomplish this by creating a texture, copying the contents of the back buffer to it and applying our warping shader when rendering the distorted texture covering the entire window. You can find the source code here: pastebin . com/ TjNJuHtC We call this module in eq::Window::frameDrawFinish() and it works well with pure OpenGL applications but not with OGRE.

This is the output without the module and its shader: http://s1.directupload.net/images/130620/amr5qh3x.png

If I enable the module, this is the rather strange output: http://s14.directupload.net/images/130620/74qiwgyd.png

And if I disable the two calls to glBindTexture, the texture used by the sun particle effect (flare.png) is rendered onto the screen (I would show it to you but I can only use two links).

Every GL state variable I consider relevant have the same values in our other applications. I checked GL_READ_BUFFER, GL_DRAW_BUFFER, GL_RENDER_MODE, GL_CULL_FACE_MODE and GL_DOUBLEBUFFER.

This raises some questions: Why does my call to glTexCopySubImage2D() seem to have no effect at all? And why does my shader not do anything even if I tell it to just make every fragment red?

Supplemental: Putting the entire shader into a material script and letting OGRE handle it is not an option.

Это было полезно?

Решение

Solved the problem: I created my shaders before Ogre::Root created my windows. I have changed the order and now it works.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top