View Single Post
 
Old 01-20-2010, 11:08 AM
Zosimas Zosimas is offline
Newcomer
 
Join Date: May 2007
Posts: 3
Smile [SOLVED] Direct3d: Render 2Dimage with a shader

Problem SOLVED!

I use quads and render them with an OrthoLH Projection.
Here is the code:
----------------------------------------------------------------------
Code:
'Declare vertices
Private vertices(5) As CustomVertex.PositionNormalTextured

'Set vertices
vertices(0).X = -Width
vertices(0).Y = -Height
vertices(0).Tu = 1
vertices(0).Tv = 0

vertices(1).X = Width
vertices(1).Y = Height
vertices(1).Tu = 0
vertices(1).Tv = 1

vertices(2).X = Width
vertices(2).Y = -Height
vertices(2).Tu = 0
vertices(2).Tv = 0

vertices(3).X = -Width
vertices(3).Y = -Height
vertices(3).Tu = 1
vertices(3).Tv = 0

vertices(4).X = -Width
vertices(4).Y = Height
vertices(4).Tu = 1
vertices(4).Tv = 1

vertices(5).X = Width
vertices(5).Y = Height
vertices(5).Tu = 0
vertices(5).Tv = 1

'Set World, View, Projection
device.Transform.World = Matrix.Identity * Matrix.Translation(0, 0, 0)
device.Transform.View = Matrix.Identity * Matrix.Translation(New Vector3(-1, -1, 0))
device.Transform.Projection = Matrix.OrthoLH(-Width * 2, -Height * 2, 0, 1)

'Render quads
Passes = blurEffect.Begin(FX.None)
For k = 0 To Passes - 1
blurEffect.BeginPass(k)
DEV.VertexFormat = CustomVertex.PositionNormalTextured.Format
DEV.DrawUserPrimitives(PrimitiveType.TriangleList, 2, vertices)
blurEffect.EndPass()
Next k
blurEffect.End()
----------------------------------------------------------------------

I really don't understand why width and height must be multiplied with 2
but this works perfect!

Last edited by Zosimas; 01-20-2010 at 11:13 AM. Reason: Solved
Reply With Quote