Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Directx8 - drawing a square - messing up things [modified]

Directx8 - drawing a square - messing up things [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    seq
    wrote on last edited by
    #1

    Hello, I wrote a code on directx9 to draw and fill a square using ID3DXLine which looked like that: (I should add that this code is inject/hooked into a game). ID3DXLine *pLine; void fillrgba(int x, int y, int w, int h, int r, int g, int b, int a) { D3DXVECTOR2 vLine[2]; pLine->SetWidth( w ); pLine->SetAntialias( false ); pLine->SetGLLines( true ); vLine[0].x = x + w/2; vLine[0].y = y; vLine[1].x = x + w/2; vLine[1].y = y + h; pLine->Begin( ); pLine->Draw( vLine, 2, D3DCOLOR_RGBA( r, g, b, a ) ); pLine->End( ); } But now I have to make it work under DirectX8! And there exist no ID3DXLine, so I tried something like this float PanelWidth = 150.0f; float PanelHeight = 200.0f; pDevice->CreateVertexBuffer(4 * sizeof(PANELVERTEX), D3DUSAGE_WRITEONLY, D3DFVF_PANELVERTEX, D3DPOOL_MANAGED, &g_pVertices); PANELVERTEX* pVertices = NULL; g_pVertices->Lock(0, 4 * sizeof(PANELVERTEX), (BYTE**)&pVertices, 0); //Set all the colors to white pVertices[0].color = pVertices[1].color = pVertices[2].color = pVertices[3].color = 0xffffffff; //Set positions and texture coordinates pVertices[0].x = pVertices[3].x = -PanelWidth / 2.0f; pVertices[1].x = pVertices[2].x = PanelWidth / 2.0f; pVertices[0].y = pVertices[1].y = PanelHeight / 2.0f; pVertices[2].y = pVertices[3].y = -PanelHeight / 2.0f; pVertices[0].z = pVertices[1].z = pVertices[2].z = pVertices[3].z = 1.0f; pVertices[1].u = pVertices[2].u = 1.0f; pVertices[0].u = pVertices[3].u = 0.0f; pVertices[0].v = pVertices[1].v = 0.0f; pVertices[2].v = pVertices[3].v = 1.0f; g_pVertices->Unlock(); pDevice->SetVertexShader(D3DFVF_PANELVERTEX); pDevice->SetStreamSource(0, g_pVertices, sizeof(PANELVERTEX)); pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); When I use the above code it messess the game up, is there any similar thing like ID3DXLine in DX8 ? I would rather avoid using vertexes, just make it as easy as possible without the BeginScene()/Endscene() and so on, just like ID3DXLine did. Regards, Pawel -- modified at 4:42 Tuesday 29th August, 2006

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups