Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Drawing triangles

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    16

    Drawing triangles

    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. 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.

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Drawing triangles

    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.
    see http://www.opengl.org/sdk/docs/man/xhtml/glBegin.xml

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    16

    Re: Drawing triangles

    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.

  4. #4
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Drawing triangles

    As i know texture`s size in openGL must be 2^n
    Not true.
    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.

  5. #5
    Senior Member Regular Contributor remdul's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands
    Posts
    346

    Re: Drawing triangles

    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).

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    16

    Re: Drawing triangles

    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.

  7. #7
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Drawing triangles

    how can i cut triangles from the picture
    what does that mean?

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    16

    Re: Drawing triangles

    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.

  9. #9
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Drawing triangles

    whay don't you just rasterise a triangle and texture it with the 'picture'. GL will take care of the 'cut off texture'.

  10. #10
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    16

    Re: Drawing triangles

    Thank you for answer, if you could tell step by step and what exactly GL commands are necesary - it would be amazing.

Page 1 of 2 12 LastLast

Similar Threads

  1. Drawing 2 triangles using transformations
    By miimoo in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-04-2018, 07:13 AM
  2. glDrawArrays is not drawing triangles, why?
    By colagl in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-28-2016, 06:53 AM
  3. Drawing edges of triangles
    By honestguvnor in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-13-2015, 02:42 PM
  4. need help in drawing rectangles nd triangles
    By Need_Help in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 04-20-2011, 09:10 AM
  5. optimisating triangles drawing
    By ybenaabud in forum OpenGL: General
    Replies: 2
    Last Post: 03-17-2004, 09:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean