#include "Globalh.h"
// Main Application Instances
HINSTANCE g_hInst; // Global instance handle
HWND g_hWnd; // Global window handle
IDirect3D9 *g_pD3D;
IDirect3DDevice9 *g_pD3DDevice;
D3DDISPLAYMODE d3ddm;
D3DPRESENT_PARAMETERS d3dpp;
D3DFORMAT d3df;
IDirect3DVertexBuffer9 *pD3DVB = NULL;
// Application window dimensions, type, class and window name
#define WNDWIDTH 640
#define WNDHEIGHT 480
#define WNDTYPE WS_OVERLAPPEDWINDOW
const char g_szClass[] = "FrameClass";
const char g_szCaption[] = "FrameCaption";
// Main application prototypes
//Entry point
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow);
// Function to display an error message
void AppError(BOOL Fatal, char *Text, ...);
// Message procedure
long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
// Functions to register and unregister windows' classes
BOOL RegisterWindowClasses(HINSTANCE hInst);
BOOL UnregisterWindowClasses(HINSTANCE hInst);
// Function to create the application window
HWND CreateMainWindow(HINSTANCE hInst);
// Functions to init, shutdown, and handle per-frame functions
BOOL DoInit();
BOOL DoShutdown();
BOOL DoPreFrame();
BOOL DoFrame();
BOOL DoPostFrame();
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow)
{
MSG Msg;
// Save application instance
g_hInst = hInst;
// Register window classes - return on FALSE
if(RegisterWindowClasses(hInst) == FALSE)
return FALSE;
// Create window - return on FALSE
if((g_hWnd = CreateMainWindow(hInst)) == NULL)
return FALSE;
// Do application initialization - return on FALSE
if(DoInit() == TRUE) {
// Enter the message pump
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT) {
// Handle Windows messages (if any)
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
} else {
// Do pre-frame processing, break on FALSE return value
if(DoPreFrame() == FALSE)
break;
// Do per-frame processing, break on FALSE return value
if(DoFrame() == FALSE)
break;
// Do post-frame processing, break on FALSE return value
if(DoPostFrame() == FALSE)
break;
}
}
}
// Do shutdown functions
DoShutdown();
// Unregister window
UnregisterWindowClasses(hInst);
return TRUE;
}
BOOL RegisterWindowClasses(HINSTANCE hInst)
{
WNDCLASSEX wcex;
// Create the window class here and register it
wcex.cbSize = sizeof(wcex);
wcex.style = CS_CLASSDC;
wcex.lpfnWndProc = WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInst;
wcex.hIcon = LoadIcon(NULL, "IDI_ZiP");
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = g_szClass;
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wcex))
return FALSE;
return TRUE;
}
BOOL UnregisterWindowClasses(HINSTANCE hInst)
{
// Unregister the window class
UnregisterClass(g_szClass, hInst);
return TRUE;
}
HWND CreateMainWindow(HINSTANCE hInst)
{
HWND hWnd;
// Create the Main Window
hWnd = CreateWindow(g_szClass, g_szCaption, WNDTYPE, 0, 0, WNDWIDTH, WNDHEIGHT, NULL, NULL, hInst, NULL);
if(!hWnd)
return NULL;
// Show and update the window
ShowWindow(hWnd, SW_NORMAL);
UpdateWindow(hWnd);
// Return the window handle
return hWnd;
}
void AppError(BOOL Fatal, char *Text, ...)
{
char CaptionText[12];
char ErrorText[2048];
va_list valist;
// Build the message box caption based on fatal flag
if(Fatal == FALSE)
strcpy(CaptionText, "Error");
else
strcpy(CaptionText, "Fatal Error");
// Build variable text buffer
va_start(valist, Text);
vsprintf(ErrorText, Text, valist);
va_end(valist);
// Display the message box
MessageBox(NULL, ErrorText, CaptionText, MB_OK | MB_ICONEXCLAMATION);
// Post a quit message if error was fatal
if(Fatal == TRUE)
PostQuitMessage(0);
}
// The message procedure - empty except for destroy message
long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
BOOL DoInit()
{
// Perform application initialization functions here
// such as those that set up the graphics, sound, network, etc.
if((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) {
//error
}
d3ddm.Width = 800;
d3ddm.Height = 600;
d3ddm.RefreshRate = 0;
d3ddm.Format = D3DFMT_R5G6B5;
d3df = D3DFMT_R5G6B5;
if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) {
// Error occurred
}
// Clear out the structure
ZeroMemory(&d3dpp,
sizeof(D3DPRESENT_PARAMETERS));
// For windowed mode, use:
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format; // use same color mode
// For both windowed and fullscreen, specify the width and height
d3dpp.BackBufferWidth = d3ddm.Width; // Supply your own width
d3dpp.BackBufferHeight = d3ddm.Height; // Supply your own height
if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice))) {
// Error occurred
}
//g_pD3DDevice->SetRenderState (D3DRS_CULLMODE, CULL_NONE);
g_pD3DDevice->SetRenderState (D3DRS_LIGHTING, FALSE);
g_pD3DDevice->Reset(&d3dpp);
g_pD3DDevice->SetRenderState (D3DRS_LIGHTING, FALSE);
if(FAILED(g_pD3DDevice->CreateVertexBuffer(sizeof(sVertex) * 4, D3DUSAGE_WRITEONLY, VertexFVF, D3DPOOL_MANAGED, &pD3DVB, NULL))) {
// Error occurred
}
BYTE *Ptr;
// Lock the vertex buffer memory and get a pointer to it
if(FAILED(pD3DVB->Lock(0, 0, (void**)&Ptr, 0))) {
// Error occurred
}
sVertex Verts[4] = {
{ -100.0f, 100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(255,255,255,255) },
{ 100.0f, 100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(255, 0, 0,255) },
{ 100.0f, -100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA( 0,255, 0,255) },
{ -100.0f, -100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA( 0, 0,255,255) }
};
// Return a value of TRUE for success, FALSE otherwise.
return TRUE;
}
BOOL DoShutdown()
{
// Perfer application shutdown functions here
// such as those that shut down the graphics, sound, etc.
g_pD3D->Release();
g_pD3DDevice->Release();
// Return a value of TRUE for success, FALSE otherwise.
return TRUE;
}
BOOL DoPreFrame()
{
// Perform pre-frame processing, such as setting up a timer.
// Return a value of TRUE for success, FALSE otherwise.
return TRUE;
}
BOOL DoFrame()
{
// Perform per-frame processing, such as rendering.
BYTE *Ptr;
// Lock the vertex buffer memory and get a pointer to it
if(SUCCEEDED(pD3DVB->Lock(0, 0, (void**)&Ptr, 0))) {
sVertex Verts[4] = {
{ -100.0f, 100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(255,255,255,255) },
{ 100.0f, 100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(255, 0, 0,255) },
{ 100.0f, -100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA( 0,255, 0,255) },
{ -100.0f, -100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA( 0, 0,255,255) }
};
// Copy local vertices into vertex buffer
memcpy(Ptr, Verts, sizeof(Verts));
// Unlock the vertex buffer
pD3DVB->Unlock();
}
// Return a value of TRUE for success, FALSE otherwise.
return TRUE;
}
BOOL DoPostFrame()
{
// Perform post-frame processing, such as time synching, etc.
// Return a value of TRUE for success, FALSE otherwise.
return TRUE;
}
Nothing renders???? C++
Well...you never render anything. :P
-You need to call IDirect3DDevice9::BeginScene before doing any rendering
-If you want to render the triangles in that vertex buffer, you need to set the vertex buffer as the current stream source using IDirect3DDevice9::SetStreamSource. you also need to set your FVF with IDirect3DDevice9::SetFVF. After this, you can call IDirect3DDevice9::DrawPrimitive to actually draw the triangles.
-When you're done rendering, you need to call IDirect3DDevice9::EndScene , and then call IDirect3DDevice9::Present to display the contents of the back-buffer.
If you need to see code for this stuff, look at the early tutorials in the DX SDK or look at one of the many tutorials available online. All of them cover this sort of basic stuff.
Also, are you getting this code from a sample? The WinAPI code looks really outdated.
-You need to call IDirect3DDevice9::BeginScene before doing any rendering
-If you want to render the triangles in that vertex buffer, you need to set the vertex buffer as the current stream source using IDirect3DDevice9::SetStreamSource. you also need to set your FVF with IDirect3DDevice9::SetFVF. After this, you can call IDirect3DDevice9::DrawPrimitive to actually draw the triangles.
-When you're done rendering, you need to call IDirect3DDevice9::EndScene , and then call IDirect3DDevice9::Present to display the contents of the back-buffer.
If you need to see code for this stuff, look at the early tutorials in the DX SDK or look at one of the many tutorials available online. All of them cover this sort of basic stuff.
Also, are you getting this code from a sample? The WinAPI code looks really outdated.
no its from a book i bought on amazon dot com but its missing the CD!!!! so i dont have the source code im trying to basically redo it with dx9 and no help! lol so im glad someone can. im going to call the publisher today and beg for them to mail me one....
Ummm, I can't see nothing like a swap or something like that to tell Dx that the screen is rendered and should be displayed on screen
How old is that book? because as MJP says, the winapi stuff is awesomely archaic... I had to do a doubletake before i was sure it was even correct! Buy a new book... I used Frank Luna's Introduction to 3D Game Programming with directx 9.0c, (the newer edition) it's a great, and up to date (ish) book.
OTOH, there are some great tutorials out there on the web, here at gamedev etc.
and, as MJP says - the directx sample apps are great - i ignored them and then spotted them a week or so ago - should have used them earlier.
OTOH, there are some great tutorials out there on the web, here at gamedev etc.
and, as MJP says - the directx sample apps are great - i ignored them and then spotted them a week or so ago - should have used them earlier.
// Main Application InstancesHINSTANCE g_hInst; // Global instance handleHWND g_hWnd; // Global window handle//hardware setupIDirect3D9 *g_pD3D;IDirect3DDevice9 *g_pD3DDevice;IDirect3DVertexBuffer9 *pD3DVB = NULL;//misc setupD3DDISPLAYMODE d3ddm;D3DPRESENT_PARAMETERS d3dpp;D3DFORMAT d3df;// ITS THE MATRIX!!!!D3DXMATRIX matWorld;D3DXMATRIX matRotX, matRotY, matRotZ;D3DXMATRIX matTrans;D3DXMATRIX matScale;D3DXMATRIX matView;D3DXMATRIX matProj;//material setupD3DMATERIAL9 d3dm;// Application window dimensions, type, class and window name#define WNDWIDTH 640#define WNDHEIGHT 480#define WNDTYPE WS_OVERLAPPEDWINDOWconst char g_szClass[] = "FrameClass";const char g_szCaption[] = "FrameCaption";// Main application prototypes//Entry pointint WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow);// Function to display an error messagevoid AppError(BOOL Fatal, char *Text, ...);// Message procedurelong WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);// Functions to register and unregister windows' classesBOOL RegisterWindowClasses(HINSTANCE hInst);BOOL UnregisterWindowClasses(HINSTANCE hInst);// Function to create the application windowHWND CreateMainWindow(HINSTANCE hInst);// Functions to init, shutdown, and handle per-frame functionsBOOL DoInit();BOOL DoShutdown();BOOL DoPreFrame();BOOL DoFrame();BOOL DoPostFrame();int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow){ MSG Msg; // Save application instance g_hInst = hInst; // Register window classes - return on FALSE if(RegisterWindowClasses(hInst) == FALSE) return FALSE; // Create window - return on FALSE if((g_hWnd = CreateMainWindow(hInst)) == NULL) return FALSE; // Do application initialization - return on FALSE if(DoInit() == TRUE) { // Enter the message pump ZeroMemory(&Msg, sizeof(MSG)); while(Msg.message != WM_QUIT) { // Handle Windows messages (if any) if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } else { // Do pre-frame processing, break on FALSE return value if(DoPreFrame() == FALSE) break; // Do per-frame processing, break on FALSE return value if(DoFrame() == FALSE) break; // Do post-frame processing, break on FALSE return value if(DoPostFrame() == FALSE) break; } } } // Do shutdown functions DoShutdown(); // Unregister window UnregisterWindowClasses(hInst); return TRUE;}BOOL RegisterWindowClasses(HINSTANCE hInst){ WNDCLASSEX wcex; // Create the window class here and register it wcex.cbSize = sizeof(wcex); wcex.style = CS_CLASSDC; wcex.lpfnWndProc = WindowProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInst; wcex.hIcon = LoadIcon(NULL, "IDI_ZiP"); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = NULL; wcex.lpszMenuName = NULL; wcex.lpszClassName = g_szClass; wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wcex)) return FALSE; return TRUE;}BOOL UnregisterWindowClasses(HINSTANCE hInst){ // Unregister the window class UnregisterClass(g_szClass, hInst); return TRUE;}HWND CreateMainWindow(HINSTANCE hInst){ HWND hWnd; // Create the Main Window hWnd = CreateWindow(g_szClass, g_szCaption, WNDTYPE, 0, 0, WNDWIDTH, WNDHEIGHT, NULL, NULL, hInst, NULL); if(!hWnd) return NULL; // Show and update the window ShowWindow(hWnd, SW_NORMAL); UpdateWindow(hWnd); // Return the window handle return hWnd;}void AppError(BOOL Fatal, char *Text, ...){ char CaptionText[12]; char ErrorText[2048]; va_list valist; // Build the message box caption based on fatal flag if(Fatal == FALSE) strcpy(CaptionText, "Error"); else strcpy(CaptionText, "Fatal Error"); // Build variable text buffer va_start(valist, Text); vsprintf(ErrorText, Text, valist); va_end(valist); // Display the message box MessageBox(NULL, ErrorText, CaptionText, MB_OK | MB_ICONEXCLAMATION); // Post a quit message if error was fatal if(Fatal == TRUE) PostQuitMessage(0);}// The message procedure - empty except for destroy messagelong WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ switch(uMsg) { case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, uMsg, wParam, lParam);}float XAngle;float YAngle;float ZAngle;float XPos;float YPos;float ZPos;float XScale;float YScale;float ZScale;BOOL DoInit(){ // Perform application initialization functions here // such as those that set up the graphics, sound, network, etc. if((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) { //error } d3ddm.Width = 800; d3ddm.Height = 600; d3ddm.RefreshRate = 0; d3ddm.Format = D3DFMT_R5G6B5; d3df = D3DFMT_R5G6B5; if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) { // Error occurred } // Clear out the structure ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); // For windowed mode, use: d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; // use same color mode // For both windowed and fullscreen, specify the width and height d3dpp.BackBufferWidth = d3ddm.Width; // Supply your own width d3dpp.BackBufferHeight = d3ddm.Height; // Supply your own height if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice))) { // Error occurred } g_pD3DDevice->Reset(&d3dpp); if(FAILED(g_pD3DDevice->CreateVertexBuffer(sizeof(sVertex) * 4, D3DUSAGE_WRITEONLY, VertexFVF, D3DPOOL_MANAGED, &pD3DVB, NULL))) { // Error occurred } BYTE *Ptr; // Lock the vertex buffer memory and get a pointer to it if(FAILED(pD3DVB->Lock(0, 0, (void**)&Ptr, 0))) { // Error occurred } sVertex Verts[4] = { { -100.0f, 100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, 100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA(255, 0, 0,255) }, { 100.0f, -100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA( 0,255, 0,255) }, { -100.0f, -100.0f, 100.0f, 1.0f, D3DCOLOR_RGBA( 0, 0,255,255) } }; // Lock the vertex buffer memory and get a pointer to it if(SUCCEEDED(pD3DVB->Lock(0, 0, (void**)&Ptr, 0))) { // Copy local vertices into vertex buffer memcpy(Ptr, Verts, sizeof(Verts)); // Unlock the vertex buffer pD3DVB->Unlock(); } if(FAILED(g_pD3DDevice->SetStreamSource(0, pD3DVB, 0, sizeof(sVertex)))) { // Error occurred } if(FAILED(g_pD3DDevice->SetFVF(VertexFVF))) { // Error occurred } // Create the rotation matrices D3DXMatrixRotationX(&matRotX, XAngle); D3DXMatrixRotationY(&matRotY, YAngle); D3DXMatrixRotationZ(&matRotZ, ZAngle); // Create the translation matrix D3DXMatrixTranslation(&matTrans, XPos, YPos, ZPos); // Create the scaling matrix D3DXMatrixScaling(&matScale, XScale, YScale, ZScale); // Set matWorld to identity D3DXMatrixIdentity(&matWorld); // Combine all matrices into world transformation matrix D3DXMatrixMultiply(&matWorld, &matWorld, &matScale); D3DXMatrixMultiply(&matWorld, &matWorld, &matRotX); D3DXMatrixMultiply(&matWorld, &matWorld, &matRotY); D3DXMatrixMultiply(&matWorld, &matWorld, &matRotZ); D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans); D3DXVECTOR3 vecVP, vecTP, vecUp(0.0f, 1.0f, 0.0f); vecVP.x = XPos; vecVP.y = YPos; vecVP.z = ZPos; vecTP.x = vecTP.y = vecTP.z = 0.0f; D3DXMatrixLookAtLH(&matView, &vecVP, &vecTP, &vecUp); if(FAILED(g_pD3DDevice->SetTransform(D3DTS_VIEW, &matView))) { // Error occurred } // Create the projection transformation matrix D3DXMatrixPerspectiveFovLH(&matProj,D3DX_PI/4,1.0f,1.0f,1000.0f); // Set the projection matrix with Direct3D if(FAILED(g_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj))) { // Error occurred } // Set the vertex stream and shader g_pD3DDevice->SetStreamSource(0, pD3DVB, 0, sizeof(sVertex)); g_pD3DDevice->SetFVF(VertexFVF); if(SUCCEEDED(g_pD3DDevice->BeginScene())) { // Render the polygons if(FAILED(g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2))) { // Error occurred } // End the scene g_pD3DDevice->EndScene(); } // Return a value of TRUE for success, FALSE otherwise. return TRUE;}BOOL DoShutdown(){ // Perfer application shutdown functions here // such as those that shut down the graphics, sound, etc. g_pD3D->Release(); g_pD3DDevice->Release(); pD3DVB->Release(); // Return a value of TRUE for success, FALSE otherwise. return TRUE;}BOOL DoPreFrame(){ // Perform pre-frame processing, such as setting up a timer. // Return a value of TRUE for success, FALSE otherwise. return TRUE;}BOOL DoFrame(){ // Perform per-frame processing, such as rendering. if(FAILED(g_pD3DDevice->Present(NULL, NULL, NULL, NULL))) { // Error occurred } // Return a value of TRUE for success, FALSE otherwise. return TRUE;}BOOL DoPostFrame(){ // Perform post-frame processing, such as time synching, etc. // Return a value of TRUE for success, FALSE otherwise. return TRUE;}
ok there i got stuff to display but its kinda screwed up dont really know what happened. its like a bunch of random stuff scattered on the screen. so then i switched
if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) { // Error occurred } // Clear out the structure ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); // For windowed mode, use: d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; // use same color mode // For both windowed and fullscreen, specify the width and height d3dpp.BackBufferWidth = d3ddm.Width; // Supply your own width d3dpp.BackBufferHeight = d3ddm.Height; // Supply your own height
with:
if(FAILED(g_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3df, d3df, FALSE))) { // Error occurred - color mode not supported }// Clear out the structure ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); // For fullscreen mode, use: d3dpp.Windowed = FALSE; d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; d3dpp.BackBufferFormat = d3ddm.Format; // use same color mode // For both windowed and fullscreen, specify the width and height d3dpp.BackBufferWidth = d3ddm.Width; // Supply your own width d3dpp.BackBufferHeight = d3ddm.Height; // Supply your own height
to make it fullscreen and it doesnt render anything still! dont i have it all now? it renders everything weird with windowed tho and nothing in fullscreen.
-What FVF are you using for your vertices?
-You're telling DrawPrimitive that you're drawing 2 triangles, but you're sending it 4 vertices.
-I'm pretty sure you can't use D3DSWAPEFFECT_FLIP in fullscreen. You should use the debug runtines, so that errors and warnings get output.
-You need to call BeginScene, DrawPrimitive, EndScene, and Present every time you render.
-You're telling DrawPrimitive that you're drawing 2 triangles, but you're sending it 4 vertices.
-I'm pretty sure you can't use D3DSWAPEFFECT_FLIP in fullscreen. You should use the debug runtines, so that errors and warnings get output.
-You need to call BeginScene, DrawPrimitive, EndScene, and Present every time you render.
ur right i cleaned it up a bit and got it down to 1 link error for this
if((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) {
//error
}
error LNK2001: unresolved external symbol _Direct3DCreate9@4
and my verts setup is
typedef struct
{
FLOAT x,y,z;
D3DCOLOR diffuse;
} sVertex;
#define VertexFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
if((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) {
//error
}
error LNK2001: unresolved external symbol _Direct3DCreate9@4
and my verts setup is
typedef struct
{
FLOAT x,y,z;
D3DCOLOR diffuse;
} sVertex;
#define VertexFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
That symbol is in d3d9.lib
Your book sounds pretty terrible, try working through the stuff at DirectXTutorial.com.
Your book sounds pretty terrible, try working through the stuff at DirectXTutorial.com.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement