43 #include <ACG/GL/acg_glew.hh>
44 #include "SkyDomeNode.hh"
45 #include <ACG/GL/gl.hh>
68 glDeleteBuffers(1,&
vbo_);
162 void SkyDomeNode::drawSkyDomePick(
ACG::GLState& _state) {
239 if ( updateBuffers_ ) {
246 if ( !info.exists() ) {
247 std::cerr <<
"Did not find image!" << filename.toStdString() << std::endl;
248 filename = OpenFlipper::Options::iconDirStr() + QDir::separator() +
"EmptySkyDome.png";
253 QImage texture(filename);
257 QImage GL_formatted_image;
258 GL_formatted_image = QGLWidget::convertToGLFormat(texture);
260 if( GL_formatted_image.isNull() )
262 std::cerr <<
"error GL_formatted_image" << std::endl ;
267 glGenTextures(1, &textureId_);
270 glBindTexture(GL_TEXTURE_2D, textureId_);
273 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, GL_formatted_image.width(),
274 GL_formatted_image.height(),
275 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_formatted_image.bits() );
278 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
279 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
281 glBindTexture(GL_TEXTURE_2D,0);
283 updateBuffers_ =
false;
292 ro.debugName =
"SkyDome";
316 float vboData_[4 * 3 * 4 ] = { unprojectedBottomLeft[0] , unprojectedBottomLeft[1] , unprojectedBottomLeft[2],
317 unprojectedBottomRight[0] , unprojectedBottomRight[1] , unprojectedBottomRight[2],
318 unprojectedtopRight[0] , unprojectedtopRight[1] , unprojectedtopRight[2],
319 unprojectedtopLeft[0] , unprojectedtopLeft[1] , unprojectedtopLeft[2]
323 glGenBuffersARB(1, &
vbo_);
327 glBindBufferARB(GL_ARRAY_BUFFER_ARB,
vbo_);
330 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 4 * 3 * 4, &vboData_[0], GL_STATIC_DRAW_ARB);
333 ro.
shaderDesc.shadeMode = ACG::SG_SHADE_UNLIT;
334 ro.
shaderDesc.vertexTemplateFile = OpenFlipper::Options::shaderDirStr() + QDir::separator() +
"SkyDome" + QDir::separator() +
"SkyDomeVertexShader.glsl";
335 ro.
shaderDesc.fragmentTemplateFile = OpenFlipper::Options::shaderDirStr() + QDir::separator() +
"SkyDome" + QDir::separator() +
"SkyDomeFragmentShader.glsl";
342 ro.setMaterial(&localMaterial);
343 ro.glDrawArrays(GL_QUADS, 0, 4);
345 ro.
setUniform(
"uUpperCutOff" , dome_.topOffset() );
346 ro.
setUniform(
"uHorizontalFOV" , dome_.horizontalFOV() );
347 ro.
setUniform(
"uVerticalFOV" , dome_.verticalFOV() );
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const
return available draw modes
int viewport_width() const
get viewport width
void boundingBox(ACG::Vec3d &_bbMin, ACG::Vec3d &_bbMax)
update bounding box
void setUniform(const char *_name, GLint _value)
set values for int uniforms
QString textureFileName()
Returns the texture that will be used.
static void disable(GLenum _cap)
replaces glDisable, but supports locking
void getRenderObjects(ACG::IRenderer *_renderer, ACG::GLState &_state, const ACG::SceneGraph::DrawModes::DrawMode &_drawMode, const ACG::SceneGraph::Material *_mat)
Add the objects to the given renderer.
void draw(ACG::GLState &_state, const ACG::SceneGraph::DrawModes::DrawMode &_drawMode)
draw SkyDome
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
VectorT< float, 3 > Vec3f
unsigned int vbo_
VBO used to render the dome.
virtual void addRenderObject(RenderObject *_renderObject)
Callback for the scenegraph nodes, which send new render objects via this function.
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
void baseColor(const Vec4f &_c)
set the base color
SkyDomeNode(SkyDome &_dome, BaseNode *_parent=0, std::string _name="<PlaneNode>")
Construct a SkyDome rendering node.
int viewport_height() const
get viewport height
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
int priority
Priority to allow sorting of objects.
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
void addElement(const VertexElement *_pElement)
void pick(ACG::GLState &_state, ACG::SceneGraph::PickTarget _target)
draw SkyDome for object picking
PickTarget
What target to use for picking.
Interface class between scenegraph and renderer.
void initFromState(GLState *_glState)
Initializes a RenderObject instance.
void addTexture(const Texture &_t)
adds a texture to stage RenderObjects::numTextures()
Vec3d unproject(const Vec3d &_winPoint) const
unproject point in window coordinates _winPoint to world coordinates
ShaderGenDesc shaderDesc
Drawmode and other shader params.