How do i set different textures...
How do i set different textures...
How do i set different textures...
How do i set different textures...
How do i set different textures...
How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures...
How do i set different textures... How do i set different textures...
How do i set different textures...
Go Back  Xtreme Visual Basic Talk > > > > How do i set different textures...


Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2008, 02:19 PM
korni_fox korni_fox is offline
Newcomer
 
Join Date: Feb 2008
Posts: 4
Default How do i set different textures...


I'm doing RPG game editor and I cant figure out how to set different textures for different quads. For example I want one quad with a texture of grass and the other quad with a texture of water.

That's my code:
(It will show the quad with the grass but it won't show the quad with the water)
Code:
 
        TextureObj(0) = TextureLoader.FromFile(GraphicsDevice, Application.StartupPath & "\grass.png")
        TextureObj(1) = TextureLoader.FromFile(GraphicsDevice, Application.StartupPath & "\water.png")

'first quad
  GraphicsDevice.SetTexture(0, TextureObj(0))
                    GraphicsDevice.SetStreamSource(0, m_VertexBuffer(0, 0), 0)

                    ' Tell the device the format of the vertices.
                    GraphicsDevice.VertexFormat = CustomVertex.PositionNormalTextured.Format

                    ' Draw the primitives in the data stream.
                    GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2)

'second quad
  GraphicsDevice.SetTexture(0, TextureObj(1))
                    GraphicsDevice.SetStreamSource(0, m_VertexBuffer(1, 0), 0)

                    ' Tell the device the format of the vertices.
                    GraphicsDevice.VertexFormat = CustomVertex.PositionNormalTextured.Format

                    ' Draw the primitives in the data stream.
                    GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2)
Any help will be appreciated
korni_fox
Reply With Quote
  #2  
Old 02-24-2008, 04:47 AM
Leade's Avatar
Leade Leade is offline
Junior Contributor
 
Join Date: Jul 2005
Location: Wherever i fall over
Posts: 222
Default

Quote:
Originally Posted by korni_fox View Post
Code:
 
'first quad
  GraphicsDevice.SetTexture(0, TextureObj(0))
                    GraphicsDevice.SetStreamSource(0, m_VertexBuffer(0, 0), 0)

                    ' Tell the device the format of the vertices.
                    GraphicsDevice.VertexFormat = CustomVertex.PositionNormalTextured.Format

                    ' Draw the primitives in the data stream.
                    GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2)

'second quad
  GraphicsDevice.SetTexture(0, TextureObj(1))
                    GraphicsDevice.SetStreamSource(0, m_VertexBuffer(1, 0), 0)

                    ' Tell the device the format of the vertices.
                    GraphicsDevice.VertexFormat = CustomVertex.PositionNormalTextured.Format

                    ' Draw the primitives in the data stream.
                    GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2)
your problem is on the second quad (obviously ) you told the system to draw a triangle strip but gave it the wrong start vertex.

Either that or you do not have enough vertecies in your buffer.

try using this code for the second quad (the bold is the only line i changed):

Code:
'second quad
  GraphicsDevice.SetTexture(0, TextureObj(1))
                    GraphicsDevice.SetStreamSource(0, m_VertexBuffer(4, 0), 0)

                    ' Tell the device the format of the vertices.
                    GraphicsDevice.VertexFormat = CustomVertex.PositionNormalTextured.Format

                    ' Draw the primitives in the data stream.
                    GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0,
Notice the 4 on your vertex buffer, i take it you are using 4 vertecies per quad, i guess the first quad uses vertecies 0 to 3, so the second will use 4 to 7, and so in steps of 4.
__________________
Fact: The best ideas come when your smashed of your face. So drink beer and be merry!!!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How do i set different textures...
How do i set different textures...
How do i set different textures... How do i set different textures...
How do i set different textures...
How do i set different textures...
How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures... How do i set different textures...
How do i set different textures...
How do i set different textures...
 
How do i set different textures...
How do i set different textures...
 
-->