View Full Version : about vetext

zydgyy

11-22-2011, 07:45 PM

Hi,

If i want to draw a pyramid,there are four trianles,if i use four vetices between glBegin(GL_TRANGLES) and glEnd() to draw it,that's ok,however,i read about,we should use 12 (4 faces * 3)to draw it,why???

Lefteris

11-22-2011, 08:52 PM

A pyramid has 6 triangles assuming you only draw with triangles. Four vertices between glBegin() and glEnd() can only draw 1 quad. One vertex is not 1 triangle. Vertex means a 3-dimensional point. So one triangle is 3 vertices (the plural of vertex). And 6 triangles is 18 vertices.

Why don't you google for some beginner's openGL tutorials to get started with openGL? They can guide you through all the process of learning.

And whoever told you to draw a pyramid with 4 triangles probably meant one without a base. And yes in that case it would be 12 vertices because it would be 4 triangles (*) 3 vertices = 12 vertices.

zydgyy

11-22-2011, 09:24 PM

I mean triangular pyramid,isnt it 4 faces,3 sides and 1 base,4 faces * 3 veteices=12 verteices?then use glBegin(GL_TRIANLGES) glEnd(),one vertex as top,and 3 vertex as base,just 4 veteices,you see?

Lefteris

11-22-2011, 09:33 PM

Oh I see. Yes if you meant triangular pyramid then it is so but you should have stated that in your original post.

From the way you write it seems that you really are totally unfamiliar with how openGL works. Please google for some nice beginner openGL tutorials and try to read on to understand how it works.

Some good ones for the fixed functionality are located here:

http://nehe.gamedev.net/ (even though it seems to be down right now)

But just to make sure you understand your problem I am going to explain it to you. You said you have 4 vertices. That is true. But you have 4 different triangles each one composed of 3 vertices. OpenGL does not care if they are duplicated or not. You will still have to send then ALL through glBegin()/End.

To rectify this you use something called Buffer Objects where you send the vertices in one object and in another one the indices of the formed triangles that are using them. But I think this is too advanced for you at this particular moment.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.