Jump to content
  • Advertisement
Sign in to follow this  
rotalever

OpenGL Rendering of a Widget

This topic is 4131 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 the following abstract widget, just imagine a button or something else. widgetfd0.th.png The widget is one image. There are nine areas marked with the numbers. My first approach was to store the images as it is in one texture. I can draw it using nine quads (ok more precisely 18 triangles drawn with a triangle strip). You may ask why nine quads? Because the widget can be scaled both in horizontal and vertical direction. This works fine as long as the areas #2,4,5,6,8 are only drawn in stretched mode. But how can I draw them in repeated mode, i.e. the sub-images should not be stretched but repeated. I think this is not possible with standard OpenGL or another graphics programming library. I cannot use pixelshaders for it. One way would be to have nine textures. Repeating would be no problem then. But how is performance? I have to reassign the texture nine times to draw one widget... Another way would be to draw the repeated areas with many quads. e.g. #2 would not consist of one quad with a repeated texture but let's say with five quads all equally sized and with the same (texture-) content The last way I can imagine: Prerender each widget completely into a texture. This would require much more space but is the fastest. Which way is the best/fastest? Which one would you chose? Thanks in advance. rotalever

Share this post


Link to post
Share on other sites
Advertisement
You can have a look at these open source apps Guichan and The Mana World to see how they do it. It looks to me like they have a function that basically loops to draw the images that need to be repeated (by calculating the length that the window needs to be and how big the images are), then just draw the four corners over it.

You could also just have an area clipped so whatever you draw inside that area is limited to the size you give it, and just loop the image inside of that. But I'm not sure how to do this.

Share this post


Link to post
Share on other sites
Quote:
Original post by Stormtrooper
You could also just have an area clipped so whatever you draw inside that area is limited to the size you give it, and just loop the image inside of that. But I'm not sure how to do this.

The problem is the looping/repeating itself. Normally if I have an OpenGL texture I can loop it 5 times if I set the texture coordinates to 0.0f,5.0f. But this is not possible if I only want to loop some parts of an image.

But I thought about another approach: I think it is best to cache the windows in a big texture and only redraw updated regions of this texture. This will give a big performance boost and then it is no problem to draw the widgets in a slow way because it is only done once...

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!