The Vish Visualization Shell 0.3
Vish
QuadDemo.cpp

Demonstration how to render a very simple geometry in Vish using OpenGL 1 calls.

Demonstration how to render a very simple geometry in Vish using OpenGL 1 calls.

See also
Background.cpp for a more basic example.
#include <ocean/GLvish/VGLRenderObject.hpp>
#include <ocean/plankton/VPipeline.hpp>
#include <ocean/GLvish/GLTexture.hpp>
namespace
{
using namespace Wizt;
class QuadDemo : public VGLRenderObject
{
public:
QuadDemo(const string&name, int p, const RefPtr<VCreationPreferences>&VP);
~QuadDemo();
bool update(VRequest&R, double precision) override;
bool renderGL(VGLRenderContext&) const override;
};
QuadDemo::QuadDemo(const string&name, int p, const RefPtr<VCreationPreferences>&VP)
: VGLRenderObject(name, DEFAULT_OBJECT, VP)
{
}
QuadDemo::~QuadDemo()
{}
bool QuadDemo::update(VRequest&Context, double precision)
{
// nothing to be done here.
// The update function in general is used to process data
// in contrast to just rendering data.
return true;
}
bool QuadDemo::renderGL(VGLRenderContext&Context) const
{
glDisable ( GL_COLOR_MATERIAL );
glDisable ( GL_LIGHTING );
glEnable(GL_TEXTURE_2D);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
const int W = 128, H = 128;
rgb_t Image[W*H];
for(int y=0; y<H; y++)
for(int x=0; x<W; x++)
{
Image[x+W*y][0] = 2*x;
Image[x+W*y][1] = 2*y;
Image[x+W*y][2] = x+y;
}
glTexImage2D(GL_TEXTURE_2D, 0, 3, W,H, 0, GL_RGB,
GL_UNSIGNED_BYTE,
Image);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f (0,-1,-1);
glTexCoord2f( 0,1);
glVertex3f (0,-1,1);
glTexCoord2f(1,1);
glVertex3f (0,1,1);
glTexCoord2f(1, 0);
glVertex3f (0,1,-1);
glEnd();
/*
The following line is important for geometric objects as it defines
their bounding volume. This is important for setting OpenGL depth parameters
correctly, as well as for camera navigation.
*/
setBoundingBall( Context, new BoundingBox( point(0,-1,-1), point(0, 1, 1) ));
return true;
}
using namespace Panthalassa;
myCreator( Category("Demo")
/VIdentifier("QuadDemo")
/ Description("Display an image in two different coordinate systems")
,
ObjectQuality::DEMO);
}
A coordinate-parallel bounding box in three dimensions.
Definition elementary/aerie/BoundingBox.hpp:24
A set of variable names, with indices associated to each type.
Definition Context.hpp:18
A vector type that is bound to a certain domain, inheriting all vector space properties,...
Definition DomainVector.hpp:23
A point in physical 3D space.
Definition elementary/eagle/PhysicalSpace.hpp:106
A reference counting pointer class which keeps objects alive as long as strong pointers to these obje...
Definition RefPtr.hpp:405
A set of property elements for VCreator objects.
Definition VCreatorProperties.hpp:258
Base class for objects that implement a drawing routine using OpenGL.
Definition VGLRenderObject.hpp:20
Request structure.
Definition VRequest.hpp:24
The Panthalassa namespace allows to conveniently specify the properties of a VCreator object during c...
Definition VCreatorProperties.hpp:385
The Vish namespace.
Definition Anemone.cpp:17
A special vish context that is passed to VGLRenderObjects when rendering.
Definition VGLRenderContext.hpp:35
Implements a data sink.
Definition VPipeline.hpp:73