Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some simplifications to the examples. Also removed extra panel render…

…s in examples.

Signed-off-by: Steven Lovegrove <stevenlovegrove@gmail.com>
  • Loading branch information...
commit e45c7e547bdda42165fb5fa9b5323fbeff5529c9 1 parent 9f01c8c
@stevenlovegrove authored
View
23 examples/SimpleDisplay/main.cpp
@@ -38,11 +38,13 @@ int main( int /*argc*/, char* argv[] )
// Create OpenGL window in single line thanks to GLUT
pangolin::CreateGlutWindowAndBind("Main",640,480);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
+
+ // 3D Mouse handler requires depth testing to be enabled
+ glEnable(GL_DEPTH_TEST);
+
// Issue specific OpenGl we might need
glEnable (GL_BLEND);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Define Camera Render Object (for view / scene browsing)
pangolin::OpenGlRenderState s_cam(
@@ -71,8 +73,8 @@ int main( int /*argc*/, char* argv[] )
// Default hooks for exiting (Esc) and fullscreen (tab).
while( !pangolin::ShouldQuit() )
{
- if(pangolin::HasResized())
- DisplayBase().ActivateScissorAndClear();
+ // Clear entire screen
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Safe and efficient binding of named variables.
// Specialisations mean no conversions take place for exact types
@@ -112,19 +114,12 @@ int main( int /*argc*/, char* argv[] )
#endif // HAVE_PNG
// Activate efficiently by object
- // (3D Handler requires depth testing to be enabled)
- d_cam.ActivateScissorAndClear(s_cam);
-
- glEnable(GL_DEPTH_TEST);
- glColor3f(1.0,1.0,1.0);
+ d_cam.Activate(s_cam);
// Render some stuff
+ glColor3f(1.0,1.0,1.0);
glutWireTeapot(1.0);
- // Render our UI panel when we receive input
- if(HadInput())
- d_panel.Render();
-
// Swap frames and Process Events
pangolin::FinishGlutFrame();
}
View
9 examples/SimpleDisplayImage/main.cpp
@@ -16,6 +16,9 @@ int main( int /*argc*/, char* argv[] )
// Create OpenGL window in single line thanks to GLUT
CreateGlutWindowAndBind("Main",640,480);
+ // 3D Mouse handler requires depth testing to be enabled
+ glEnable(GL_DEPTH_TEST);
+
pangolin::OpenGlRenderState s_cam(
ProjectionMatrix(640,480,420,420,320,240,0.1,1000),
ModelViewLookAt(-0,0.5,-3, 0,0,0, AxisY)
@@ -41,7 +44,7 @@ int main( int /*argc*/, char* argv[] )
const int width = 640;
const int height = 480;
- float * imageArray = new float[width*height];
+ float* imageArray = new float[width*height];
GlTexture imageTexture(width,height,GL_LUMINANCE32F_ARB);
// Default hooks for exiting (Esc) and fullscreen (tab).
@@ -50,7 +53,7 @@ int main( int /*argc*/, char* argv[] )
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d_cam.Activate(s_cam);
- glEnable(GL_DEPTH_TEST);
+
glColor3f(1.0,1.0,1.0);
glutWireTeapot(2.0);
@@ -65,7 +68,7 @@ int main( int /*argc*/, char* argv[] )
pangolin::FinishGlutFrame();
}
- delete imageArray;
+ delete[] imageArray;
return 0;
}
View
23 examples/SimpleMultiDisplay/main.cpp
@@ -14,7 +14,9 @@ int main( int /*argc*/, char* argv[] )
{
// Create OpenGL window in single line thanks to GLUT
pangolin::CreateGlutWindowAndBind("Main",640,480);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ // 3D Mouse handler requires depth testing to be enabled
+ glEnable(GL_DEPTH_TEST);
// Issue specific OpenGl we might need
glEnable (GL_BLEND);
@@ -70,40 +72,37 @@ int main( int /*argc*/, char* argv[] )
// Default hooks for exiting (Esc) and fullscreen (tab).
while( !pangolin::ShouldQuit() )
{
- if(HasResized())
- DisplayBase().ActivateScissorAndClear();
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Generate random image and place in texture memory for display
setImageData(imageArray,width,height);
imageTexture.Upload(imageArray,GL_LUMINANCE,GL_FLOAT);
- // (3D Handler requires depth testing to be enabled)
- glEnable(GL_DEPTH_TEST);
glColor3f(1.0,1.0,1.0);
- d_cam1.ActivateScissorAndClear(s_cam);
+ d_cam1.Activate(s_cam);
glutWireTeapot(1.0);
- d_cam2.ActivateScissorAndClear(s_cam2);
+ d_cam2.Activate(s_cam2);
glutWireTeapot(1.0);
- d_cam3.ActivateScissorAndClear(s_cam);
+ d_cam3.Activate(s_cam);
glutWireTeapot(1.0);
- d_cam4.ActivateScissorAndClear(s_cam2);
+ d_cam4.Activate(s_cam2);
glutWireTeapot(1.0);
- d_img1.ActivateScissorAndClear();
+ d_img1.Activate();
imageTexture.RenderToViewport();
- d_img2.ActivateScissorAndClear();
+ d_img2.Activate();
imageTexture.RenderToViewport();
// Swap frames and Process Events
pangolin::FinishGlutFrame();
}
- delete imageArray;
+ delete[] imageArray;
return 0;
}
View
6 examples/SimplePlot/main.cpp
@@ -12,10 +12,6 @@ int main( int /*argc*/, char* argv[] )
// Create OpenGL window in single line thanks to GLUT
pangolin::CreateGlutWindowAndBind("Main",640,480);
- // Issue specific OpenGl we might need, in this case for smooth lines
- glEnable (GL_BLEND);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
// Data logger object
DataLog log;
const double tinc = 0.01;
@@ -35,8 +31,6 @@ int main( int /*argc*/, char* argv[] )
labels.push_back(std::string("sin(t)+cos(t)"));
log.SetLabels(labels);
-
-
// Default hooks for exiting (Esc) and fullscreen (tab).
while( !pangolin::ShouldQuit() )
{
View
14 examples/SimpleRepeatVideo/main.cpp
@@ -50,15 +50,18 @@ void RecordSample(const std::string uri, const std::string vid_file, const std::
while( !pangolin::ShouldQuit() )
{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
// Load next video frame
- video.GrabNext(img,true);
- texVideo.Upload(img, vid_fmt.channels==1 ? GL_LUMINANCE:GL_RGB, GL_UNSIGNED_BYTE);
+ if( video.GrabNext(img,true) ) {
+ texVideo.Upload(img, vid_fmt.channels==1 ? GL_LUMINANCE:GL_RGB, GL_UNSIGNED_BYTE);
- // Associate input with this video frame
- input.SetIndex(video.FrameId());
+ // Associate input with this video frame
+ input.SetIndex(video.FrameId());
+ }
// Activate video viewport and render texture
- vVideo.ActivateScissorAndClear();
+ vVideo.Activate();
if( colour ) {
glColorHSV(hue,0.5,1.0);
@@ -84,7 +87,6 @@ void RecordSample(const std::string uri, const std::string vid_file, const std::
input.SaveBuffer(ui_file);
}
- d_panel.Render();
pangolin::FinishGlutFrame();
}
View
13 examples/SimpleVideo/main.cpp
@@ -34,12 +34,13 @@ void VideoSample(const std::string uri)
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
- video.GrabNext(img,true);
- // TODO: Work out the correct display format properly
- texVideo.Upload(
- img, vid_fmt.channels==1 ? GL_LUMINANCE:GL_RGB,
- vid_fmt.channel_bits[0]==8?GL_UNSIGNED_BYTE:GL_UNSIGNED_SHORT
- );
+ if( video.GrabNext(img,true) ) {
+ // TODO: Work out the correct display format properly
+ texVideo.Upload(
+ img, vid_fmt.channels==1 ? GL_LUMINANCE:GL_RGB,
+ vid_fmt.channel_bits[0]==8?GL_UNSIGNED_BYTE:GL_UNSIGNED_SHORT
+ );
+ }
// Activate video viewport and render texture
vVideo.Activate();
View
11 examples/VBODisplay/main.cpp
@@ -32,6 +32,9 @@ int main( int /*argc*/, char* argv[] )
pangolin::CreateGlutWindowAndBind("Main",640,480);
glewInit();
+
+ // 3D Mouse handler requires depth testing to be enabled
+ glEnable(GL_DEPTH_TEST);
// Create vertex and colour buffer objects and register them with CUDA
GlBufferCudaPtr vertex_array(
@@ -78,11 +81,9 @@ int main( int /*argc*/, char* argv[] )
cutStartTimer(timer);
#endif
- if(HasResized())
- DisplayBase().ActivateScissorAndClear();
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- d_cam.ActivateScissorAndClear(s_cam);
- glEnable(GL_DEPTH_TEST);
+ d_cam.Activate(s_cam);
glColor3f(1.0,1.0,1.0);
{
@@ -114,8 +115,6 @@ int main( int /*argc*/, char* argv[] )
#endif
}
- d_panel.Render();
-
// Swap frames and Process Events
pangolin::FinishGlutFrame();
Please sign in to comment.
Something went wrong with that request. Please try again.