Sign in to follow this  
kiwidrifter

Error when trying to compile-Interger division by zero?

Recommended Posts

Hey, im using visual express c++ with directx sdk (feb 2010) and keep getting an error when trying to compile a rather simple program to draw a triangle on screen. im following a tutorial and have been sweet up until now, cant figure out whats wrong the peice of code im having issues with is: void init_graphics(void) { //create three vertices using the CUSTOMVERTEX struct built earlier CUSTOMVERTEX vertices[] = { { 320.0f, 50.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 520.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), }, { 120.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; //create the vertex and store the pointer into v_buffer, which is created globally d3ddev->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; //the void pointer v_buffer->Lock(0, 0, (void**)&pVoid, 0); //lock the vertex buffer memcpy(pVoid, vertices, sizeof(vertices)); //copy the vertices to the locked buffer v_buffer->Unlock(); //unlock the vertex buffer } and the error message i get is: First-chance exception at 0x70f1ef19 in Triangle.exe: 0xC0000094: Integer division by zero. Unhandled exception at 0x70f1ef19 in Triangle.exe: 0xC0000094: Integer division by zero. The program '[5952] Triangle.exe: Native' has exited with code -1073741676 (0xc0000094). and it points to the line NULL is on even thought the documentation states this should be set to NULL please help

Share this post


Link to post
Share on other sites
When you have problems with DirectX code, always start by switching to the debug runtime. Find Microsoft DirectX SDK in the start menu and select DirectX Control Panel under Utilities. Select the Debug runtime, set output level (I recommend second highest) and check Maximum Validation. Break on D3D9 Error can also be useful so you don't miss anything.

Now run your program as usual from Visual Studio and check the Output console. You should get a lot of useful information.

You can also define D3D_DEBUG_INFO (for example in the Preprocessor settings) in your debug build.

Share this post


Link to post
Share on other sites
thanks for that, very handy to know.

found the problem

it was in the declaration of CUSTOMFVF

my original was

#define CUSTOMFVF (D3DFVF_XVZRHW || D3DFVF_DIFFUSE)

duno why i had 2 OR operators but yea, took one out and worked fine

Share this post


Link to post
Share on other sites
Quote:
Original post by kiwidrifter
duno why i had 2 OR operators but yea
'||' is 1 operator, the logical OR operator. '|' is the bit-wise OR operator. If you had '| |' you would have two operators. Just clarifying your terminology, I'm sure you know the difference!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this