GameDev Marketplace

Women's i.make.games T-shirt

$20$15

Image of the Day Submit

IOTD | Top Screenshots

What does this mean, and how can I fix it?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

#1littletray26  Members

Posted 05 March 2013 - 11:37 PM

Hey GameDev

So I just attempted making a Breakout clone, but I did not get far at all when I got an error I've not dealt with before.

When I debug my completely blank window, I get this outputting:

First-chance exception at 0x74cdc41f in Breakout.exe: Microsoft C++ exception: long at memory location 0x003af9e0..

I stepped through the code, and it seems to be spawning from this line:

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

here's my full source so far, I don't understand what's happening as I'm doing everything as I normally do:


//Winmain cpp
#include <Windows.h>
#include <d3d9.h>
#include <d3dx9.h>

#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
#pragma comment (lib, "winmm.lib")

LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3dDevice;
LPD3DXSPRITE spriteMachine;

LPARAM CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void InitializeD3D(HWND hWnd);
void Pulse(DWORD delta);
void KillD3D();

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
HWND hWnd;
WNDCLASSEX wc;
DWORD delta = 0;
DWORD prevFrameTime = 0;
DWORD thisFrameTime = 0;

ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.lpszClassName = L"WINDOW";
wc.style = CS_HREDRAW | CS_VREDRAW;

RegisterClassEx(&wc);

hWnd = CreateWindowEx(
NULL, L"WINDOW", L"Breakout Clone",
WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU, 0, 0, 800, 600,
NULL, NULL, hInstance, NULL);

ShowWindow(hWnd, nShowCmd);

MSG msg = {0};
InitializeD3D(hWnd);

while (true)
{
thisFrameTime = timeGetTime();

if(prevFrameTime != 0)
delta = thisFrameTime - prevFrameTime;
else delta = 0;

prevFrameTime = thisFrameTime;

if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);

if (msg.message == WM_QUIT)
break;
}

Pulse(delta);
}

KillD3D();
return msg.wParam;
}

LPARAM CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
break;
}
}

return DefWindowProc(hWnd, msg, wParam, lParam);
}

void InitializeD3D(HWND hWnd)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dPP;

ZeroMemory(&d3dPP, sizeof(D3DPRESENT_PARAMETERS));
d3dPP.BackBufferWidth = 800;
d3dPP.BackBufferHeight = 600;
d3dPP.hDeviceWindow = hWnd;
d3dPP.Windowed = true;

d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dPP, &d3dDevice);
D3DXCreateSprite(d3dDevice, &spriteMachine);
}

void Pulse(DWORD delta)
{
d3dDevice->Clear(0, 0, D3DCLEAR_TARGET, 0x000000, 1, 0);
d3dDevice->BeginScene();
spriteMachine->Begin(D3DXSPRITE_ALPHABLEND);

spriteMachine->End();
d3dDevice->EndScene();
d3dDevice->Present(NULL, NULL, NULL, NULL);
}

void KillD3D()
{
spriteMachine->Release();
d3dDevice->Release();
d3d->Release();
}


The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky

#2Khatharr  Members

Posted 06 March 2013 - 12:00 AM

Switch D3D to the debug runtime (search the D3D documentation for 'debug'). You'll get more detailed error messages.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#3littletray26  Members

Posted 06 March 2013 - 07:00 AM

Switch D3D to the debug runtime (search the D3D documentation for 'debug'). You'll get more detailed error messages.

That seemed to eliminate the problem all together, so thanks

The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky

#4EWClay  Members

Posted 06 March 2013 - 07:19 AM

POPULAR

Switch D3D to the debug runtime (search the D3D documentation for 'debug'). You'll get more detailed error messages.

That seemed to eliminate the problem all together, so thanks

That's not the idea. It's supposed to help find the error, not allow you to ignore it.

Make sure "break on D3D error" is turned on.

#5NightCreature83  Members

Posted 06 March 2013 - 09:49 AM

And also turn up the message to one tick below informational, you will get flooded otherwise, any warning that comes out of those messages should be fixed in a release build.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max

#6littletray26  Members

Posted 06 March 2013 - 07:15 PM

Switch D3D to the debug runtime (search the D3D documentation for 'debug'). You'll get more detailed error messages.

That seemed to eliminate the problem all together, so thanks

That's not the idea. It's supposed to help find the error, not allow you to ignore it.

Make sure "break on D3D error" is turned on.

I've turned directx into debug mode, and the break on d3d error is also enabled, but now it runs like there is no error at all. Nothing comes out of the output that I see as unusual. If I had of remembered to turn it to debug mode in the first place, I never would have even seen this error. What should I do? How do I find/fix it?

And also turn up the message to one tick below informational, you will get flooded otherwise, any warning that comes out of those messages should be fixed in a release build.

Sorry I'm not sure what you mean

The majority of Internet Explorer users don't understand the concept of a browsing application, or that there are options.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.

Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.

I love the word Clicky

#7Khatharr  Members

Posted 06 March 2013 - 11:10 PM

Possibly it was a bad build. Switch it back from debug and see if it still works. You should develop in debug, though.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.