Skip to main content
gamedev.net
🔒 Locked

growth rendering

Started by PetrakovichJ 4 replies 600+ views
Original Post
PetrakovichJ
PetrakovichJ
What is the general strategy for rendering growth? For example if I have a line rendered in the display function, how do I add more line on top of it while keeping the old line?
NineYearCycle
NineYearCycle
I think you need to rephrase you're question because I doubt there's a general/all-purpose answer to what you've asked for.

Are you saying that you start with one "line" and then later on you have another line which makes two lines? or do you mean scanlines? or lines from a bitmap?

If you're just drawing a line using GL_LINES then you can just draw as many of them as you want.

Andy
"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile" "Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."
Waterwalker
Waterwalker
Sounds like that approach to render a fraktal or a growing tree to me. It depends on how you want to render but if it is just lines keep a std::vector of points where you add two more points for each new line and then render this array as LINE_LIST using a graphics API of your choice.
------------------------------------I always enjoy being rated up by you ...
PetrakovichJ
PetrakovichJ
Actually fractals is exactly what I am doing. How would I go about using OpenGL to use this vector of points?
NineYearCycle
NineYearCycle
Quote:
Original post by PetrakovichJ
Actually fractals is exactly what I am doing. How would I go about using OpenGL to use this vector of points?


You could do it exactly as WaterWalker suggested in the post above yours. have you used OpenGL before? Just so we have an idea of your knowledge since what he's suggested is pretty basic.

Andy
"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile" "Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."
Waterwalker
Waterwalker
Just some pseudo-code how to do it. I assume you know enough OpenGL to setup and render something:

// declarations
struct Point3{   float x, y, z;};std::vector <Point3> points;// initializationspoints.reserve(num_lines * 2);for (uint i=0; i<num_lines; ++i){   points.push_back(lines.point_a);   points.push_back(lines.point_b);}// drawing (unoptimized, no VBO and stuff)glBegin (GL_LINE_LIST);for (uint i=0; i<num_lines; ++i){   glVertex3fv( & points[i*2].x );   glVertex3fv( & points[i*2+1].x );}glEnd


When you add lines just push the corresponding two points into the vector. You could also use LINE_STRIPS but that would require a sequence where each new line connects to the last point of the last line which is not true for fraktals.
------------------------------------I always enjoy being rated up by you ...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.