Jump to content
  • Advertisement
Sign in to follow this  
thestien

Dreaded book examples not working

This topic is 2269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys and Girls i have just started programming again and recently brought a few books from amazon.

only one of the books came with a CD which i have managed to get the code from that to work.

i have spent the last few days trying to get one of the example codes in the book " The Zen of Direct3d Game Programming" which i do not have the CD for.

it is a directx8 book and i have managed to get it to compile and link (which took a few days) but now when i debug it the program crashes my whole pc.

i changed it slightly from fullscreen to windowed mode and now at least i can exit the debugger when it gets to the crash point. it says
"Unhandled exception at 0x5ddbe870 in fullscreendemos.exe: 0xC0000005: Access violation writing location 0x5dd6149c."
EDIT: sorry i forgot to tell you where it happens
g_pDevice->CreateImageSurface( 128, 128, D3DFMT_X8R8G8B8, &g_pD3DBitmapSurf);

int j = sizeof(&g_pD3DBitmapSurf);


D3DXLoadSurfaceFromFile( g_pD3DBitmapSurf, NULL, NULL, "ZenD3D.bmp", NULL,
D3DX_FILTER_NONE, 0, NULL);
srand( GetTickCount());
return S_OK;


its quite a long code so i appologise for my non commenting and bad coding i was trying to get the example working as fast as possible as i dont have the CD to get the source from.
#include <Windows.h>
#include <d3d8.h>
#include <d3dx8.h>
#include <D3D9Types.h>
#pragma once
#define RENDER_GDI 2
#define RENDER_D3D 1
#define RENDER_BOTH 0


HWND hWnd ;
MSG msg;
WNDCLASSEX wc;
static char strAppName[] = "Zong!! - the game of the great ones";
HDC g_phGDIBitmapDC;
HDC g_hDC = NULL;
HWND g_hWndMain ;
LPDIRECT3D8 g_pD3D = 0;
LPDIRECT3DDEVICE8 g_pDevice = 0;
int g_DeviceHeight;
int g_DeviceWidth;
D3DPRESENT_PARAMETERS g_SavedPresParams;
int g_RenderMode =0;
LPDIRECT3DSURFACE8 g_pBackSurface =0;
LPDIRECT3DSURFACE8 g_pD3DBitmapSurf =0;
HBITMAP g_hGDIBitmap =0;
HDC g_hGDIBitmapDC =0;


int GameInit();
int GameLoop();
int GameShutdown();
long CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
void SetError( char* string);
int InitDirect3DDevice( HWND hWndTarget, int Width, int Height, BOOL bWindowed,
D3DFORMAT FullScreenFormat, LPDIRECT3D8 pD3D,
LPDIRECT3DDEVICE8* ppDevice);
int Render();
HRESULT CopyDCToSurface( LPDIRECT3DSURFACE8 pDestSurf, POINT* pDestPoint,
HDC hDCSource, HBITMAP hDibSection, RECT* pSrcRect, COLORREF ColorKey);

void DeleteD3DCompatibleDC( HDC hDC, HBITMAP hDibSection);
HDC CreateCompatibleDC( int Width, int Height, HBITMAP* phDibSection);

////////////////////////////////////////////////////////////////////////////////////////////////
void SetError( char* string)
{
OutputDebugString(string);
OutputDebugString("\n");
}

HRESULT CopyDCToSurface( LPDIRECT3DSURFACE8 pDestSurf, POINT* pDestPoint,
HDC hDCSource, HBITMAP hDibSection, RECT* pSrcRect, COLORREF ColorKey)
{
HRESULT r;
RECT SourceRect;
POINT DestPoint;
DIBSECTION DibSection;
D3DLOCKED_RECT LockedRect;
GetObject( hDibSection, sizeof( DIBSECTION), &DibSection);
int SrcTotalWidth = DibSection.dsBm.bmWidth;
int SrcTotalHeight = DibSection.dsBm.bmHeight;

if(!pSrcRect)
SetRect( &SourceRect, 0, 0, SrcTotalWidth, SrcTotalHeight);

else
SourceRect = *(pSrcRect);

if( !pDestPoint)
DestPoint.x = DestPoint.y = 0;
else
DestPoint = *(pDestPoint);

if( !pDestSurf)
return E_FAIL;
if( !hDCSource)
return E_FAIL;

r = pDestSurf->LockRect(&LockedRect, 0, 0);

if( FAILED( r))
{
SetError( "unable to lock the surface for GDI transfer");
return E_FAIL;
}

DWORD* pSrcData = (DWORD*)(DibSection.dsBm.bmBits);
DWORD* pDestData = (DWORD*)(LockedRect.pBits);
int Pitch32 = LockedRect.Pitch / 4;

int SrcHeight = SourceRect.bottom - SourceRect.top;
int SrcWidth = SourceRect.right - SourceRect.left;
DWORD SrcOffset = SourceRect.top * SrcTotalWidth + SourceRect.left;
DWORD DestOffset = DestPoint.y * Pitch32 + DestPoint.x;

if( ColorKey == -1)
{
for( int y =0; y < SrcHeight; y++)
{
memcpy( (void*)&(pDestData[ DestOffset]),(void*)&(pSrcData[SrcOffset]), SrcWidth*4);
DestOffset += Pitch32;
SrcOffset +=SrcTotalWidth;
}
}
else
{
for( int y =0; y< SrcHeight; y++)
{
for( int x =0; x< SrcWidth; x++)
{

if( pSrcData[ SrcOffset] != ColorKey)
pDestData[DestOffset] = pSrcData[ SrcOffset];
SrcOffset++;
DestOffset++;
}
}
}

pDestSurf->UnlockRect();

return S_OK;
}


void DeleteD3DCompatibleDC( HDC hDC, HBITMAP hDibSection)
{
DeleteObject( hDibSection);
DeleteDC( hDC);
}

HDC CreateD3DCompatibleDC( int Width, int Height, HBITMAP* phDibSection)
{
HDC hDC = CreateCompatibleDC(0);
void* pDibSection = 0;

BITMAPINFO bi;
ZeroMemory( &bi, sizeof( BITMAPINFO));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = Width;
bi.bmiHeader.biHeight = Height;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 32;
bi.bmiHeader.biCompression = BI_RGB;

HBITMAP hDibSection = CreateDIBSection( hDC, &bi, DIB_RGB_COLORS, &pDibSection, NULL, NULL);

SelectObject( hDC, hDibSection);
*phDibSection = hDibSection;

return hDC;
}

long CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{

switch( uMessage)
{
case WM_CREATE:
{

return 0;
}
case WM_KEYDOWN:
{
switch( wParam)
{
case VK_SPACE:
{
g_RenderMode++;
if( g_RenderMode > 2)
g_RenderMode =0;
break;
}

default:
break;
}
}


case WM_PAINT:
{
ValidateRect( hWnd, NULL);

return 0;
}

case WM_DESTROY:
{
PostQuitMessage( 0);
return 0;
}

default:
{
return DefWindowProc( hWnd, uMessage, wParam, lParam);
}
}
}

int InitDirect3DDevice( HWND hWndTarget, int Width, int Height, BOOL bWindowed,
D3DFORMAT FullScreenFormat, LPDIRECT3D8 pD3D,
LPDIRECT3DDEVICE8* ppDevice)
{
D3DPRESENT_PARAMETERS d3dpp;
D3DDISPLAYMODE d3ddm;
HRESULT r = 0;
if( *ppDevice)
(*ppDevice)->Release();

ZeroMemory( &d3dpp, sizeof( D3DPRESENT_PARAMETERS));
r = pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm);

if(FAILED( r))
{
SetError( " Could not get display adapter information" );
return E_FAIL;
}

d3dpp.BackBufferWidth = Width;
d3dpp.BackBufferHeight = Height;
d3dpp.BackBufferFormat = bWindowed ? d3ddm.Format : FullScreenFormat;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWndTarget;
d3dpp.Windowed = bWindowed;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.FullScreen_RefreshRateInHz = 0;
d3dpp.FullScreen_PresentationInterval = bWindowed ? 0 : D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
r = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWndTarget,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, ppDevice);

if( FAILED( r))
{
SetError( " Could not create the render device");
return E_FAIL;
}
g_DeviceHeight = Height;
g_DeviceWidth = Width;
g_SavedPresParams = d3dpp;
return S_OK;
}

int Render()
{
if(!g_pDevice)
{
SetError( "cannot render because there is no device");
return E_FAIL;
}

RECT D3DSrcRect = { 0, 0, 128, 128};
POINT D3DDestPoint = { rand() % (g_DeviceWidth - 128), rand() % (g_DeviceHeight - 128)};
POINT GDIDestPoint = { rand() % (g_DeviceWidth - 128), rand() % (g_DeviceHeight - 128)};

if( g_RenderMode == RENDER_GDI || g_RenderMode == RENDER_BOTH)
CopyDCToSurface( g_pBackSurface, &GDIDestPoint, g_hGDIBitmapDC, g_hGDIBitmap, 0, -1);

if( g_RenderMode == RENDER_D3D || g_RenderMode == RENDER_BOTH)
g_pDevice->CopyRects( g_pD3DBitmapSurf, &D3DSrcRect, 1, g_pBackSurface, &D3DDestPoint);

g_pDevice->Present( NULL, NULL, NULL, NULL);

return S_OK;

}

int GameInit()
{
HRESULT r = 0;
//D3DDISPLAYMODE d3ddm;
//D3DPRESENT_PARAMETERS d3dpp;

g_pD3D = Direct3DCreate8( D3D_SDK_VERSION);

if( g_pD3D == NULL)
{
SetError( " Could not create IDIRECT3D8 object");
return E_FAIL;
}

r = InitDirect3DDevice( g_hWndMain, 640, 480, TRUE, D3DFMT_X8R8G8B8, g_pD3D, &g_pDevice);

if( FAILED( r))
{
SetError( "Init of the device failed");
return E_FAIL;
}

g_pDevice->Clear( 0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0),10.f, 0);

g_hGDIBitmapDC = CreateD3DCompatibleDC(128, 128, &g_hGDIBitmap);
HDC hTempDC = CreateCompatibleDC(0);
HBITMAP hTempBitmap = (HBITMAP)LoadImage(0, "ZenGDI.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject( hTempDC, hTempBitmap);
BitBlt( g_hGDIBitmapDC, 0, 0, 128, 128, hTempDC, 0, 0, SRCCOPY);
DeleteObject( hTempBitmap);
DeleteDC( hTempDC);

r = g_pDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &g_pBackSurface);

if( FAILED( r))
{
SetError( "Couldnt get backbuffer");
return E_FAIL;
}

g_pDevice->CreateImageSurface( 128, 128, D3DFMT_X8R8G8B8, &g_pD3DBitmapSurf);

int j = sizeof(&g_pD3DBitmapSurf);


D3DXLoadSurfaceFromFile( g_pD3DBitmapSurf, NULL, NULL, "ZenD3D.bmp", NULL,
D3DX_FILTER_NONE, 0, NULL);
srand( GetTickCount());
return S_OK;
}


int GameLoop()
{
Render();
if(GetAsyncKeyState(VK_ESCAPE))
{
PostQuitMessage(0);
return S_OK;
}
}


this is Engine.h i did have it seperated into a .cpp file but it gave me errors which i will work out later.

here is the main code

#include <Windows.h>
#include <d3d8.h>
#include <d3dx8.h>
#include <D3D9Types.h>
#pragma once
#define RENDER_GDI 2
#define RENDER_D3D 1
#define RENDER_BOTH 0


HWND hWnd ;
MSG msg;
WNDCLASSEX wc;
static char strAppName[] = "Zong!! - the game of the great ones";
HDC g_phGDIBitmapDC;
HDC g_hDC = NULL;
HWND g_hWndMain ;
LPDIRECT3D8 g_pD3D = 0;
LPDIRECT3DDEVICE8 g_pDevice = 0;
int g_DeviceHeight;
int g_DeviceWidth;
D3DPRESENT_PARAMETERS g_SavedPresParams;
int g_RenderMode =0;
LPDIRECT3DSURFACE8 g_pBackSurface =0;
LPDIRECT3DSURFACE8 g_pD3DBitmapSurf =0;
HBITMAP g_hGDIBitmap =0;
HDC g_hGDIBitmapDC =0;


int GameInit();
int GameLoop();
int GameShutdown();
long CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
void SetError( char* string);
int InitDirect3DDevice( HWND hWndTarget, int Width, int Height, BOOL bWindowed,
D3DFORMAT FullScreenFormat, LPDIRECT3D8 pD3D,
LPDIRECT3DDEVICE8* ppDevice);
int Render();
HRESULT CopyDCToSurface( LPDIRECT3DSURFACE8 pDestSurf, POINT* pDestPoint,
HDC hDCSource, HBITMAP hDibSection, RECT* pSrcRect, COLORREF ColorKey);

void DeleteD3DCompatibleDC( HDC hDC, HBITMAP hDibSection);
HDC CreateCompatibleDC( int Width, int Height, HBITMAP* phDibSection);

////////////////////////////////////////////////////////////////////////////////////////////////
void SetError( char* string)
{
OutputDebugString(string);
OutputDebugString("\n");
}

HRESULT CopyDCToSurface( LPDIRECT3DSURFACE8 pDestSurf, POINT* pDestPoint,
HDC hDCSource, HBITMAP hDibSection, RECT* pSrcRect, COLORREF ColorKey)
{
HRESULT r;
RECT SourceRect;
POINT DestPoint;
DIBSECTION DibSection;
D3DLOCKED_RECT LockedRect;
GetObject( hDibSection, sizeof( DIBSECTION), &DibSection);
int SrcTotalWidth = DibSection.dsBm.bmWidth;
int SrcTotalHeight = DibSection.dsBm.bmHeight;

if(!pSrcRect)
SetRect( &SourceRect, 0, 0, SrcTotalWidth, SrcTotalHeight);

else
SourceRect = *(pSrcRect);

if( !pDestPoint)
DestPoint.x = DestPoint.y = 0;
else
DestPoint = *(pDestPoint);

if( !pDestSurf)
return E_FAIL;
if( !hDCSource)
return E_FAIL;

r = pDestSurf->LockRect(&LockedRect, 0, 0);

if( FAILED( r))
{
SetError( "unable to lock the surface for GDI transfer");
return E_FAIL;
}

DWORD* pSrcData = (DWORD*)(DibSection.dsBm.bmBits);
DWORD* pDestData = (DWORD*)(LockedRect.pBits);
int Pitch32 = LockedRect.Pitch / 4;

int SrcHeight = SourceRect.bottom - SourceRect.top;
int SrcWidth = SourceRect.right - SourceRect.left;
DWORD SrcOffset = SourceRect.top * SrcTotalWidth + SourceRect.left;
DWORD DestOffset = DestPoint.y * Pitch32 + DestPoint.x;

if( ColorKey == -1)
{
for( int y =0; y < SrcHeight; y++)
{
memcpy( (void*)&(pDestData[ DestOffset]),(void*)&(pSrcData[SrcOffset]), SrcWidth*4);
DestOffset += Pitch32;
SrcOffset +=SrcTotalWidth;
}
}
else
{
for( int y =0; y< SrcHeight; y++)
{
for( int x =0; x< SrcWidth; x++)
{

if( pSrcData[ SrcOffset] != ColorKey)
pDestData[DestOffset] = pSrcData[ SrcOffset];
SrcOffset++;
DestOffset++;
}
}
}

pDestSurf->UnlockRect();

return S_OK;
}


void DeleteD3DCompatibleDC( HDC hDC, HBITMAP hDibSection)
{
DeleteObject( hDibSection);
DeleteDC( hDC);
}

HDC CreateD3DCompatibleDC( int Width, int Height, HBITMAP* phDibSection)
{
HDC hDC = CreateCompatibleDC(0);
void* pDibSection = 0;

BITMAPINFO bi;
ZeroMemory( &bi, sizeof( BITMAPINFO));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = Width;
bi.bmiHeader.biHeight = Height;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 32;
bi.bmiHeader.biCompression = BI_RGB;

HBITMAP hDibSection = CreateDIBSection( hDC, &bi, DIB_RGB_COLORS, &pDibSection, NULL, NULL);

SelectObject( hDC, hDibSection);
*phDibSection = hDibSection;

return hDC;
}

long CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{

switch( uMessage)
{
case WM_CREATE:
{

return 0;
}
case WM_KEYDOWN:
{
switch( wParam)
{
case VK_SPACE:
{
g_RenderMode++;
if( g_RenderMode > 2)
g_RenderMode =0;
break;
}

default:
break;
}
}


case WM_PAINT:
{
ValidateRect( hWnd, NULL);

return 0;
}

case WM_DESTROY:
{
PostQuitMessage( 0);
return 0;
}

default:
{
return DefWindowProc( hWnd, uMessage, wParam, lParam);
}
}
}

int InitDirect3DDevice( HWND hWndTarget, int Width, int Height, BOOL bWindowed,
D3DFORMAT FullScreenFormat, LPDIRECT3D8 pD3D,
LPDIRECT3DDEVICE8* ppDevice)
{
D3DPRESENT_PARAMETERS d3dpp;
D3DDISPLAYMODE d3ddm;
HRESULT r = 0;
if( *ppDevice)
(*ppDevice)->Release();

ZeroMemory( &d3dpp, sizeof( D3DPRESENT_PARAMETERS));
r = pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm);

if(FAILED( r))
{
SetError( " Could not get display adapter information" );
return E_FAIL;
}

d3dpp.BackBufferWidth = Width;
d3dpp.BackBufferHeight = Height;
d3dpp.BackBufferFormat = bWindowed ? d3ddm.Format : FullScreenFormat;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWndTarget;
d3dpp.Windowed = bWindowed;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.FullScreen_RefreshRateInHz = 0;
d3dpp.FullScreen_PresentationInterval = bWindowed ? 0 : D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
r = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWndTarget,
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, ppDevice);

if( FAILED( r))
{
SetError( " Could not create the render device");
return E_FAIL;
}
g_DeviceHeight = Height;
g_DeviceWidth = Width;
g_SavedPresParams = d3dpp;
return S_OK;
}

int Render()
{
if(!g_pDevice)
{
SetError( "cannot render because there is no device");
return E_FAIL;
}

RECT D3DSrcRect = { 0, 0, 128, 128};
POINT D3DDestPoint = { rand() % (g_DeviceWidth - 128), rand() % (g_DeviceHeight - 128)};
POINT GDIDestPoint = { rand() % (g_DeviceWidth - 128), rand() % (g_DeviceHeight - 128)};

if( g_RenderMode == RENDER_GDI || g_RenderMode == RENDER_BOTH)
CopyDCToSurface( g_pBackSurface, &GDIDestPoint, g_hGDIBitmapDC, g_hGDIBitmap, 0, -1);

if( g_RenderMode == RENDER_D3D || g_RenderMode == RENDER_BOTH)
g_pDevice->CopyRects( g_pD3DBitmapSurf, &D3DSrcRect, 1, g_pBackSurface, &D3DDestPoint);

g_pDevice->Present( NULL, NULL, NULL, NULL);

return S_OK;

}

int GameInit()
{
HRESULT r = 0;
//D3DDISPLAYMODE d3ddm;
//D3DPRESENT_PARAMETERS d3dpp;

g_pD3D = Direct3DCreate8( D3D_SDK_VERSION);

if( g_pD3D == NULL)
{
SetError( " Could not create IDIRECT3D8 object");
return E_FAIL;
}

r = InitDirect3DDevice( g_hWndMain, 640, 480, TRUE, D3DFMT_X8R8G8B8, g_pD3D, &g_pDevice);

if( FAILED( r))
{
SetError( "Init of the device failed");
return E_FAIL;
}

g_pDevice->Clear( 0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0),10.f, 0);

g_hGDIBitmapDC = CreateD3DCompatibleDC(128, 128, &g_hGDIBitmap);
HDC hTempDC = CreateCompatibleDC(0);
HBITMAP hTempBitmap = (HBITMAP)LoadImage(0, "ZenGDI.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SelectObject( hTempDC, hTempBitmap);
BitBlt( g_hGDIBitmapDC, 0, 0, 128, 128, hTempDC, 0, 0, SRCCOPY);
DeleteObject( hTempBitmap);
DeleteDC( hTempDC);

r = g_pDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &g_pBackSurface);

if( FAILED( r))
{
SetError( "Couldnt get backbuffer");
return E_FAIL;
}

g_pDevice->CreateImageSurface( 128, 128, D3DFMT_X8R8G8B8, &g_pD3DBitmapSurf);

int j = sizeof(&g_pD3DBitmapSurf);


D3DXLoadSurfaceFromFile( g_pD3DBitmapSurf, NULL, NULL, "ZenD3D.bmp", NULL,
D3DX_FILTER_NONE, 0, NULL);
srand( GetTickCount());
return S_OK;
}


int GameLoop()
{
Render();
if(GetAsyncKeyState(VK_ESCAPE))
{
PostQuitMessage(0);
return S_OK;
}
}


the book isnt structured very well when it comes to copying the code out so i may have missed something?

you help will be very much appreciated smile.png

Share this post


Link to post
Share on other sites
Advertisement
You know... DX9 came out in 2002. Or about 10 years ago. There's no reason to use DX8 anymore. Not unless your target computer is still running Windows 95.

Share this post


Link to post
Share on other sites
hehehe im kind of cheap and got this book for a few £ i used to use SDL but now i want to use directx well really i want to do 3D stuff.

i guess i could use a newer version but to follow the examples in the book would be alot harder as i would have to convert alot of it and i dont really know how it works yet. do you think im flogging a dead horse? or will i be able to get these examples to work?

thanks for the fast reply anyways :)

Share this post


Link to post
Share on other sites
just a thought but if anybody has this book and CD could you possibly let me have a copy of the chaper source file and the bmps ect. that way i can make that work and see what is wrong with my code?

i have tried to get a copy of the cd but the website dont work so i guess i have no chance to order a new one from them?

thanks again guys


EDIT:Sorry Again i have now fixed this problem.

incase you was wondering what happened it was a simple fix the file was called "ZenD3D.bmp" in the code but in the folder it was named "ZenD3D" so adding the .bmp

well i say fixed it i mean it doesnt crash now but it still doesnt load the images. i will hopefully be able to fix this but any pointers would be appreciated :) Edited by thestien

Share this post


Link to post
Share on other sites

hehehe im kind of cheap and got this book for a few £ i used to use SDL but now i want to use directx well really i want to do 3D stuff.

i guess i could use a newer version but to follow the examples in the book would be alot harder as i would have to convert alot of it and i dont really know how it works yet. do you think im flogging a dead horse? or will i be able to get these examples to work?

thanks for the fast reply anyways smile.png

Yeah you're beating a dead horse. I used to do this myself and actually ported quite a bit of DX7/8 code to DX9 and even before Microsoft stripped out a lot of the necessary headers from the latest DirectX SDK it was a PITA. You'll have install and older supported compiler and DX SDK to even get started.
Besides everything has moved to the shader pipeline vs vertex which is a totally different way of doing things.

Share this post


Link to post
Share on other sites
i thought so :( well i guess ill have to work on it and try to convert them i mean i got the whole internet to learn dx9.

i have worked out what is happening
D3DXLoadSurfaceFromFile( g_pD3DBitmapSurf, NULL, NULL, "ZenD3D.bmp", NULL,
D3DX_FILTER_NONE, 0, NULL);


this isnt working. if i step over this function the program displays the image using the "ZenGDI.bmp"
if i dont then it tries to write to memory in places it shouldnt any ideas?

thanks again :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!