资源简介
一个光线追踪的源程序,有助于了解相关的渲染技术
代码片段和文件信息
/******************************************************************************
Author: Xiaoqiang ding
Email: xiaoqiangding@126.com
******************************************************************************/
#include “declares.h“
HWND hWnd;
BITMAPINFO bmpInfo;
HDC hDC;
COLOR32 buffer[SCREEN_HEIGHT*SCREEN_WIDTH];
CRayTracer* tracer = 0;
LRESULT CALLBACK WndProc(HWND hWnd UINT message WPARAM wParam LPARAM lParam);
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE hInstance int nCmdShow);
int APIENTRY WinMain(HINSTANCE hInstanceHINSTANCE hPrevInstanceLPSTR lpCmdLineint nCmdShow)
{
MyRegisterClass(hInstance);
if (!InitInstance (hInstance nCmdShow))
{
return FALSE;
}
ZeroMemory(&bmpInfo sizeof(bmpInfo));
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 32;
bmpInfo.bmiHeader.biCompression = BI_RGB;
bmpInfo.bmiHeader.biWidth = SCREEN_WIDTH;
bmpInfo.bmiHeader.biHeight = -SCREEN_HEIGHT;
hDC = GetDC(hWnd);
tracer = new CRayTracer();
tracer->GetScene()->InitScene();
tracer->SetBuffer(buffer SCREEN_WIDTH SCREEN_HEIGHT);
MSG message;
tracer->InitRender();
while(1)
{
if(tracer->Render())
tracer->InitRender();
while(PeekMessage(&message hWnd 0 0 PM_REMOVE))
{
TranslateMessage(&message );
DispatchMessage(&message );
}
StretchDIBits(hDC 0 0 SCREEN_WIDTH SCREEN_HEIGHT 0 0 SCREEN_WIDTH SCREEN_HEIGHT buffer &bmpInfo DIB_RGB_COLORS SRCCOPY);
}
return 1;
}
///////////////////////////////////////////////////////////////////////////////
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hCursor = LoadCursor(NULL IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = “Raytracer“;
wcex.hIconSm = NULL;
return RegisterClassEx(&wcex);
}
///////////////////////////////////////////////////////////////////////////////
BOOL InitInstance(HINSTANCE hInstance int nCmdShow)
{
// hInst = hInstance;
// make the window show at the center of the screen and the client area size is 800*600
RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = SCREEN_WIDTH;
rect.bottom = SCREEN_HEIGHT;
AdjustWindowRect(&rect WS_POPUP | WS_SYSMENU | WS_CAPTION NULL);
int windowWidth = rect.right - rect.left;
int windowHeight = rect.bottom - rect.top;
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
int windowLeft = (screenWidth - windowWidth) / 2;
int windowTop = (screenHeight - windowHeight) / 2;
hWnd = CreateWindow(“R
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-04-09 16:26 Raytracer\
目录 0 2013-04-09 16:26 Raytracer\Debug\
文件 11740 2012-11-12 09:30 Raytracer\Debug\BuildLog.htm
文件 3054 2012-04-11 15:55 Raytracer\Debug\Point3.obj
文件 411136 2012-11-12 09:30 Raytracer\Debug\Raytracer.exe
文件 406 2012-11-12 09:30 Raytracer\Debug\Raytracer.exe.em
文件 472 2012-11-12 09:30 Raytracer\Debug\Raytracer.exe.em
文件 381 2012-11-12 09:30 Raytracer\Debug\Raytracer.exe.intermediate.manifest
文件 278852 2012-11-12 09:30 Raytracer\Debug\Raytracer.ilk
文件 2157568 2012-11-12 09:30 Raytracer\Debug\Raytracer.pdb
文件 29477 2012-11-12 09:30 Raytracer\Debug\main.obj
文件 29478 2012-11-12 09:30 Raytracer\Debug\material.obj
文件 65 2012-11-12 09:30 Raytracer\Debug\mt.dep
文件 28856 2012-11-12 09:30 Raytracer\Debug\plane.obj
文件 28089 2012-11-12 09:30 Raytracer\Debug\primitive.obj
文件 24142 2012-11-12 09:30 Raytracer\Debug\ray.obj
文件 38724 2012-11-12 09:30 Raytracer\Debug\raytracer.obj
文件 37700 2012-11-12 09:30 Raytracer\Debug\scene.obj
文件 31298 2012-11-12 09:30 Raytracer\Debug\sphere.obj
文件 11979 2012-04-14 15:46 Raytracer\Debug\surface.obj
文件 156672 2012-04-16 15:35 Raytracer\Debug\vc60.idb
文件 77824 2012-04-16 15:35 Raytracer\Debug\vc60.pdb
文件 486400 2012-11-12 09:30 Raytracer\Debug\vc90.idb
文件 118784 2012-11-12 09:30 Raytracer\Debug\vc90.pdb
文件 33013 2012-11-12 09:30 Raytracer\Debug\vector3.obj
文件 340 2012-04-14 21:23 Raytracer\Plane.h
文件 5012 2012-04-14 21:22 Raytracer\Raytracer.dsp
文件 526 2012-04-11 15:34 Raytracer\Raytracer.dsw
文件 7605248 2013-03-06 08:59 Raytracer\Raytracer.ncb
文件 52736 2012-04-28 10:22 Raytracer\Raytracer.opt
文件 1321 2012-04-28 10:21 Raytracer\Raytracer.plg
............此处省略33个文件信息
- 上一篇:软件工程开发各种项目文档
- 下一篇:RS-232中国标准文档
评论
共有 条评论