-
1 Attachment(s)
Access Violation error
Ok this time I'm using Borland C++ Builder and I got a small app to compile and link just fine but I get an access violation error when it is running. It happens when I call the DirectX function "IDirect3DDevice8::Clear" in my "Render()" function (See file below). Anyone know what's going wrong here?
-
Most likely you write to memory you don't own. I haven't looked at the code, but that's the most probable error.
-
This is an easy one =). Dont Render() when you get a WM_PAINT. Your problem is that when you call ShowWindow(), you havent initialized DX yet, and your Window Proc gets a WM_PAINT message, which calls Render(), and causes your error (Your D3D Device is invalid).
Never call Render() in this way. Instead, call it in a loop in your main program, each time you process messages. It should look something like this:
Code:
while(running)
{
if(PeekMessage(hWnd, &msg, 0, 0, PM_REMOVE))
{
TranslateMessage(...);
DispatchMessage(...);
}
Render();
}
Z.
-
Thanks a bunch! It works fine now :).