39 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
40 #include <OpenGLFramework/SpecializedBatches/PMDWarp.hh>
41 #include <OpenGLFramework/Base/glfException.hh>
42 #include <OpenGLFramework/Base/glfFramebufferObject.hh>
45 #include <Utils/Param.hh>
46 #include <Utils/IOUtils.hh>
47 #include <Base/Image/ImageIO.hh>
48 #include <Base/Image/Image.hh>
49 #include <Image/Camera.hh>
51 #include <Gui/biasgl.h>
52 #include <GLviewer/Scenes/ScenePointLight.hh>
53 #include <GLviewer/GLProjectionParametersPerspective.hh>
54 #ifdef BIAS_HAVE_OPENSCENEGRAPH
55 #include <GLviewer/Scenes/ScenePlainOpenSceneGraph.hh>
56 #define HAVE_A_SCENEGRAPH
59 #include <GLviewer/Scenes/SceneOSG.hh>
60 #define HAVE_A_SCENEGRAPH
68 int main(
int argc,
char* argv[])
74 string *projection = params.
AddParamString(
"Projection",
"",
"",
'p',GRP_NOSHOW);
75 int *numSamples = params.
AddParamInt(
"samples",
"number of samples used for multi sample buffers",
76 16, 0,16,
'b',GRP_NOSHOW);
78 if(!IOUtils::ParseCommandLineEvalHelp(params, argc, argv) )
81 #ifdef HAVE_A_SCENEGRAPH
82 bool hasmodel =
false;
84 unsigned int width = 1024;
85 unsigned int height = 768;
104 glViewport(0,0,width,height);
115 colorTexture.
Allocate(width, height, GL_RGB);
123 depthTexture.
Allocate(width, height, GL_DEPTH_COMPONENT);
127 targetFbo.
AttachTexture(colorTexture, GL_COLOR_ATTACHMENT0_EXT);
128 targetFbo.
AttachTexture(depthTexture, GL_DEPTH_ATTACHMENT_EXT);
131 GLF_THROW_ON_OPENGL_ERROR;
136 if(*projection !=
"") {
137 cout<<
"Loading projection:"<<*projection<<endl;
139 int ret = proj.
XMLRead(*projection);
140 if(ret != 0) BIASERR(
"Reading projection failed!");
147 #ifdef BIAS_HAVE_OPENSCENEGRAPH
151 BIAS::SceneOSG sceneOSG;
154 #ifdef HAVE_A_SCENEGRAPH
158 cout<<
"Loading model:"<<*model<<endl;
159 if(sceneOSG.AppendSubTreeFromFile(*model)>=0)
170 glClearColor(0.0, 1.0, 0.0, 0.0);
171 glEnable(GL_MULTISAMPLE);
172 glEnable(GL_DEPTH_TEST);
173 glClearColor(0.0, 0.0, 0.0, 0.0);
175 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
177 #ifdef HAVE_A_SCENEGRAPH
181 vector<SceneBase*> scenes; scenes.push_back(&lightScene);
182 scenes.push_back(&sceneOSG);
183 glParams.
Draw(scenes);
184 cout<<
"Drawing target scene!"<<endl;
187 glDisable(GL_DEPTH_TEST);
190 glColor3f(0.8,0.8,0.0);
191 glVertex2f(0.25,0.25);
192 glColor3f(0.0,0.0,1.0);
193 glVertex2f(-0.25,-0.25);
202 IOUtils::SaveCamera(
"colorBeforeBlit.mip",resultColor);
206 IOUtils::SaveCamera(
"depthBeforeBlit.mip", resultDepth);
212 colorRenderbuffer.
Create(GL_RGBA, width, height, *numSamples);
214 depthRenderbuffer.
Create(GL_DEPTH_COMPONENT, width, height, *numSamples);
222 glClearColor(1.0, 0.0, 0.0, 0.0);
224 glEnable(GL_DEPTH_TEST);
225 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
228 #ifdef HAVE_A_SCENEGRAPH
232 vector<SceneBase*> scenes; scenes.push_back(&lightScene);
233 scenes.push_back(&sceneOSG);
234 glParams.
Draw(scenes);
235 cout<<
"Drawing source scene!"<<endl;
238 glDisable(GL_DEPTH_TEST);
242 glColor3f(0.8,0.8,0.0);
243 glVertex2f(0.25,0.25);
244 glColor3f(0.0,0.0,1.0);
245 glVertex2f(-0.25,-0.25);
248 if(*numSamples == 0) {
251 IOUtils::SaveCamera(
"colorRenderbuffer.mip",resultColor);
254 IOUtils::SaveCamera(
"depthRenderbuffer.mip", resultDepth);
258 glfFramebufferObject::BlitColorBuffer(&sourceFbo, &targetFbo, GL_LINEAR);
259 glfFramebufferObject::Blit(&sourceFbo, &targetFbo, GL_DEPTH_BUFFER_BIT);
261 GLF_THROW_ON_OPENGL_ERROR;
266 IOUtils::SaveCamera(
"colorAfterBlit.mip",resultColor);
270 IOUtils::SaveCamera(
"depthAfterBlit.mip", resultDepth);
int SetSimplePerspectiveCam(double fovyDEG, int imageWidth=-1, int imageHeight=-1)
void Allocate(int width, int height, GLenum internalFormat, int mipmap=0)
Creates a texture with undefined content.
void AttachTexture(const glfTexture &texture, GLenum attachmentPoint, int attachedMipMapLevel=0, int zSlice=0, GLenum cubeMapSide=0)
Attaches a texture to an attachment point which can be.
int XMLRead(const std::string &Filename)
derived classes must implement the function XMLIn which is called by this function XMLRead to read ev...
virtual void SetClearColor(const BIAS::Vector4< float > &cc)
setclearcolor is pure virtual.
void Create()
Creates the texture but does not upload any data yet.
void SetLightAsHeadLight(bool asHeadLight)
virtual void SetRenderTarget(BIAS::glfRenderTarget *RT)
void SetWrapS(GLenum wrapS)
Sets the wrapping mode for the 1st texture coordinate.
void Create(GLenum internalFormat, int width, int height, GLsizei samples=0)
Creates the renderbuffer with the given format and size.
void SetUndistortion(double kc1, double kc2)
void CopyToImage(ImageBase &image, int mipmap=0)
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase.
virtual void MakeCurrent()
Makes this context the current target for OpenGL calls.
Exception class used for run-time errors in the OpenGLFramework.
void SetSpecular(BIAS::Vector4< double > sp)
virtual int Draw(std::vector< BIAS::SceneBase * > &scenes, BIAS::SceneBGImage *backgroundImageScene=NULL, BIAS::glfFramebufferObject *theTarget=NULL)
Renders scenes passed as argument beginning with the smallest index.
virtual void Destroy()
Uninitializes the rendering context.
BIAS::Quaternion< double > GetQ(unsigned int cam=0) const
return rotation quaternion of camera with index cam if cam>0 this is a relative pose in the coordinat...
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
void AttachRenderbuffer(const glfRenderbuffer &renderbuffer, GLenum attachmentPoint)
Attaches a renderbuffer to the framebuffer object.
void SetMinFilter(GLenum minFilter)
Sets the minifying function.
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
This class hides the underlying projection model, like projection matrix, spherical camera...
void CheckComplete() const
Checks whether the framebuffer object is supported in its current state.
void CopyToImage(ImageBase &image)
void SetDiffuse(BIAS::Vector4< double > di)
void SetWrapT(GLenum wrapT)
Sets the wrapping mode for the 2nd texture coordinate.
GLX pbuffer rendering context.
void SetIntrinsics(BIAS::ProjectionParametersBase *p)
void SetZClippingPlanes(float n, float f)
Setting the near and far z-Clipping planes.
virtual void Init(const glfRenderingContextConfig &config)
Initializes the rendering context with the given configuration.
This class Param provides generic support for parameters.
Implements slim openscenegraph scene without extras.
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
int Flip()
flips the image vertically (row order is inverted) In place function return 0 in case of success...
Vector3< double > GetC(unsigned int cam=0) const
return Center of camera with index cam.
int Init(unsigned int width=1200, unsigned int height=900)
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
Configuration for a rendering context.
void Create()
Creates the framebuffer object.
void SetMagFilter(GLenum magFilter)
Sets the magnification function.
void SetAmbient(BIAS::Vector4< double > am)
void SetDrawLightPosition(bool drawLight)
class for rendering with projection parameters of ProjectionParametersPerspective ...
virtual int SetExtrinsics(const BIAS::HomgPoint3D &C, const BIAS::RMatrix &R)