Public Group

# [directx9] Shapes creating

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

## Recommended Posts

Hello, i am programming a simple network 2d game and i would like to ask. How ci i make more complex objects. For example star or whatever i want. For testing purpouses i currently use simple quad object, but its time to give it some form.

So. How can i make these kind of objects? I read,that texturing the base objects can be the way. But how can i create more non simple shapes using vertexes please? When i create quad for example, i see that it has 4 vertexes, but when i add fifth, i cant predict, what the shape will be like. Can you please give me any advice?

##### Share on other sites
Get a pen and paper. Draw the shape you want. Decompose it into triangles. Work out the offsets from the shape centre to each vertex of each triangle. You've got your shape in local space. Add its centre position to each vertex (or use a transform matrix or whatever) when you render it.

It really isn't more complex than that. In Direct3D (don't know what API you are using) even a quad is composed of two triangles. I vaguely remember OpenGL having some kind of built-in quad support but there is really no difference between constructing a quad from two triangles and constructing a star from 'n' triangles.

##### Share on other sites

I vaguely remember OpenGL having some kind of built-in quad support but there is really no difference between constructing a quad from two triangles and constructing a star from 'n' triangles.

OpenGL Supports the GL_QUADS primitive, but that will basically just get turned into 2 Triangles as soon as you pass it to the driver. AFAIK Graphics cards know one thing, how to draw Triangles.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013599
×