Jump to content
  • Advertisement
Sign in to follow this  
kiwidrifter

Error when trying to compile-Interger division by zero?

This topic is 3127 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

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
Advertisement
My guess would be that something is wrong with the declaration of CUSTOMFVF. Can we see that declaration?

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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!