January 25, 2012

greenlinux greenlinux
Lab Rat
3 posts

Qt/3D OpenGl Simple Gooch Shader Example

 

Hello,

I’ve been struggling to get my head around the “proper” — Qt/3D — way to use OpenGL (programmable pipeline) in a Qt data aquisition and visualisation application. I’m fairly new to OpenGL and GLSL as well so this may be old news to everyone except me, howeve, while struggling with it I didn’t find any examples that showed simply, “this is how to make a nice looking teapot/cube/icosohedron etc.”

So, this is one way of makeing a nice looking teapot with a gooch shader in Qt/3D. Qt/3D is under quite rapid development (by the looks of things) so I expect the method will change with time. This example contains one scene node — teapot (or triangle) — one light, one shader program and no textures. I’m in scientific visualisation so I don’t really need textures much unless I want my data to look like a crate or a wall :-)

I have found “Shader Maker” useful (not for this example, just in general): Shader Maker Project Page [cg.in.tu-clausthal.de] as Shader Designer wouldn’t go for me in Kubuntu 11.10.

If there are screw-ups or someone knows better than me what the “Qt way” for doing this sort of thing is… please let me know.

My approach is based on the following copule of lines from the Qt/3D docs at QGLScreenNode() Qt Doc [doc.qt.nokia.com]

As a general approach to 3D applications, a tree of QGLSceneNodes may be constructed, geometry added to them, materials and transformations applied, all during application initialization; and then by simply calling the draw() function the scene is easily rendered for each frame.

Sigh, well i was going to post the code but apparently i have more then 6k characters and that’s making it grumpy… So D/L code from,

Here [iceamplifiers.co.uk]

Best,

James

1 reply

January 25, 2012

greenlinux greenlinux
Lab Rat
3 posts

I’ve assumed your Qt/3D is in /opt/Qt-4.8.0/include/Qt3D in the .pro this must be changed to wherever your insall is.

 
  ‹‹ Get "motion blur" in animations      How to setup OpenGL 3.x? ››

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