18 std::chrono::high_resolution_clock::time_point
last_clock;
23 int main(
int argc,
char * argv[])
try 27 bool use_gpu_processing =
true;
30 window app(1280, 720,
"RealSense GPU-Processing Example");
63 float proj_matrix[16];
64 float view_matrix[16];
102 proj_matrix, view_matrix);
111 texture_id = gpu_frame.get_texture_id(0);
116 tex.
upload(depth_texture);
136 if (points) pc_renderer.
process(points);
164 catch (
const std::exception & e)
187 std::stringstream ss;
188 ss <<
"Performing Point-Cloud and Histogram-Equalization (Colorize) on the " << (use_gpu_processing ?
"GPU" :
"CPU");
192 ss <<
"( Press " << (use_gpu_processing ?
"[C] - Switch to processing on the CPU )" :
"[G] - Switch to processing on the GPU )");
196 ss <<
"This demo is being rendered at " <<
last_fps <<
" frames per second, ~" << (1000 / (
last_fps + 1)) <<
"ms for single rendered frame";
202 auto sec_elapsed = std::chrono::duration_cast<std::chrono::seconds>(since_last_clock).
count();
217 reset = use_gpu_processing;
218 use_gpu_processing =
false;
222 reset = !use_gpu_processing;
223 use_gpu_processing =
true;
235 gluPerspective(60, width / height, 0.01
f, 10.0
f);
240 gluLookAt(0, 0, 0, 0, 0, 1, 0, -1, 0);
void init_processing(bool use_glsl=true)
void prepare_matrices(glfw_state &app_state, float width, float height, float *projection, float *view)
video_frame colorize(frame depth) const
GLint GLint GLsizei GLsizei GLsizei depth
void map_to(frame mapped)
void shutdown_processing()
depth_frame get_depth_frame() const
const std::string & get_failed_args() const
rs2::frame process(rs2::frame frame) const override
bool poll_for_frames(frameset *f) const
void set_matrix(rs2_gl_matrix_type type, float *m4x4)
void print_instructions(window &app, bool use_gpu_processing)
void shutdown_rendering()
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
void upload(const rs2::video_frame &frame)
#define GL_PROJECTION_MATRIX
points calculate(frame depth) const
static const textual_icon upload
GLint GLsizei GLsizei height
std::chrono::high_resolution_clock::time_point last_clock
void init_rendering(bool use_glsl=true)
void enable_stream(rs2_stream stream_type, int stream_index, int width, int height, rs2_format format=RS2_FORMAT_ANY, int framerate=0)
#define GL_DEPTH_BUFFER_BIT
int main(int argc, char *argv[])
bool handle_input(window &app, bool &use_gpu_processing)
void draw_text(int x, int y, const char *text)
#define GL_MODELVIEW_MATRIX
void register_glfw_callbacks(window &app, glfw_state &app_state)
const std::string & get_failed_function() const
GLdouble GLdouble GLint GLint const GLdouble * points