• Advertisement
Sign in to follow this  

a beginner ideia of optimization

This topic is 3460 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

python like pseudocode, my real code is in C++
class WorldClass:
    newobjs = 0
    def render():
        if newobjs > somenumber:
            # sort renderlist using RenderObject.texid
            newobjs = 0
        for obj in renderlist: # everything on that list is RenderObject
            obj.render()

class RenderObject:
    def __init__(texture, owner)
        self.texid = texture.id # a plain integer
        owner.newojbs += 1

it will work? ps: what is the action of glBindTexture() if i try to bind a texture that is already binded?

Share this post


Link to post
Share on other sites
Advertisement
Yes, sorting by (texture-, material-, shader-, ...)IDs is a quite good way to optimize the rendering process for opaque meshes.

However, for transparent objects you'll need to sort back-to-front.

Share this post


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

  • Advertisement