13 #define GLFW_INCLUDE_GLU 41 printf(
"There are %d connected RealSense devices.\n", ctx.
get_device_count());
46 printf(
"\nUsing device 0, an %s\n", dev->
get_name());
47 printf(
" Serial number: %s\n", dev->
get_serial());
78 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
79 glMatrixMode(GL_PROJECTION);
81 gluPerspective(60, (
float)1280/960, 0.01
f, 20.0
f);
82 glMatrixMode(GL_MODELVIEW);
84 gluLookAt(0,0,0, 0,0,1, 0,-1,0);
85 glTranslatef(0,0,+0.5
f);
86 glRotated(
pitch, 1, 0, 0);
87 glRotated(
yaw, 0, 1, 0);
88 glTranslatef(0,0,-0.5
f);
92 glEnable(GL_DEPTH_TEST);
95 for(
int dy=0; dy<depth_intrin.
height; ++dy)
97 for(
int dx=0; dx<depth_intrin.
width; ++dx)
100 uint16_t depth_value = depth_image[dy * depth_intrin.
width + dx];
101 float depth_in_meters = depth_value *
scale;
104 if(depth_value == 0)
continue;
107 rs::float2 depth_pixel = {(float)dx, (
float)dy};
113 const int cx = (
int)std::round(color_pixel.
x), cy = (
int)std::round(color_pixel.
y);
114 if(cx < 0 || cy < 0 || cx >= color_intrin.
width || cy >= color_intrin.
height)
116 glColor3ub(255, 255, 255);
120 glColor3ubv(color_image + (cy * color_intrin.
width + cx) * 3);
124 glVertex3f(depth_point.
x, depth_point.
y, depth_point.
z);
138 printf(
" %s\n", e.what());
void log_to_console(log_severity min_severity)
Provides convenience methods relating to devices.
intrinsics get_stream_intrinsics(stream stream) const
Retrieves intrinsic camera parameters for specific stream.
void enable_stream(stream stream, int width, int height, format format, int framerate, output_buffer_format output_buffer_type=output_buffer_format::continous)
Enables specific stream and requests specific properties.
static void on_cursor_pos(GLFWwindow *win, double x, double y)
const std::string & get_failed_args() const
extrinsics get_extrinsics(stream from_stream, stream to_stream) const
Retrieves extrinsic transformation between viewpoints of two different streams.
Cross-stream extrinsics: encode the topology describing how the different devices are connected...
const char * get_firmware_version() const
Retrieves version of firmware currently installed on device.
GLint GLint GLint GLint GLint GLint y
GLenum GLenum GLenum GLenum GLenum scale
Exposes librealsense functionality for C++ compilers.
static void on_mouse_button(GLFWwindow *win, int button, int action, int mods)
const void * get_frame_data(stream stream) const
Retrieves contents of latest frame on a stream.
struct GLFWwindow GLFWwindow
Opaque window object.
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
const char * get_name() const
Retrieves human-readable device model string.
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
void start(rs::source source=rs::source::video)
Begins streaming on all enabled streams for this device.
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
const char * get_serial() const
Retrieves unique serial number of device.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
float get_depth_scale() const
Retrieves mapping between units of depth image and meters.
float3 deproject(const float2 &pixel, float depth) const
device * get_device(int index)
float3 transform(const float3 &point) const
const std::string & get_failed_function() const
GLint GLint GLint GLint GLint x
float2 project(const float3 &point) const
void wait_for_frames()
Blocks until new frames are available.
int get_device_count() const
static double clamp(double val, double lo, double hi)
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.