View Full Version : Drawing triangles
11-17-2011, 05:14 AM
Hello dear OpenGL community. As this post sections says im just a beginner in OpenGL. I have some experience in flash and try to redesign my flash project for openGL. The place when i stuck is flash function drawtriangles that is described here (http://www.flashandmath.com/advanced/p10triangles/method.html). So i do not understand if it is possible to create function in openGL that can do same thing as described flash function. Thank You for any help.
11-17-2011, 10:40 AM
Forget Flash and it's hybrid approach to rasterisation.
You need to learn a new approach because openGL offers far greater control and speed options that you could imagine.
The simplest and oldest (and no longer supported in Core OpenGL profiles) is to use immediate mode rendering. This uses glbegin and glEnd to encapsulate vertex data sent with glVertex commands.
There are loads of tutorials on the new for this kind of thing - and it's still an option for Compatibility profiles on all new and existing hardware.
Then there's vertex arrays. Here you can pack together a bunches of triangles and draw them all in one go.
Then there's buffer objects, where the vertex data is uploaded to the GFX card for even faster execution.
11-19-2011, 11:07 AM
Thank you for an abstract answer. It will be good if i could know can i draw textured triangles in openGL. At example : i have an image, so i will divide image in triangles. After this i would like to draw these triangles. As i know texture`s size in openGL must be 2^n, but if i wanna draw triangles - it will not always be 2^n.
11-20-2011, 07:23 AM
As i know texture`s size in openGL must be 2^n
Non-power of 2 texture support has been standard core functionality since version 2.0
Even before then, there were extensions which allowed NPOT textures. Additionally, there are such things as rectangular textures which may be of some use too.
If you are running OpenGL ES of some flavour on a mobile phone, then perhaps they might have some restrictions on NPOT, but certainly not on Desktop OpenGL.
but if i wanna draw triangles - it will not always be 2^n.
The sizes of the triangles is not the restriction. It is only the dimensions of the texture image which has to be 2^n.
11-21-2011, 03:48 AM
Depending on how serious you are about retaining Flash as a framework for your project, you might want to check out "WebGL", it doesn't have the legacy issues mentioned by BionicBytes (although WebGL is still not entirely mature yet).
11-21-2011, 04:07 AM
Thank you for answers, last i would like to now - is how can i cut triangles from the picture and put them in GL_TRIANGLES as a texture. After understanding it, i could continue my work. Thank you.
11-21-2011, 10:52 AM
how can i cut triangles from the picture
what does that mean?
11-21-2011, 12:42 PM
I mean i have a picture, that has size 440 x 560 (exactly my situation). At example i have an algorhitm that knows 3 points of this picture, that must organize triangle and cut off texture exactly from this triangle to my 3 opengl points.
11-21-2011, 01:59 PM
whay don't you just rasterise a triangle and texture it with the 'picture'. GL will take care of the 'cut off texture'.
11-22-2011, 05:06 AM
Thank you for answer, if you could tell step by step and what exactly GL commands are necesary - it would be amazing.
11-22-2011, 05:52 PM
Spend a lot of time in searching, but still no results - so you are my only hope :)
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.