# Vertexbuffers, intervallum

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all! See this "code-draft" Device.CreateVertexBuffer(4*sizeof(MyVertexFormat), 0, blablabla, D3DPOOL_MANAGED, MYRECTANGLE); ALPHARECT.Lock (0, 0, PO, 0); p[0].x:= -0.3; p[0].y:= -0.3; p[0].z:= 0; p[0].diffuse:= D3DCOLOR_ARGB(Alpha, R,G,B); p[1].x:= -0.3; p[1].y:= 0.3; p[1].z:= 0; p[1].diffuse:= D3DCOLOR_ARGB(Alpha, R,G,B); p[2].x:= 0.3; p[2].y:= -0.3; p[2].z:= 0; p[2].diffuse:= D3DCOLOR_ARGB(Alpha, R,G,B); p[3].x:= 0.3; p[3].y:= 0.3; p[3].z:= 0; p[3].diffuse:= D3DCOLOR_ARGB(Alpha, R,G,B); Move (p, PO^, SizeOf(MyVertexFormat)*4); MYRECTANGLE.Unlock; MYRECTANGLE DRAWING ETC ETC BLAHBLAH It defines an beautiful coloured rectangle. Although the X,Y or texture coordinates can be -1 beetwen 1. Hm... I want to draw an simple 2D texture on the screen at 100,120. What do I set up, to increase the interval? (for example, if I draw at 100,120, 200,210, it really be at 100,120, 200,210);

##### Share on other sites
Try changing your vertex format to XYZRHW, and changing your vertex structure to x,y,z,w, or D3DXVECTOR4. Set w=1 in each vertex.

What this does is say "I'm giving you pre-transformed coordinates". No world, view, or projection matrices are needed. No lighting will be attempted.

Another alternative is to use an orthographic projection matrix. Specify the width and height that match your display. In this case 0,0 will be the center, which isn't quite what you want. You should be able to add a translation into the projection matrix to account for that (changing matrix.41, and matrix.42).

Sorry I'm not posting code, but I'm in a rush.

##### Share on other sites
Hi there BigBeginner,
How are you doing?

[The problem]
How do I draw a Triangle at transformed coordinates

[The solution]
Your Vertex format defines what coordinates you are going to use for each vertex.

D3DFVF_XYZRHW:
Vertex format includes the position of a transformed vertex. This flag cannot be used with the D3DFVF_XYZ or D3DFVF_NORMAL flags.

Example:
// Transformed vertex for light-map-based lighting with shared rhw.
dwFVF = ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );

This means if you give the coordinates to your vertices now that they will be placed at the coordinates in screen space.

I hope this helps, Keep cool.

PS: Thanks Namethatnobodyelsetook, I see you beat me to it :)

##### Share on other sites
Yes, you two helped me :) thanx

1. 1
Rutin
73
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633426
• Total Posts
3011816
• ### Who's Online (See full list)

There are no registered users currently online

×