Jump to content
  • Advertisement
Sign in to follow this  

Which way to fill grid renderer with right data?

This topic is 2095 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
//in filler class

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!