Jump to content
Xtreme .Net Talk

Obvious

Members
  • Posts

    2
  • Joined

  • Last visited

Obvious's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I'm writing a small graphics class for direct3d 9 and have some OOP problems. CGraphics contains the d3d device and initialization/drawing code. It also contains CTextureManager as public. I figured there's nothing wrong with typing something like: Graphics.TextureManager.AddTexture(FilePath) Another option is to wrap the texture manager methods in the graphics class like: Sub CGraphics.AddTexture(FilePath) TextureManager.AddTexture(FilePath) End Sub Graphics.AddTexture(FilePath) Which way is best and why? Now my problem is the texture manager needs access to the d3d device in order to load textures. How should I set up my scope and structure in a professional way? I could get around this by making the Device a public property and typing: TextureManager.Device = Graphics.Device but that would be sloppy and I know there's a better way. If my whole approach isn't right, I'd be happy to be shown a better structure.
  2. I'm using VB.NET 2003 with D3D9 and having problems with drawing and vertex buffers. I'm creating a graphics class for my upcoming 2d tile-based game. I have a working version, and decided to rewrite it for more organization, but the new version doesn't work. The problem comes when I try and pass a vertex buffer as an argument for my draw function (I get an unknown error). My first version kept the vertexbuffer inside the graphics class in scope with the D3D device, but my rewrite is using a separate class which passes it's vertexbuffer to the graphics class. Besides that, there's no difference. Here's my code: 'separate class Private Texture1 As Texture Private VertexBuffer1 As VertexBuffer Public Sub New() Graphics.PlotQuad(VertexBuffer1, New Drawing.Rectangle(50, 50, 64, 128)) End Sub Public Sub Draw() Graphics.DrawQuad(VertexBuffer1) End Sub 'Graphics class Public Sub PlotQuad(ByVal Buffer As VertexBuffer, ByVal rDest As Drawing.Rectangle) Buffer = New VertexBuffer(GetType(CustomVertex.TransformedTextured), 4, D3DDev, 0, CustomVertex.TransformedTextured.Format, Pool.Default) Dim v As CustomVertex.TransformedTextured() = CType(Buffer.Lock(0, 0), CustomVertex.TransformedTextured()) v(0) = New CustomVertex.TransformedTextured(rDest.Left, rDest.Top, 0, 1, 0, 0) v(1) = New CustomVertex.TransformedTextured(rDest.Right, rDest.Top, 0, 1, 1, 0) v(2) = New CustomVertex.TransformedTextured(rDest.Left, rDest.Bottom, 0, 1, 0, 1) v(3) = New CustomVertex.TransformedTextured(rDest.Right, rDest.Bottom, 0, 1, 1, 1) Buffer.Unlock() End Sub Public Sub DrawQuad(ByVal Buffer As VertexBuffer) D3DDev.SetStreamSource(0, Buffer, 0) D3DDev.VertexFormat = CustomVertex.TransformedTextured.Format D3DDev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2) End Sub I get the error on the D3DDev.DrawPrimitives line, if anyone needs the source code to understand better let me know.
×
×
  • Create New...