20 printf(
"There are %d connected RealSense devices.\n", ctx.
get_device_count());
24 printf(
"\nUsing device 0, an %s\n", dev->
get_name());
25 printf(
" Serial number: %s\n", dev->
get_serial());
28 const auto streams = 4;
31 std::atomic<bool> running(
true);
39 std::map<rs::stream, resolution> resolutions;
41 for (
auto i = 0; i < streams; i++)
46 if (running) frames_queue[i].enqueue(std::move(frame));
67 auto max_aspect_ratio = 0.0f;
68 for (
auto i = 0; i < streams; i++)
70 auto aspect_ratio =
static_cast<float>(resolutions[
static_cast<rs::stream>(i)].
height) /
static_cast<float>(resolutions[
static_cast<rs::stream>(i)].
width);
71 if (max_aspect_ratio < aspect_ratio)
72 max_aspect_ratio = aspect_ratio;
75 auto win =
glfwCreateWindow(1100,
int(1100 * max_aspect_ratio),
"librealsense - callback 2",
nullptr,
nullptr);
87 glViewport(0, 0, w, h);
88 glClear(GL_COLOR_BUFFER_BIT);
92 glOrtho(0, w, h, 0, -1, +1);
94 for (
auto i = 0; i < streams; i++)
98 if (frames_queue[i].try_dequeue(&frame))
103 auto x = (i % 2) * (w / 2);
104 auto y = (i / 2) * (h / 2);
105 buffers[i].
show(
x,
y, w / 2, h / 2,
res.width,
res.height);
113 for (
auto i = 0; i < streams; i++) frames_queue[i].clear();
117 for (
auto i = 0; i < streams; i++)
128 printf(
" %s\n", e.what());
Provides convenience methods relating to devices.
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.
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
const std::string & get_failed_args() const
GLint GLint GLsizei GLsizei height
const char * get_firmware_version() const
Retrieves version of firmware currently installed on device.
GLint GLint GLint GLint GLint GLint y
int get_stream_width(stream stream) const
Retrieves width, in pixels, of a specific stream, equivalent to the width field from the stream's int...
Exposes librealsense functionality for C++ compilers.
GLfloat GLfloat GLfloat GLfloat h
void stop(rs::source source=rs::source::video)
Ends streaming on all streams for this device.
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
void show(float rx, float ry, float rw, float rh) const
stream
Streams are different types of data provided by RealSense devices.
int get_stream_height(stream stream) const
Retrieves height, in pixels, of a specific stream, equivalent to the height field from the stream's i...
bool is_stream_enabled(stream stream) const
Determines if specific stream is enabled.
const char * get_name() const
Retrieves human-readable device model string.
format
Formats: defines how each stream can be encoded. rs_format specifies how a frame is represented in me...
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 void * get_data() const
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.
void disable_stream(stream stream)
Disables specific stream.
GLint GLint GLsizei width
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
void set_frame_callback(rs::stream stream, std::function< void(frame)> frame_handler)
Sets callback for frame arrival event.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
bool supports(capabilities capability) const
Determines device capabilities.
device * get_device(int index)
const std::string & get_failed_function() const
GLint GLint GLint GLint GLint x
GLubyte GLubyte GLubyte GLubyte w
void upload(const void *data, int width, int height, rs::format format, int stride=0)
int get_device_count() const
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.