태그: GPU

Off-screen Rendering (Render to Texture) using OpenGL

((Preliminaries)) 1. download the most recent version of GLEW library at http://glew.sourceforge.net/ 2. copy *.h files to “C:\Program Files\Microsoft Visual Studio 8\VC\include\GL” 3. copy *.lib files to “C:\Program Files\Microsoft Visual Studio 8\VC\lib” 4. copy *.dll files to “C:\WINDOWS\system32” #include <GL/glew.h> #include <GL/glut.h> #include <iostream> using namespace std;#pragma comment( lib, "glew32.lib"  ) #pragma comment( lib, "glew32s.lib"

How to get depth value form depth buffer in OpenGL

glEnable( GL_DEPTH_TEST ); glDepthMask( 1 ); glDepthFunc( GL_LEQUAL ); float onePixel; glReadPixels( xPos, yPos, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &onePixel ); float *depth = new float[w*h]; glReadPixels( xPos, yPos, w, h, GL_DEPTH_COMPONENT, GL_FLOAT, depth ); delete depth;