Need a bit of help finding a bug

Started by
10 comments, last by link102 13 years, 4 months ago
Sorry about the bad title, it's not very descriptive.

This program is supposed to load a bitmap and output it on the screen. However, the program compiles fine, but when it runs, it just shows a black screen, then exits with no errors.
I've traced the bug to "initDirect3D(hWnd, iWith, iHeight)" (in main.cpp). That's where the program ends.

What I'd like you to help me with is;
A: What did I do wrong? Why isn't this working.
B: Is there anything else I should change? Do you notice any pitfalls I might have stepped in or do you see any programming conventions that don't make sense?

If you need to know more about this project's setup just ask and I'll post some more details a.s.a.p

main.cpp
#include <windows.h>#include <tchar.h>#include <d3d9.h>#include <d3dx9.h>#include "direct3D.h"HINSTANCE hInst;HWND hWnd;int iWidth = 1280;int iHeight = 960;bool InitWindow(HINSTANCE hInstance, int iWidth, int iHeight);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){	if(!InitWindow(hInstance, iWidth, iHeight)){		return false;	}	if(!initDirect3D(hWnd, iWidth, iHeight)){		return false;	}	MSG msg = {0};	while(msg.message != WM_QUIT){		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){			TranslateMessage(&msg);			DispatchMessage(&msg);		} else {			render();		}	}	cleanUp();	return (int) msg.wParam;}bool InitWindow(HINSTANCE hInstance, int iWidth, int iHeight){	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			= 0;	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);	wcex.lpszMenuName	= NULL;	wcex.lpszClassName	= TEXT("DirectX 1");	wcex.hIconSm		= 0;	RegisterClassEx(&wcex);	RECT rect = {0, 0, iWidth, iHeight};	AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);	hWnd = CreateWindow(TEXT("DirectX 1"),	//class name						TEXT("DirectX 1"),		//window title						WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,						CW_USEDEFAULT,			//initial x position						CW_USEDEFAULT,			//initial y postion						iWidth,					//width						iHeight,				//height						NULL,					//parent handle						NULL,					//menu handle						hInstance,				//instance handle						NULL);	if(!hWnd){		return false;	}	ShowWindow(hWnd, SW_SHOW);	UpdateWindow(hWnd);	return true;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){	switch(message){		case WM_KEYDOWN:			switch(wParam){				case VK_ESCAPE:					PostQuitMessage(0);				break;			}		break;		case WM_DESTROY:			PostQuitMessage(0);		break;	}	return DefWindowProc(hWnd, message, wParam, lParam);}


direct3D.h
LPDIRECT3D9			pD3D;		//the Direct3d objectLPDIRECT3DDEVICE9	pd3dDevice;	//the Direct3D deviceIDirect3DSurface9*	surface;bool initDirect3D(HWND hWnd, int iWidth, int iHeight){	pD3D = NULL;	pd3dDevice = NULL;	HRESULT hResult;	if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}	D3DPRESENT_PARAMETERS d3dpp;	ZeroMemory(&d3dpp, sizeof(d3dpp));	d3dpp.Windowed =			FALSE;	d3dpp.SwapEffect =			D3DSWAPEFFECT_DISCARD;	d3dpp.BackBufferFormat =	D3DFMT_X8R8G8B8;	d3dpp.BackBufferCount =		1;	d3dpp.BackBufferWidth =		iWidth;	d3dpp.BackBufferHeight =	iHeight;	d3dpp.hDeviceWindow =		hWnd;	if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT,								 D3DDEVTYPE_REF,								 hWnd,								 D3DCREATE_SOFTWARE_VERTEXPROCESSING,								 &d3dpp,								 &pd3dDevice))){		return false;	}	hResult = pd3dDevice->CreateOffscreenPlainSurface(iWidth, iHeight, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL);	if(FAILED(hResult)){		return NULL;	}	hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, L"test.bmp", NULL, D3DX_DEFAULT, 0, NULL);	if(FAILED(hResult)){		return NULL;	}	return true;}void render(void){	IDirect3DSurface9* backbuffer = NULL;	if(pd3dDevice == NULL){		return;	}	pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(62, 62, 68), 1.0f, 0);	pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);	pd3dDevice->StretchRect(surface, NULL, backbuffer, NULL, D3DTEXF_NONE);	pd3dDevice->Present(NULL, NULL, NULL, NULL);}void cleanUp(void){	if(pd3dDevice != NULL){		pd3dDevice->Release();	}	if(pD3D != NULL){		pD3D->Release();	}}


thank you.

[Edited by - link102 on December 9, 2010 4:12:13 PM]
Advertisement
The first thing to do is to move implementation code out of a header. In general, headers shouldn't be used for code. Keep just the function declarations in the header. You should probably move the code itself to a .cpp file.

Once you've done that, use the Debug Runtime to see what it tells you about errors, etc.

In addition, do yourself a huge favor by outputting some sort of information when an error is encountered - e.g., a MessageBox(). As it is, you just return false if something goes wrong.

Also, take a look at the DXGetErrorDescription function. That will help you interpret HRESULT error codes.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This is just really being nitpicky but I noticed

if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}


The backward comparison makes it a little confusing to read for me, but thats just a preference thing.

I tend to use

if( (pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL ){		return false;	}
Quote:Original post by yewbie
This is just really being nitpicky but I noticed

if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}


The backward comparison makes it a little confusing to read for me, but thats just a preference thing.

I tend to use

if( (pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL ){		return false;	}


"Backward comparison" is a technique used by some programmers to prevent accidental bugs:

if(variable = NULL) //compiles, but is a bugif(NULL = variable) //does not compile
first of all thank you for your replies :D
I've merged the codes back into 1 file again. Not quite sure yet what the differences between implementation code and function declaration are.

Does this backward comparison thing work with other data types?

Here's the code so far. It compiles, but has a D3DERR_INVALIDCALL > one of D3DXLoadSurfaceFromFile's parameters is not valid? What does that mean?
#include <windows.h>#include <tchar.h>#include <d3d9.h>#include <d3dx9.h>#include <dxerr.h>HINSTANCE hInst;HWND hWnd;LPDIRECT3D9			pD3D;		//the Direct3d objectLPDIRECT3DDEVICE9	pd3dDevice;	//the Direct3D deviceIDirect3DSurface9*	surface;int iWidth = 1280;int iHeight = 960;bool InitWindow(HINSTANCE hInstance, int iWidth, int iHeight);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);void notify(HRESULT hResult){	MessageBox(hWnd,DXGetErrorDescription(hResult),DXGetErrorString(hResult),MB_OK | MB_ICONWARNING);}bool initDirect3D(HWND hWnd, int iWidth, int iHeight){	pD3D = NULL;	pd3dDevice = NULL;	HRESULT hResult;	if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}	D3DPRESENT_PARAMETERS d3dpp;	ZeroMemory(&d3dpp, sizeof(d3dpp));	d3dpp.Windowed =			FALSE;	d3dpp.SwapEffect =			D3DSWAPEFFECT_DISCARD;	d3dpp.BackBufferFormat =	D3DFMT_X8R8G8B8;	d3dpp.BackBufferCount =		1;	d3dpp.BackBufferWidth =		iWidth;	d3dpp.BackBufferHeight =	iHeight;	d3dpp.hDeviceWindow =		hWnd;	if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT,								 D3DDEVTYPE_REF,								 hWnd,								 D3DCREATE_SOFTWARE_VERTEXPROCESSING,								 &d3dpp,								 &pd3dDevice))){		notify(hResult);		return false;	}	hResult = pd3dDevice->CreateOffscreenPlainSurface(iWidth, iHeight, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL);	if(FAILED(hResult)){		notify(hResult);		return false;	}	hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, L"test.bmp", NULL, D3DX_DEFAULT, 0, NULL);	if(FAILED(hResult)){		notify(hResult);		return false;	}	return true;}void render(void){	IDirect3DSurface9* backbuffer = NULL;	if(pd3dDevice == NULL){		return;	}	pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(62, 62, 68), 1.0f, 0);	pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);	pd3dDevice->StretchRect(surface, NULL, backbuffer, NULL, D3DTEXF_NONE);	pd3dDevice->Present(NULL, NULL, NULL, NULL);}void cleanUp(void){	if(pd3dDevice != NULL){		pd3dDevice->Release();	}	if(pD3D != NULL){		pD3D->Release();	}}int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){	if(!InitWindow(hInstance, iWidth, iHeight)){		return false;	}	if(!initDirect3D(hWnd, iWidth, iHeight)){		return false;	}	MSG msg = {0};	while(msg.message != WM_QUIT){		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){			TranslateMessage(&msg);			DispatchMessage(&msg);		} else {			render();		}	}	cleanUp();	return (int) msg.wParam;}bool InitWindow(HINSTANCE hInstance, int iWidth, int iHeight){	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			= 0;	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);	wcex.lpszMenuName	= NULL;	wcex.lpszClassName	= TEXT("DirectX 1");	wcex.hIconSm		= 0;	RegisterClassEx(&wcex);	RECT rect = {0, 0, iWidth, iHeight};	AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);	hWnd = CreateWindow(TEXT("DirectX 1"),	//class name						TEXT("DirectX 1"),		//window title						WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,						CW_USEDEFAULT,			//initial x position						CW_USEDEFAULT,			//initial y postion						iWidth,					//width						iHeight,				//height						NULL,					//parent handle						NULL,					//menu handle						hInstance,				//instance handle						NULL);	if(!hWnd){		return false;	}	ShowWindow(hWnd, SW_SHOW);	UpdateWindow(hWnd);	return true;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){	switch(message){		case WM_KEYDOWN:			switch(wParam){				case VK_ESCAPE:					PostQuitMessage(0);				break;			}		break;		case WM_DESTROY:			PostQuitMessage(0);		break;	}	return DefWindowProc(hWnd, message, wParam, lParam);}


If it's any help here's the debug log: (note I've edited it, watch the "{}")
'Directx 1.exe': Loaded '{my visual studio filepath}\Projects\Directx 1\Debug\Directx 1.exe', Symbols loaded.'Directx 1.exe': Loaded 'D:\WINDOWS\system32\ntdll.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\kernel32.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\d3d9.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\d3d8thk.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\gdi32.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\user32.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\msvcrt.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\advapi32.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\rpcrt4.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\secur32.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\version.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\winmm.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\D3dx9d_42.dll''Directx 1.exe': Loaded 'D:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll', Symbols loaded.'Directx 1.exe': Loaded 'D:\WINDOWS\system32\imm32.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\lpk.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\usp10.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\uxtheme.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\MSCTF.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\MSCTFIME.IME''Directx 1.exe': Loaded 'D:\WINDOWS\system32\ole32.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\d3d9d.dll''Directx 1.exe': Loaded 'D:\WINDOWS\system32\d3dx9d_33.dll'D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO'Directx 1.exe': Loaded 'D:\WINDOWS\system32\d3dref9.dll'Direct3D9: (INFO) :======================= Reference SWVP device selectedDirect3D9: (INFO) :Using P4 PSGPD3DX: Source surface data (pvSrcData or cbSrcData) is invalid'Directx 1.exe': Loaded 'D:\WINDOWS\system32\oleaut32.dll'The thread 'Win32 Thread' (0x108) has exited with code 0 (0x0).repeat this about 200 times {Direct3D9: (ERROR) :    [0] : Address 00BEE4CBDirect3D9: (ERROR) :    [1] : Address 00BEE59BDirect3D9: (ERROR) :    [2] : Address 00BEE440Direct3D9: (ERROR) :    [3] : Address 00BE2DB4Direct3D9: (ERROR) :    [4] : Address 4FD3AF2EDirect3D9: (ERROR) :    [5] : Address 004240B0Direct3D9: (ERROR) :    [6] : Address 00411D0EDirect3D9: (ERROR) :    [7] : Address 0042BE9BDirect3D9: (ERROR) :    [8] : Address 0042BBFFDirect3D9: (ERROR) :    [9] : Address 7C7E7077Direct3D9: (ERROR) :    [10] : Address 00000000Direct3D9: (ERROR) :    [11] : Address 00000000Direct3D9: (ERROR) :    [12] : Address 00000000Direct3D9: (ERROR) :    [13] : Address 00000000Direct3D9: (ERROR) :    [14] : Address 00000000Direct3D9: (ERROR) :    [15] : Address 00000000}The program '[2476] Directx 1.exe: Native' has exited with code 0 (0x0).
L"test.bmp"


The hell is this?
They hated on Jeezus, so you think I give a f***?!
Quote:Original post by Fl4sh
*** Source Snippet Removed ***

The hell is this?
See here (towards the bottom).
Quote:Original post by xytor
Quote:Original post by yewbie
This is just really being nitpicky but I noticed

if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}


The backward comparison makes it a little confusing to read for me, but thats just a preference thing.

I tend to use

if( (pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL ){		return false;	}


"Backward comparison" is a technique used by some programmers to prevent accidental bugs:

*** Source Snippet Removed ***


Ha.. ha.. ha.. Almost all beginners will experience the '==' and '=' thing. Wish I got this tip sooner :-)

But since I will do scripting here and there, I'm sure it will be usefull.
Quote:Original post by Fl4sh
*** Source Snippet Removed ***

The hell is this?


L"test.bmp" = _T("test.bmp")
the line
hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, L"test.bmp", NULL, D3DX_DEFAULT, 0, NULL);


expects a unicode string

Quote:Original post by FableFox
Ha.. ha.. ha.. Almost all beginners will experience the '==' and '=' thing. Wish I got this tip sooner :-)

But since I will do scripting here and there, I'm sure it will be usefull.


I've been there, from my experience with php.


btw: I've tested to see if it could find the bmp file. It gave me a D3DERR_INVALIDDATA after I renamed it. Meaning the problem does not lie within the name or location of the bmp.
I've stil got the D3DERR_INVALIDCALL, just with I knew which parameter is wrong.

edit:

SOLVED!

Thank you very much for you help guys :D, here's the fix:
I was trying to see if the test.bmp file had the right format (D3DFMT_X8R8G8B8) turns out it's to big for the surface I was trying to load it on.
Final code: (d3d9.lib d3dx9d.lib dxerr.lib included in the editor)
#include <windows.h>#include <tchar.h>#include <d3d9.h>#include <d3dx9.h>#include <dxerr.h>HINSTANCE hInst;HWND hWnd;LPDIRECT3D9			pD3D;		//the Direct3d objectLPDIRECT3DDEVICE9	pd3dDevice;	//the Direct3D deviceIDirect3DSurface9   *surface;int iWidth = 1280;int iHeight = 960;bool InitWindow(HINSTANCE hInstance, int iWidth, int iHeight);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);void notify(HRESULT hResult){	MessageBox(hWnd,DXGetErrorDescription(hResult),DXGetErrorString(hResult),MB_OK | MB_ICONWARNING);}////////////////////INITDIRECT3D//bool initDirect3D(HWND hWnd, int iWidth, int iHeight){	pD3D = NULL;	pd3dDevice = NULL;	HRESULT hResult;	if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}	D3DPRESENT_PARAMETERS d3dpp;	ZeroMemory(&d3dpp, sizeof(d3dpp));	d3dpp.Windowed =			FALSE;	d3dpp.SwapEffect =			D3DSWAPEFFECT_DISCARD;	d3dpp.BackBufferFormat =	D3DFMT_X8R8G8B8;	d3dpp.BackBufferCount =		1;	d3dpp.BackBufferWidth =		iWidth;	d3dpp.BackBufferHeight =	iHeight;	d3dpp.hDeviceWindow =		hWnd;	hResult = pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF,								 hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,								 &d3dpp, &pd3dDevice);	if(FAILED(hResult)){		notify(hResult);		return false;	}	hResult = pd3dDevice->CreateOffscreenPlainSurface(iWidth, iHeight, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL);	if(FAILED(hResult)){		notify(hResult);		return false;	}	hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, L"test.bmp", NULL, D3DX_DEFAULT, 0, NULL);	if(FAILED(hResult)){		notify(hResult);		return false;	}	return true;}//////////////RENDER//void render(void){	IDirect3DSurface9* backbuffer = NULL;	if(pd3dDevice == NULL){		return;	}	pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(62, 62, 68), 1.0f, 0);	pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);	pd3dDevice->StretchRect(surface, NULL, backbuffer, NULL, D3DTEXF_NONE);	pd3dDevice->Present(NULL, NULL, NULL, NULL);}void cleanUp(void){	if(pd3dDevice != NULL){		pd3dDevice->Release();	}	if(pD3D != NULL){		pD3D->Release();	}}int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){	if(!InitWindow(hInstance, iWidth, iHeight)){		return false;	}	if(!initDirect3D(hWnd, iWidth, iHeight)){		return false;	}	MSG msg = {0};	while(msg.message != WM_QUIT){		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){			TranslateMessage(&msg);			DispatchMessage(&msg);		} else {			render();		}	}	cleanUp();	return (int) msg.wParam;}bool InitWindow(HINSTANCE hInstance, int iWidth, int iHeight){	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			= 0;	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);	wcex.lpszMenuName	= NULL;	wcex.lpszClassName	= TEXT("DirectX 1");	wcex.hIconSm		= 0;	RegisterClassEx(&wcex);	RECT rect = {0, 0, iWidth, iHeight};	AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);	hWnd = CreateWindow(TEXT("DirectX 1"),	//class name						TEXT("DirectX 1"),		//window title						WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,						CW_USEDEFAULT,			//initial x position						CW_USEDEFAULT,			//initial y postion						iWidth,					//width						iHeight,				//height						NULL,					//parent handle						NULL,					//menu handle						hInstance,				//instance handle						NULL);	if(!hWnd){		return false;	}	ShowWindow(hWnd, SW_SHOW);	UpdateWindow(hWnd);	return true;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){	switch(message){		case WM_KEYDOWN:			switch(wParam){				case VK_ESCAPE:					PostQuitMessage(0);				break;			}		break;		case WM_DESTROY:			PostQuitMessage(0);		break;	}	return DefWindowProc(hWnd, message, wParam, lParam);}


I stil have a couple of questions?
- What's the difference between IDirect3DSurface9 *surface; and IDirect3DSurface9* surface;?
- Is the cleanUp() in the correct location (at the end of WinMain) and is it complete enough?
- Are there any things you would change about this code that would make it run better or easier to read? Like putting some functions in a separate file or changing some of the code to a object oriented style.
- Are there any ways of improving the error reporting? (the notify(); function)

[Edited by - link102 on December 10, 2010 6:01:28 AM]
IDirect3DSurface9 *surface;
IDirect3DSurface9* surface;

They function the same.

This topic is closed to new replies.

Advertisement