PDA

View Full Version : How to fill with color a line strip



suzanne14
04-26-2009, 08:30 AM
Hi, I am drawing some figure using GL_LINE_STRIP, & I wonder how could I fill it with color. I couldn't use GL_POLYGON instead of line strip because I also have some translation & rotation there (I am doing 1 translation & rotation 4 times to obtain my figure).... & I don't want to calculate all those coordinates manually. Please give me some idea how could I do that :(

Rosario Leonardi
04-26-2009, 11:23 AM
Try glLineWidth (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/linewidth.html)

dletozeun
04-26-2009, 11:52 AM
Try glLineWidth


What is the relation between the answer and the question?



I am drawing some figure using GL_LINE_STRIP, & I wonder how could I fill it with color.


What do you mean exactly by fill a line with color? You can call glColor at each line vertex to change its color.

suzanne14
04-26-2009, 12:08 PM
Sorry, I actually ment the GL_LINE_LOOP not GL_LINE_STRIP, & I wanted to fill with color the figure I get, which is a concave polygon.

Rosario Leonardi
04-26-2009, 02:32 PM
Ah.. you want to fill the polygon, not the line. :D
You can use glu tasselator but it's archaic.
http://glprogramming.com/red/chapter11.html

Otherwise you have to decompose the polygon in triangle and use GL_TRIANGLE to draw it.

There are some algorithm in the web:
http://cgm.cs.mcgill.ca/~godfried/teaching/cg-projects/97/Ian/cutting_ears.html

http://valis.cs.uiuc.edu/~sariel/research/CG/applets/convex_decomp/Default.html

@dletozeun:
Cause fill a line don't make any sense to me I thought that she need a way to make the line more "visible".

dletozeun
04-26-2009, 02:44 PM
Cause fill a line don't make any sense to me I thought that she need a way to make the line more "visible".


Ah, I get it! :)



I couldn't use GL_POLYGON instead of line strip because I also have some translation & rotation there (I am doing 1 translation & rotation 4 times to obtain my figure).


I can't understand this sentence, drawing lines or a polygon it is the same problem, the second just fill the shape content. Could you elaborate a bit more?

suzanne14
04-26-2009, 04:38 PM
I didn't use GL_POLYGON which would have solved the color problem because I read I can't call glTranslate & glRotate between glBegin(...) and glEnd() :) .

Well, at last I how ever calculated all the coordinates manually & called glBegin(GL_TRIANGLE_FAN), but didn't use tessellation but instead chose decomposing it in triangles, as you said, & that finally worked :) !!!
So thanks a lot !!!!!!!!