void PointCloudApplication::render_camera_frame() {
	switch_to_ortho();
	
	//glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(/*GL_COLOR_BUFFER_BIT | */GL_DEPTH_BUFFER_BIT);	
	
	glBindTexture(GL_TEXTURE_2D, video_texture);

	glEnable(GL_TEXTURE_2D);
	glDisable(GL_DEPTH_TEST);
	
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
	
	glColor4f(1.0, 1.0, 1.0, 1.0);
	glVertexPointer(2, GL_FLOAT, 0, video_vertices);
	glTexCoordPointer( 2, GL_FLOAT, 0, video_texcoords);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
	
	glDisable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
}
/*
 * Draws the required (for the free SDK) logo in the bottom-left corner of the visible camera feed
 */
void PointCloudApplication::draw_logo() {
	int h = context.viewport_height;
	int w = context.viewport_width;
	double scale_factor = w == 320 ? 0.5 : 1.0;
	switch_to_ortho();
	draw_image(logo_texture, 10, h-(140+54)*scale_factor, 262*scale_factor, 54*scale_factor, 0, 0, 1, 1);
}
void PointCloudApplication::setup_graphics() {
	// Define Viewport
	glViewport(0, 
			   0, 
			   context.viewport_width * ui_scale_factor, 
			   context.viewport_height * ui_scale_factor);
	
	setup_video_texture();
	
	logo_texture  = read_png_texture("pointcloud-logo.png");
	point_texture = read_png_texture("trackpoint.png");
	
	switch_to_ortho();
}
/*
 * Renders the tracked points
 */
void PointCloudApplication::render_point_cloud() {
	
    pointcloud_state state = pointcloud_get_state();
		     
    if (state == POINTCLOUD_INITIALIZING ||
		state == POINTCLOUD_TRACKING_SLAM_MAP) {
        
        pointcloud_point_cloud* points = pointcloud_get_points();
		
        if (points) {
			switch_to_camera();
			disable_lighting();

			glDisable(GL_DEPTH_TEST);

            glColor4f(0.9, 0.95, 1.0, 0.6);
            
            glEnable(GL_POINT_SPRITE_OES);
            glEnable(GL_TEXTURE_2D);
            
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			
			glBindTexture(GL_TEXTURE_2D, point_texture);

            glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE);
            
            glPointParameterf(GL_POINT_SIZE_MAX, 64.0f);
            
			glPointSize(32.0);
			glEnableClientState(GL_VERTEX_ARRAY);
            glVertexPointer(3,GL_FLOAT,0, (float *)points->points);
            glDrawArrays(GL_POINTS,0, points->size);
			
			glDisableClientState(GL_VERTEX_ARRAY);
            
            glColor4f(1, 1, 1, 1);
			
			glPointSize(1);

			glDisable(GL_BLEND);
			glDisable(GL_TEXTURE_2D);            
			glDisable(GL_POINT_SPRITE_OES);
			
			pointcloud_destroy_point_cloud(points);
			
			switch_to_ortho();
        }
    }    
}
Ejemplo n.º 5
0
//TODO: ES2ify
void App::render_content(double time_since_last_frame) {
	
    pointcloud_state state = pointcloud_get_state();
	
	// Draw the content if we have SLAM or image tracking
	if (state == POINTCLOUD_TRACKING_SLAM_MAP || state == POINTCLOUD_TRACKING_IMAGES) {
        
		switch_to_camera();
        
//        // Set light position
//        static const float light_position[4] = {1, 6, 0.5, 1.0f};
//        glLightfv(GL_LIGHT0, GL_POSITION, light_position);
//        
//		glColor4f(1,0,0,1);
//		
//		glDisable(GL_TEXTURE_2D);
//		glEnable(GL_COLOR_MATERIAL);
//		glShadeModel(GL_FLAT);
//		
//		glEnableClientState(GL_VERTEX_ARRAY);
//		glEnableClientState(GL_NORMAL_ARRAY);
//		
//		glVertexPointer(3, GL_FLOAT, 0, (float *)cuboid_vertices);
//		glNormalPointer(GL_FLOAT, 0, (float *)cuboid_normals);
//		glDrawArrays(GL_TRIANGLE_STRIP, 0, 19);
//		
//		glDisableClientState(GL_NORMAL_ARRAY);
//		glDisableClientState(GL_VERTEX_ARRAY);
//		
//		glShadeModel(GL_SMOOTH);
//		glDisable(GL_COLOR_MATERIAL);
//		glColor4f(1, 1, 1, 1);
	}
	
	// Draw the UI on top of the content
	switch_to_ortho();
	draw_ui();
}