19 #define GLFW_INCLUDE_GLU 116 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
117 glMatrixMode(GL_PROJECTION);
119 gluPerspective(60, (
float)1280/960, 0.01
f, 20.0
f);
120 glMatrixMode(GL_MODELVIEW);
122 gluLookAt(0,0,0, 0,0,1, 0,-1,0);
123 glTranslatef(0,0,+0.5
f);
124 glRotated(
pitch, 1, 0, 0);
125 glRotated(
yaw, 0, 1, 0);
126 glTranslatef(0,0,-0.5
f);
130 glEnable(GL_DEPTH_TEST);
134 for(dy=0; dy<depth_intrin.
height; ++dy)
136 for(dx=0; dx<depth_intrin.
width; ++dx)
139 uint16_t depth_value = depth_image[dy * depth_intrin.
width + dx];
140 float depth_in_meters = depth_value *
scale;
143 if(depth_value == 0)
continue;
146 float depth_pixel[2] = {(float)dx, (
float)dy};
147 float depth_point[3], color_point[3], color_pixel[2];
153 const int cx = (
int)roundf(color_pixel[0]), cy = (
int)roundf(color_pixel[1]);
154 if(cx < 0 || cy < 0 || cx >= color_intrin.
width || cy >= color_intrin.
height)
156 glColor3ub(255, 255, 255);
160 glColor3ubv(color_image + (cy * color_intrin.
width + cx) * 3);
164 glVertex3f(depth_point[0], depth_point[1], depth_point[2]);
static void on_mouse_button(GLFWwindow *win, int button, int action, int mods)
void rs_get_stream_intrinsics(const rs_device *device, rs_stream stream, rs_intrinsics *intrin, rs_error **error)
Retrieves intrinsic camera parameters for a specific stream.
static void on_cursor_pos(GLFWwindow *win, double x, double y)
int rs_get_device_count(const rs_context *context, rs_error **error)
Determines number of connected devices.
GLint GLint GLint GLint GLint GLint y
void rs_log_to_console(rs_log_severity min_severity, rs_error **error)
Starts logging to console.
GLenum GLenum GLenum GLenum GLenum scale
const void * rs_get_frame_data(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the contents of the latest frame on a stream.
const char * rs_get_device_name(const rs_device *device, rs_error **error)
Retrieves human-readable device model string.
const char * rs_get_error_message(const rs_error *error)
Returns static pointer to error message.
float rs_get_device_depth_scale(const rs_device *device, rs_error **error)
Retrieves mapping between the units of the depth image and meters.
static void rs_project_point_to_pixel(float pixel[2], const struct rs_intrinsics *intrin, const float point[3])
Exposes librealsense functionality for C compilers.
static void rs_transform_point_to_point(float to_point[3], const struct rs_extrinsics *extrin, const float from_point[3])
struct GLFWwindow GLFWwindow
Opaque window object.
const char * rs_get_failed_function(const rs_error *error)
Returns static pointer to name of a failing function in case of error.
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
rs_context * rs_create_context(int api_version, rs_error **error)
Creates RealSense context that is required for the rest of the API.
void rs_get_device_extrinsics(const rs_device *device, rs_stream from_stream, rs_stream to_stream, rs_extrinsics *extrin, rs_error **error)
Retrieves extrinsic transformation between the viewpoints of two different streams.
static double clamp(double val, double lo, double hi)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
const char * rs_get_device_firmware_version(const rs_device *device, rs_error **error)
Retrieves the version of the firmware currently installed on the 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.
static void rs_deproject_pixel_to_point(float point[3], const struct rs_intrinsics *intrin, const float pixel[2], float depth)
const char * rs_get_failed_args(const rs_error *error)
Returns static pointer to arguments of a failing function in case of error.
Cross-stream extrinsics: encode the topology describing how the different devices are connected...
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
rs_device * rs_get_device(rs_context *context, int index, rs_error **error)
Retrieves connected device by index.
const char * rs_get_device_serial(const rs_device *device, rs_error **error)
Retrieves unique serial number of the device.
void rs_wait_for_frames(rs_device *device, rs_error **error)
Blocks until new frames are available.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
void rs_enable_stream_preset(rs_device *device, rs_stream stream, rs_preset preset, rs_error **error)
Enables a specific stream and requests properties using a preset.
void rs_start_device(rs_device *device, rs_error **error)
Begins streaming on all enabled streams for this device.
GLint GLint GLint GLint GLint x
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.