Jump to content
  • Advertisement
Sign in to follow this  
Codorke

OpenGL 3D Book Problems

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

Hi, I'm making a 3D Book in openGL. I created a class cPage that contains all information about 1 page. I also made a linked list so i have my book. But i have a question about the text on my pages. My pages do turn, so my text is needed to be converted in different textures for the different pages. Or is there an other possibility that makes it easier to display my text on my pages ? The final goal is to be able to import different XML-files that can be readed in my 3D Book. Every XML-file stands for one book. Please some advise (or example source code) to help me out. Thnks

Share this post


Link to post
Share on other sites
Advertisement
The only way I can really think of, is to do an off-screen render of your text to a texture, then apply that texture to the page. After each page is turned, the texture is removed from memory and the new one is rendered.

I don't think you could do the page turning action with actual bitmap fonts, but i may be wrong.

Share this post


Link to post
Share on other sites
Thanks for the reply.

Is there any other way to show the text on pages ? (without bitmap fonts)

I realy need this thing working because it's for my final project of my studies.
Any suggestion are welcome ...

Generating the textures outside my program is not possible, because i can't make of any possible text a texture, and it needs to possible to import any XML-file into the program so everyone using my progam can make his own personalised book.

Any suggestions ?

Share this post


Link to post
Share on other sites
Quote:
Original post by Codorke
Thanks for the reply.

Is there any other way to show the text on pages ? (without bitmap fonts)

I realy need this thing working because it's for my final project of my studies.
Any suggestion are welcome ...

Generating the textures outside my program is not possible, because i can't make of any possible text a texture, and it needs to possible to import any XML-file into the program so everyone using my progam can make his own personalised book.

Any suggestions ?


Render to texture would be the simplest approach. Render the page to the back buffer and use glCopyTexSubImage2D() to copy it into a texture, then texure the page mesh with it. You can use whatever method you want for getting the text onto the back buffer, texture fonts, bitmap fonts, stroke fonts, etc.

Since you do the render to texture at run time you can generate the textures dynamicly to account for whatever text is supplied, so you can read the book text in from xml or anything you want.

Assuming the page is flat (does not bend as it turns) you could also set up a transform matrix when drawing the text that accounts for the movement of the page. Then just render everything to the screen in one pass. If the page needs to bend however, then the required distortion of the text could not be created with a simple transform matrix. Personally I'd probably go with the render to texture method however.

Share this post


Link to post
Share on other sites
I guess you only need to render the contents of the page new page when you flip to the next page. Once rendered in a secondary texture you can map it onto the mesh as suggested by a previous poster.

The pro in this situation is that the heavy rendering portion (the construction of the page) is done just once on each page flip (not each frame) so the main process just maps the texture onto the book (really fast).

So, just go on and use OS fonts to build your image. In Win32 you may even render it with common GUI calls. Easy in DX but don't know how to do it in OGL.

Luck!
Guimo

Share this post


Link to post
Share on other sites
Thanks for the advise !

I will try your suggestions, and hopefully it works this way. (And indeed my pages bend). But i'll try it first on a flat page.

Once again, thanks a lot.

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!