Jump to content

  • Log In with Google      Sign In   
  • Create Account

Which way to fill grid renderer with right data?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Waterlimon   Crossbones+   -  Reputation: 2635

Like
0Likes
Like

Posted 30 December 2012 - 09:41 AM

I have 2 classes, a grid renderer that needs lets say texture data for each tile in a grid to render it, and a class that owns such a grid renderer and needs to provide that data.

Which way is the [absolutely best in all contexts] - way to go about passing the data:
1. Grid renderer creates an empty grid with verticies
*I need to either initialize the vertices to an acceptable state in case data is not provided for each vertex by the filler class, or somehow check that data for all vertices has been provided before sending to GPU
eg.
//in filler class
GridRenderer.TellWhatTileLooksLike(x,y,texture);

2.Grid renderer takes in a lambda which it calls for each vertex/cell/whatever
*All data is guaranteed to be filled, and as such i dont need to initialize them to 0/some other acceptable state, nor do i need to check that all data has been filled.
eg.
//In filler class
GridRenderer<[](x,y){return GetTileTexture(x,y);}> renderer;

3.Unknown way


If the answer is 2, what would be the answer if we DIDNT have lambdas?


Additional question:
How do i tell the filler class what parameters/return value the lambda needs? Is there syntax to specify that in the template thing?
EDIT: Should i use std::function here? EDIT2: yep std::function seems to work. Imagine all of this additional question and these edits have that line over them (what was it called?), indicating you should ignore this last question, as i dont want to use full editor because it eats all the spacing and this non-full editor doesnt have much text formatting features...

Edited by Waterlimon, 30 December 2012 - 10:03 AM.

o3o


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS