Advertisement Jump to content
Sign in to follow this  

Vertexbuffers, intervallum

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

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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 this post

Link to post
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.

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

// Transformed vertex for light-map-based lighting with shared rhw.

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 this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!