Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into transparent_mode
Browse files Browse the repository at this point in the history
ahcorde authored Jun 23, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents ba04b22 + 8c34f9d commit 605d7ee
Showing 41 changed files with 1,992 additions and 202 deletions.
42 changes: 42 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -56,6 +56,48 @@

### Ignition Rendering 4.X

### Ignition Rendering 4.8.0 (2021-06-18)

1. relax gaussian test tolerance
* [Pull request #344](https://github.com/ignitionrobotics/ign-rendering/pull/344)

1. recreate node only when needed
* [Pull request #342](https://github.com/ignitionrobotics/ign-rendering/pull/342)

1. Backport memory fixes found by ASAN
* [Pull request #340](https://github.com/ignitionrobotics/ign-rendering/pull/340)

1. Re-enable part of depth camera test on macOS
* [Pull request #335](https://github.com/ignitionrobotics/ign-rendering/pull/335)
* [Pull request #347](https://github.com/ignitionrobotics/ign-rendering/pull/347)

1. Fix depth alpha
* [Pull request #316](https://github.com/ignitionrobotics/ign-rendering/pull/316)

1. Fix floating point precision bug handling alpha channel (#332)
* [Pull request #333](https://github.com/ignitionrobotics/ign-rendering/pull/333)

1. Include MoveTo Helper class to ign-rendering
* [Pull request #311](https://github.com/ignitionrobotics/ign-rendering/pull/311)

1. Remove `tools/code_check` and update codecov
* [Pull request #321](https://github.com/ignitionrobotics/ign-rendering/pull/321)

1. [OGRE 1.x] Uniform buffer shader support
* [Pull request #294](https://github.com/ignitionrobotics/ign-rendering/pull/294)

1. Helper function to get a scene
* [Pull request #320](https://github.com/ignitionrobotics/ign-rendering/pull/320)

1. Reduce lidar data discretization
* [Pull request #296](https://github.com/ignitionrobotics/ign-rendering/pull/296)

1. Prevent console warnings when multiple texture coordinates are present
* [Pull request #301](https://github.com/ignitionrobotics/ign-rendering/pull/301)

1. Added command line argument to pick version of Ogre
* [Pull request #277](https://github.com/ignitionrobotics/ign-rendering/pull/277)

### Ignition Rendering 4.7.0 (2021-03-17)

1. Enable depth write in particles example
2 changes: 1 addition & 1 deletion examples/custom_shaders_uniforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ include_directories(SYSTEM
${PROJECT_BINARY_DIR}
)

find_package(ignition-rendering4)
find_package(ignition-rendering6)

set(TARGET_THIRD_PARTY_DEPENDS "")

48 changes: 48 additions & 0 deletions examples/visualization_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ignition-rendering-visualization-demo)

find_package(ignition-rendering6)

if (APPLE OR UNIX)
find_package(GLUT REQUIRED)
include_directories(SYSTEM ${GLUT_INCLUDE_DIRS})
link_directories(${GLUT_LIBRARY_DIRS})

find_package(OpenGL REQUIRED)
include_directories(SYSTEM ${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})

set(TARGET_THIRD_PARTY_DEPENDS
${TARGET_THIRD_PARTY_DEPENDS}
${OPENGL_LIBRARIES}
${GLUT_LIBRARIES}
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()

if (NOT APPLE)
find_package(GLEW REQUIRED)
if (WIN32)
set(TARGET_THIRD_PARTY_DEPENDS
${TARGET_THIRD_PARTY_DEPENDS}
GLEW::glew
)
else ()
set(TARGET_THIRD_PARTY_DEPENDS
${TARGET_THIRD_PARTY_DEPENDS}
GLEW
)
endif()
endif()

if (WIN32)
find_package(FreeGLUT REQUIRED)
set(TARGET_THIRD_PARTY_DEPENDS ${TARGET_THIRD_PARTY_DEPENDS} FreeGLUT::freeglut)
endif()

add_executable(visualization_demo Main.cc GlutWindow.cc)

target_link_libraries(visualization_demo
${IGNITION-RENDERING_LIBRARIES}
${TARGET_THIRD_PARTY_DEPENDS}
)
227 changes: 227 additions & 0 deletions examples/visualization_demo/GlutWindow.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#if __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#elif _WIN32
#define NOMINMAX
// Must include this before GL/gl.h
#include <windows.h>
#include <GL/glew.h
// OpenGL utilities header file
#include <GL/glu.h>
// OpenGL utilities header file
#include <GL/glut.h>
#include "Wingdi.h"
#else
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glut.h>
#endif

#if !defined(__APPLE__) && !defined(_WIN32)
#include <GL/glx.h>
#endif

#include <mutex>

#include <ignition/common/Console.hh>
#include <ignition/rendering/Camera.hh>
#include <ignition/rendering/Image.hh>
#include <ignition/rendering/Scene.hh>

#include "GlutWindow.hh"

#define KEY_ESC 27
#define KEY_TAB 9

//////////////////////////////////////////////////
unsigned int imgw = 0;
unsigned int imgh = 0;

std::vector<ir::CameraPtr> g_cameras;
ir::CameraPtr g_camera;
ir::CameraPtr g_currCamera;
unsigned int g_cameraIndex = 0;
ir::ImagePtr g_image;

bool g_initContext = false;

#if __APPLE__
CGLContextObj g_context;
CGLContextObj g_glutContext;
#elif _WIN32
HGLRC g_context = 0;
HDC g_display = 0;
HGLRC g_glutContext = 0;
HDC g_glutDisplay = 0;
#else
GLXContext g_context;
Display *g_display;
GLXDrawable g_drawable;
GLXContext g_glutContext;
Display *g_glutDisplay;
GLXDrawable g_glutDrawable;
#endif

double g_offset = 0.0;

//////////////////////////////////////////////////
void updateCameras()
{
double angle = g_offset / 2 * M_PI;
double x = sin(angle) * 3.0 + 3.0;
double y = cos(angle) * 3.0;
for (ir::CameraPtr camera : g_cameras)
{
camera->SetLocalPosition(x, y, 0.0);
}

g_offset += 0.0005;
}

//////////////////////////////////////////////////
void displayCB()
{
#if __APPLE__
CGLSetCurrentContext(g_context);
#elif _WIN32
if(!wglMakeCurrent(g_display, g_context))
{
std::cerr << "Not able to wglMakeCurrent" << '\n';
exit(-1);
}
#else
if (g_display)
{
glXMakeCurrent(g_display, g_drawable, g_context);
}
#endif

g_cameras[g_cameraIndex]->Capture(*g_image);

#if __APPLE__
CGLSetCurrentContext(g_glutContext);
#elif _WIN32
wglMakeCurrent(g_glutDisplay, g_glutContext);
#else
glXMakeCurrent(g_glutDisplay, g_glutDrawable, g_glutContext);
#endif

unsigned char *data = g_image->Data<unsigned char>();

glClearColor(0.5, 0.5, 0.5, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPixelZoom(1, -1);
glRasterPos2f(-1, 1);
glDrawPixels(imgw, imgh, GL_RGB, GL_UNSIGNED_BYTE, data);

glutSwapBuffers();
updateCameras();
}

//////////////////////////////////////////////////
void idleCB()
{
glutPostRedisplay();
}

//////////////////////////////////////////////////
void keyboardCB(unsigned char _key, int, int)
{
if (_key == KEY_ESC || _key == 'q' || _key == 'Q')
{
exit(0);
}
else if (_key == KEY_TAB)
{
g_cameraIndex = (g_cameraIndex + 1) % g_cameras.size();
}
}

//////////////////////////////////////////////////
void initCamera(ir::CameraPtr _camera)
{
g_camera = _camera;
imgw = g_camera->ImageWidth();
imgh = g_camera->ImageHeight();
ir::Image image = g_camera->CreateImage();
g_image = std::make_shared<ir::Image>(image);
g_camera->Capture(*g_image);
}

//////////////////////////////////////////////////
void initContext()
{
glutInitDisplayMode(GLUT_DOUBLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(imgw, imgh);
glutCreateWindow("Visualization Demo");
glutDisplayFunc(displayCB);
glutIdleFunc(idleCB);
glutKeyboardFunc(keyboardCB);
}

//////////////////////////////////////////////////
void printUsage()
{
std::cout << "===============================" << std::endl;
std::cout << " TAB - Switch render engines " << std::endl;
std::cout << " ESC - Exit " << std::endl;
std::cout << "===============================" << std::endl;
}

//////////////////////////////////////////////////
void run(std::vector<ir::CameraPtr> _cameras)
{
if (_cameras.empty())
{
ignerr << "No cameras found. Scene will not be rendered" << std::endl;
return;
}

#if __APPLE__
g_context = CGLGetCurrentContext();
#elif _WIN32
g_context = wglGetCurrentContext();
g_display = wglGetCurrentDC();
#else
g_context = glXGetCurrentContext();
g_display = glXGetCurrentDisplay();
g_drawable = glXGetCurrentDrawable();
#endif

g_cameras = _cameras;
initCamera(_cameras[0]);
initContext();
printUsage();

#if __APPLE__
g_glutContext = CGLGetCurrentContext();
#elif _WIN32
g_glutContext = wglGetCurrentContext();
g_glutDisplay = wglGetCurrentDC();
#else
g_glutDisplay = glXGetCurrentDisplay();
g_glutDrawable = glXGetCurrentDrawable();
g_glutContext = glXGetCurrentContext();
#endif

glutMainLoop();
}
29 changes: 29 additions & 0 deletions examples/visualization_demo/GlutWindow.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_RENDERING_EXAMPLES_VISUALIZATION_DEMO_GLUTWINDOW_HH_
#define IGNITION_RENDERING_EXAMPLES_VISUALIZATION_DEMO_GLUTWINDOW_HH_

#include <vector>
#include "ignition/rendering/RenderTypes.hh"

namespace ir = ignition::rendering;

/// \brief Run the demo and render the scene from the cameras
/// \param[in] _cameras Cameras in the scene
void run(std::vector<ir::CameraPtr> _cameras);

#endif
Loading

0 comments on commit 605d7ee

Please sign in to comment.