#include<d3d9.h>
#include <d3dx9.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <tchar.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "winmm.lib ")
#define WINDOW_CLASS "UGPDX"
#define WINDOW_NAME "Blank D3D Window"
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 800
#define SAFE_RELEASE(p) {if(p){(p)->Release();(p)=NULL;}}
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg, WPARAM wParam,LPARAM lParam);//窗口过程
HRESULT Direct3D_Init(HWND hwnd);//3D初始化
void Direct3D_Render(HWND hwnd);//
HRESULT Objects_Init();//字体初始化
void Direct3D_CleanUp();//清理
float Get_FPS();//FPS
RECT g_FontPosition = {0, 0, 0, 0};//定义一个矩形,用于字体位置的设定
ID3DXFont* g_pFont=NULL; //字体COM接口
LPDIRECT3DDEVICE9 g_pd3dDevice =NULL;//DIRECT3D设备接口指针
LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer=NULL;//顶点缓存地址
float g_FPS = 0.0f; //一个浮点型的变量,代表帧速率
wchar_t g_strFPS[50]; //包含帧速率的字符数组
//1.定义一个只包含顶点三维坐标和颜色的结构体
struct CUSTOMVERTEX
{
float x, y, z,rhw; //顶点的三维坐标值,x,y,z
DWORD color; //顶点的颜色值
//float nx,ny,nz;//法线向量
//float u,v;//纹理坐标
};
#define D3DFVF_CUSTOMEVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
WNDCLASSEX wcex; //1.设计窗体
wcex.cbClsExtra=0;
wcex.cbSize=sizeof(WNDCLASSEX);
wcex.cbWndExtra=0;
wcex.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wcex.hCursor=NULL;
wcex.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_APPLICATION));//加载图标
wcex.hIconSm=NULL;
wcex.hInstance =hInstance;
wcex.lpfnWndProc =WndProc;
wcex.lpszClassName=_T("absurd");
wcex.lpszMenuName=NULL;
wcex.style =
使用direct3d9技术绘制文字和生成顶点缓存
最新推荐文章于 2019-10-23 23:46:21 发布
这是一个关于使用Direct3D9技术进行3D图形编程的示例,包括窗口创建、3D设备初始化、字体绘制、顶点缓存的创建和管理,以及帧率的计算和显示。
摘要由CSDN通过智能技术生成