求助:DirectX 8.0 源码调试

proof1 proof1 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
学一本书《Direct3D中的2D编程》,书中只写理论,没有实验操作步骤。
第一章第一节的源码,就没有通过。

实验配置:
Windows7、DX8_SDK
Cfree5.0,设置了Include和Library目录。源码未通过。
VC++6.0,设置了Include和Library目录。源码未通过。

网上看到以下片段:
“第二步:添加链接所需的库文件,如dxguid.lib、d3d9.lib、d3dx9.lib等,……”

这一步骤我不懂,不知是否因为缺少这一步骤?针对DX8和本源码,该如何设置?

----------------------------------------------------------------------------------------
下载: 源码 +《Direct3D中的2D编程》PDF
https://download.csdn.net/download/u010971968/5882089

PDF在线阅读
https://ishare.iask.sina.com.cn/f/22639180.html

附源码Example1_1,所有源码可在上面链接下载

//Example1_1
//main.cpp
//Ernest Pazera
//04OCT2001
//TGO-01-C
//Libs: d3d8.lib

#include <windows.h> //include windows stuff
#include <stdio.h> //standard input/output
#include "D3D8.h" //include direct3d8 stuff

//constants
//window class name
const char* WINDOWCLASS = "3D42DGP" ;
//window title
const char* WINDOWTITLE = "Example 1.1 (TGO-01-C): Creating and Destroying an IDirect3D8 object" ;

//globals
//instance handle
HINSTANCE g_hInstance = NULL ;
//window handle
HWND g_hWnd = NULL ;
//IDirect3D8 pointer
IDirect3D8* g_pd3d = NULL ;

//function prototypes
//winmain
int WINAPI WinMain ( HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpCmdLine , int nShowCmd ) ;
//window procedure
LRESULT CALLBACK TheWindowProc ( HWND hWnd , UINT uMsg , WPARAM wParam , LPARAM lParam ) ;
//initialization
void Prog_Init ( ) ;
//clean up
void Prog_Done ( ) ;


//window procedure
LRESULT CALLBACK TheWindowProc ( HWND hWnd , UINT uMsg , WPARAM wParam , LPARAM lParam )
{
//which message did we get?
switch ( uMsg )
{
case WM_DESTROY : //window being destroyed
{
//quit

PostQuitMessage ( 0 ) ;

//message handled, return 0

return ( 0 ) ;

} break ;
default: //all other messages, send to default handler
return ( DefWindowProc ( hWnd , uMsg , wParam , lParam ) ) ;
}
}

//winmain
int WINAPI WinMain ( HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpCmdLine , int nShowCmd )
{
//grab instance handle
g_hInstance = hInstance ;

//redirect stderr and stdout output
freopen ( "stderr.txt" , "w" , stderr ) ;
freopen ( "stdout.txt" , "w" , stdout ) ;

//fill in window class
WNDCLASSEX wc ;
wc.cbClsExtra = 0 ; //no extra class information
wc.cbSize = sizeof ( WNDCLASSEX ) ; //size of structure
wc.cbWndExtra = 0 ; //no extra window information
wc.hbrBackground = ( HBRUSH ) GetStockObject ( BLACK_BRUSH ) ; //black brush
wc.hCursor = NULL ; //no cursor
wc.hIcon = NULL ; //no icon
wc.hIconSm = NULL ; //no small icon
wc.hInstance = g_hInstance ; //instance handle
wc.lpfnWndProc = TheWindowProc ; //window procedure
wc.lpszClassName = WINDOWCLASS ; //name of class
wc.lpszMenuName = NULL ; //no menu
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC ; //class styles

//register window class
RegisterClassEx ( &wc ) ;

//create window
g_hWnd = CreateWindowEx ( 0 , WINDOWCLASS , WINDOWTITLE , WS_OVERLAPPEDWINDOW , 0 , 0 , 320 , 240 , NULL , NULL , g_hInstance , NULL ) ;

//show the window
ShowWindow ( g_hWnd , nShowCmd ) ;

//initialization
Prog_Init ( ) ;

MSG msg ;
//message pump
for ( ; ; )
{
//check for a message
if ( PeekMessage( &msg , NULL , 0 , 0 , PM_REMOVE ) )
{
//message exists

//check for quit message
if ( msg.message == WM_QUIT ) break ;

//translate the message
TranslateMessage ( &msg ) ;

//dispatch the message
DispatchMessage ( &msg ) ;
}
}

//clean up
Prog_Done ( ) ;

//exit
return ( msg.wParam ) ;
}

//initialization
void Prog_Init ( )
{
//create the IDirect3D8 object
g_pd3d = Direct3DCreate8 ( D3D_SDK_VERSION ) ;

//error check
if ( g_pd3d )
{
//success
fprintf ( stdout , "IDirect3D8 object created successfully.\n" ) ;
}
else
{
//failure
fprintf ( stderr , "IDirect3D8 object creation failed.\n" ) ;
}
}

//clean up
void Prog_Done ( )
{
//safe release of IDirect3D8 object
if ( g_pd3d )
{
//release
g_pd3d->Release ( ) ;

//set to null
g_pd3d = NULL ;

//report action
fprintf ( stdout , "IDirect3D8 object released.\n" ) ;
}
}


...全文

相关推荐

DirectX9.0+3D游戏开发编程基础(PDF+源码)

本资源包含一本关于DirectX9.0和3D游戏开发的编程书籍的PDF版本以及配套的源码,对于初学者来说是一个很好的学习平台。首先,我们要了解DirectX9.0的主要组成部分:1.

yang1013114323

DirectX 11核心编程实战:D3D11教程2源码解析

是一个关键的结构体,用于描述渲染目标上的一块矩形区域,该区域将成为当前绘制命令的目标空间。它不仅限定了像素坐标的映射范围,还参与了从裁剪空间到屏幕空间的坐标变换过程。其定义如下:成员字段含义说明TopLeftXTopLeftY视口左上角在渲染目标中的像素坐标WidthHeight视口的宽度和高度(像素单位)MinDepthMaxDepth深度值映射范围,默认为0.0~1.0。

闲书郎

使用DirectX进行抓屏源码

在这个场景中,"使用DirectX进行抓屏源码"指的是利用DirectX的技术来捕获屏幕内容。这种技术常用于游戏截图、屏幕录制或者实时监控等多种用途。

dreamnear

Directx8中教程及源码.rar

这个压缩包“Directx8中教程及源码.rar”包含了关于DirectX 8的教程和源代码,帮助学习者深入理解DirectX 8在3D图形编程中的应用。

cmf41013

DirectX8.0基本框架

在"DirectX8.0框架"的压缩包中,可能包含了以下内容:- 源代码文件:通常分为多个模块,如初始化、渲染、输入处理、音频管理等,结构清晰,便于阅读和修改。

东方盛夏
评论 1
收藏 已收藏
分享
返回顶部