Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Best method for drawing things

Name: Anonymous 2009-05-26 19:44

List method: Graphic items are separate, and contain data structures containing information on rendering, i.e.:
struct render_item {
    int x, y;
    image *data;
    void (*draw_function) (struct render_item*);
    bool use_data_or_function;
};

A separate thread is running that goes through a list of render_items added with draw_this (item);, rendering them one by one. Useful especially for games and things that have to draw a lot of different objects.

Tree method: Graphic items are arranged in a hierarchy, with one master containing all of the others. Useful for GUIs and things that have nested objects. Not particularly useful if you can't get it to work properly.

Thoughts?

Name: Anonymous 2009-05-26 19:55

I am confus
What's the question?

Name: Anonymous 2009-05-26 20:03

>>1
well, are you writing a game or thing that has to draw a lot of different objects?

Name: Anonymous 2009-05-26 20:05

Just wanted some actual programming discussion, really.
Plus, I'm trying to do things the tree way and am failing miserably, I've done it the list way before and it worked fine, but it's a shitload of hassle to redesign the whole project and I don't see any advantages over the way I'm trying to do it, apart from it won't not work inexplicably.
Also, are there any other good ways anyone's done it?

Name: Anonymous 2009-05-26 21:19

actual programming discussion
You my friend, have come to the wrong place.

Name: Anonymous 2009-05-26 21:41

That's what I do with OpenGL. It's useful to also have a unique id and a pick function in the structure so you can do selection and stuff.

Name: Anonymous 2009-05-27 6:46

>>4
you should write a lightweight enterprise abstraction to these two methods so that your app can easily switch between them

Name: Anonymous 2009-05-27 7:38

>>7
lightweight enterprise abstraction

IHBT

Name: Anonymous 2009-05-27 7:56

I've seen someone implement the tree method(which you describe) in a C# gaming framework a few years ago. It worked pretty well the way it was designed ( it was OOP, so you had your virtual render methods which rendered child objects automatically and so on ). UI programming like this is one of those few cases where (this type of) object-oriented programming can be quite useful.

Name: Anonymous 2009-05-27 9:20

>>1
Bad, bad, bad.

Batch everything together as much as possible.

Name: Anonymous 2009-05-27 10:43

>>1
Your tree method is also called a scene graph, and is an important part of most modern 3d engines. Use it whenever you need something to move relative to something else that moves. You don't need it for a pure sprite-based game.

Proper GUI layout engines are bitches to write, if you need one, use the horrible built-in one in whatever library you fancy.

Your bool is redundant, BTW, just set draw_function to NULL.

Name: Anonymous 2013-09-01 15:28


Cognitive scientist George Lakoff considers the concept of infinity in mathematics and the sciences as a metaphor. This view is based on the basic metaphor of infinity (BMI), defined as the ever-increasing sequence <1,2,3,...>.

Don't change these.
Name: Email:
Entire Thread Thread List