Vertex buffer problems, I think?

This is a discussion on Vertex buffer problems, I think? within the Game Programming forums, part of the General Programming Boards category; I got my Direct3D window working. Now I am trying to draw a triangle, and it doesn't draw anything. I ...

  1. #1
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552

    Vertex buffer problems, I think?

    I got my Direct3D window working. Now I am trying to draw a triangle, and it doesn't draw anything. I checked all the code several times, and I can't see anything wrong with it. I included the source with a MSVC++ 6 workspace and project.
    Attached Files Attached Files

  2. #2
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    I wont help you until you change your name to freedom fry.





    hahahah, get it? Freedom fry? hahahaha.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  3. #3
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    LMAO...i sense a nickname coming on hahah

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    What's the problem? I'm running DX8 and when I ported it over to DX8.1 it wouldn't even create a window. You shouldn't pass

    D3DCREATE_HARDWARE_VERTEXPROCESSING

    You should let that be software vertex processing when you create the device. Not all video cards support that in hardware. Anyways, you should start checking more return values and then translate the HRESULT in a message. i just glanced through it and nothing really shot out at me but I'll look again tomorrow morning.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  5. #5
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    The problem is, the triangle never draws. The clear command is working properly, but the triangle never is drawn on the screen.

    edit: I've added error checking to every single DX function I made, and every time I call them, and I am not getting any errors whatsoever.
    Last edited by frenchfry164; 03-15-2003 at 10:43 AM.

  6. #6
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    This is really weird. I copied the exact code from FillVertexBuffer() into StartDirect3D() and it worked. But I need it to work from FillVertexBuffer().

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    After seeing your last post its clear what the problem is. In your function FillVertexBuffer you take a pointer to the vertices. The function is prototyped as follow:

    Code:
    HRESULT FillVertexBuffer( CUSTOM_VERTEX vertices[] );
    Whenever you so sizeof(vertices) in the code that will always return 4 because that is a pointer! You are receiving a pointer to an array in the function. You need to either pass in the size or find another way to do it.

  8. #8
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    sorry for reviving dead thread, but I was on vacation all week. Anywayz, I tried changing it to
    Code:
    	if(FAILED(VertexBuffer->Lock(0, sizeof(CUSTOM_VERTEX)*3,
    		(void**)&pVertices, 0)))
    	    return E_FAIL;
    and it still doesn't work!

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I thought your problem was it wouldn't work in the one function and I told you about the sizeof pointer issue. That didn't clear it up?

  10. #10
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    you were right. I forgot to change the sizeof() in the memcpy() too. I hate when I do stupid stuff like that, but I guess that is just learning

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple (?) problem rendering a vertex buffer
    By Dark_Phoenix in forum Game Programming
    Replies: 4
    Last Post: 08-11-2007, 08:32 PM
  2. DirectX8 FVFs
    By Epo in forum Game Programming
    Replies: 16
    Last Post: 10-10-2004, 11:11 AM
  3. Im having linking problems with turbo c++ ver 4.5
    By Marcos in forum C++ Programming
    Replies: 4
    Last Post: 05-17-2004, 05:57 PM
  4. Problems posting a message from the buffer
    By josh_d in forum Windows Programming
    Replies: 3
    Last Post: 03-31-2004, 08:39 AM
  5. DirectSound - multiple sounds
    By Magos in forum Game Programming
    Replies: 9
    Last Post: 03-03-2004, 04:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21