资源简介
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绘制三维
- vs搭建OpenGL所需文件 & 简易天体运动源
- LIB3DS,OpenGL显示3DS文件
- freeglut-3.2.1.rar
- OPENGL三维绘图
- opengl开发库文件
- opengl雪花koch
- qt opengl 2d纹理到球面
- OpenGL实现机器人运动下蹲、起身、走
- OpenGL完整测试文件
- OpenGL绘制3D机器人
- 包含GlU32.Lib glut32.dll glut32.lib glut.dll
- gl/glext.h
- glutdlls37beta
- opengl所需的5个基本文件
- gltools/freeglut
- openGL中的glut库,32位和64位
- openGL期末大作业——行走的机器人
- OpenGL立方体带黑白格格纹理有光照可
- 计算机图形学OpenGL、codeblock、四连通
- opengl鼠标旋转,键盘缩放和平移
- opengl头文件glext.h
- 计算机图形学OpengL蔡士杰等译 随书代
- OPENGL室内三维效果
- YUV420在qt5下显示
- glut工具库
- 计算机图形学 交互实体模型
- OPENGL读取显示obj模型_VS2010
- 运用Opengl和C实现一个人体面部的三维
- opengl实现分形山脉
评论
共有 条评论