资源简介
Name: ReadDepth
Desc: 通过读取Z Buffer深度值将屏幕2D坐标转化为场景3D坐标
操作:点击鼠标左键,在标题栏上会显示深度值和转化后的场景3D坐标
代码片段和文件信息
/*
written by SM3Dbase on NeHe‘s simple basecode.
welcome to visit my website:http://sm3d.126.com
*/
/*
* This Code Was Created By Jeff Molofee 2000
* A HUGE Thanks To Fredric Echols For Cleaning Up
* And Optimizing This Code Making It More Flexible!
* If You‘ve Found This Code Useful Please Let Me Know.
* Visit My Site At nehe.gamedev.net
*/
#include // Header File For Windows
#include
#include // Header File For The OpenGL32 Library
#include // Header File For The GLu32 Library
#include // Header File For The Glaux Library
#pragma comment( lib “opengl32.lib“ ) // Search For OpenGL32.lib While linking
#pragma comment( lib “glu32.lib“ ) // Search For GLu32.lib While linking
#pragma comment( lib “glaux.lib“ ) // Search For GLaux.lib While linking
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLfloat winXwinYwinZ;
GLdouble object_xobject_yobject_z;
int mouse_xmouse_y;
char str[80];
LRESULT CALLBACK WndProc(HWND UINT WPARAM LPARAM); // Declaration For WndProc
GLvoid ReSizeGLScene(GLsizei width GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
glViewport(00widthheight); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f(GLfloat)width/(GLfloat)height0.1f100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f 0.0f 0.0f 0.0f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST); // Really Nice Perspective Calculations
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
return TRUE; // Initialization Went OK
}
int DrawGLScene(GLvoid) // Here‘s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset T
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 53760 2005-10-16 21:47 ReadDepth\ReadDepth.opt
文件 520 2004-12-17 15:22 ReadDepth\ReadDepth.dsw
文件 50176 2005-10-16 21:47 ReadDepth\ReadDepth.ncb
文件 1164 2005-10-16 17:54 ReadDepth\ReadDepth.plg
文件 3945 2004-12-19 17:12 ReadDepth\ReadDepth.dsp
文件 16891 2005-10-16 17:53 ReadDepth\main.cpp
文件 221282 2005-10-16 17:54 ReadDepth\ReadDepth.exe
文件 243 2005-10-16 21:51 ReadDepth\readme.txt
目录 0 2005-10-16 21:47 ReadDepth
----------- --------- ---------- ----- ----
348199 10
- 上一篇:240128液晶源程序
- 下一篇:51单片机作为i2c从设备加密芯片+红外+串口
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
- OpenGL实现飘动效果
- opengl室内场景的绘制,包括碰撞检测
评论
共有 条评论