WANTED: Urgent help with Direct3D
-
Hello, I urgently need help getting Direct3D working, or at least find out where I am going wrong, so please read on. I am willing to send the full source code of my app to anyone willing and capable of maybe solving the problem. I have managed to setup DirectDraw, Direct3D the Primary Surface with one BackBuffer and the Direct3DDevice in one function (where I also set the Direct3DDevice viewport). I can load an image and blt it to the backbuffer and flip it, no problem. However, if I try and draw a simple triangle with gouraud shading with the following code: HRESULT CDarkSoldier::Render() { if (SUCCEEDED(m_pD3DDevice->BeginScene())) { D3DTLVERTEX v[3]; v[0] = D3DTLVERTEX(D3DVECTOR(160,50,0), 1, D3DRGB(1,0,0), D3DRGB(0,0,0), 0, 0); v[1] = D3DTLVERTEX(D3DVECTOR(440,200,0), 1, D3DRGB(0,1,0), D3DRGB(0,0,0), 0, 0); v[2] = D3DTLVERTEX(D3DVECTOR(160,550,0), 1, D3DRGB(0,0,1), D3DRGB(0,0,0), 0, 0); m_m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DVT_TLVERTEX, (LPVOID)v, 3, NULL); return m_pD3DDevice->EndScene(); } return DDERR_INVALIDPARAMS; } I get nothing, just a blank screen. This code is executed whenever there is no windows message pending (i.e. when the system is idle - and it is I have tested it). I have tried flipping the primary surface after this code, but nothing. Also, I have tried using m_pD3Device->Clear() to clear to another colour without success. Why is this happening? Is there something I MUST do before the Direct3DDevice will work? I receive no errors during setup, or during the app at all, come to think about it. I create the Direct3DDevice using m_pD3D->CreateDevice(pGUID, BackBuffer, &m_pD3DDevice); I have DirectX8.1 runtime and DirectX7 SDK. I have tested DirectX7 and DirectX8 using the system diagnostic indicator, and both are fine. So there MUST be something. Please...just highlight some areas or pitfalls where I might be falling down on. I am desperate to draw a friggin triangle...it shouldn't be this difficult. P.S. Not sure if its linked, but immediately after window creation and d3d initialisation if I blt a surface to the back buffer and flip it, the image comes up. If I blt it to the primary surface, it never comes up no matter how many times I flip it (its blank). However, I can get this code to work provided it is located somewhere in the WindowProc message processing loop, but not before it enters...is that strange or what? Thanks to all who read and reply. Alan. "When I left you I was but the learner, now I am the master" - Darth Vader
-
Hello, I urgently need help getting Direct3D working, or at least find out where I am going wrong, so please read on. I am willing to send the full source code of my app to anyone willing and capable of maybe solving the problem. I have managed to setup DirectDraw, Direct3D the Primary Surface with one BackBuffer and the Direct3DDevice in one function (where I also set the Direct3DDevice viewport). I can load an image and blt it to the backbuffer and flip it, no problem. However, if I try and draw a simple triangle with gouraud shading with the following code: HRESULT CDarkSoldier::Render() { if (SUCCEEDED(m_pD3DDevice->BeginScene())) { D3DTLVERTEX v[3]; v[0] = D3DTLVERTEX(D3DVECTOR(160,50,0), 1, D3DRGB(1,0,0), D3DRGB(0,0,0), 0, 0); v[1] = D3DTLVERTEX(D3DVECTOR(440,200,0), 1, D3DRGB(0,1,0), D3DRGB(0,0,0), 0, 0); v[2] = D3DTLVERTEX(D3DVECTOR(160,550,0), 1, D3DRGB(0,0,1), D3DRGB(0,0,0), 0, 0); m_m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DVT_TLVERTEX, (LPVOID)v, 3, NULL); return m_pD3DDevice->EndScene(); } return DDERR_INVALIDPARAMS; } I get nothing, just a blank screen. This code is executed whenever there is no windows message pending (i.e. when the system is idle - and it is I have tested it). I have tried flipping the primary surface after this code, but nothing. Also, I have tried using m_pD3Device->Clear() to clear to another colour without success. Why is this happening? Is there something I MUST do before the Direct3DDevice will work? I receive no errors during setup, or during the app at all, come to think about it. I create the Direct3DDevice using m_pD3D->CreateDevice(pGUID, BackBuffer, &m_pD3DDevice); I have DirectX8.1 runtime and DirectX7 SDK. I have tested DirectX7 and DirectX8 using the system diagnostic indicator, and both are fine. So there MUST be something. Please...just highlight some areas or pitfalls where I might be falling down on. I am desperate to draw a friggin triangle...it shouldn't be this difficult. P.S. Not sure if its linked, but immediately after window creation and d3d initialisation if I blt a surface to the back buffer and flip it, the image comes up. If I blt it to the primary surface, it never comes up no matter how many times I flip it (its blank). However, I can get this code to work provided it is located somewhere in the WindowProc message processing loop, but not before it enters...is that strange or what? Thanks to all who read and reply. Alan. "When I left you I was but the learner, now I am the master" - Darth Vader
I wish I could swear at this point. I have AT LAST found the problem of ALL problems, and I managed to do it myself (where is the smiley for pat yourself on the back??). Do you want to know why my D3DDevice structure wasn't drawing a triangle on the screen? Well I'm gonna tell you anyway. You wil note my code in the previous message (above) where it says m_pD3DDevice->DrawPrimitive(...) ok? See the flag D3DVT_TLVERTEX? yeah? well change it to D3DFVF_TLVERTEX and the b*****d thing works! I have wasted 4 or 5 days on this crappy problem and if there is ever an excuse NOT to use Direct3D over OpenGL, that is it! That flag worked in v6, but not in v7, watch out for more nasty problems I run into on this very web site. "When I left you I was but the learner, now I am the master" - Darth Vader