Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Nov 22, 2017 9:32 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: OpenGL Sphere - Can you texture this?
PostPosted: Thu Mar 18, 2010 1:11 pm 
Offline
User avatar

Joined: Sun Mar 23, 2008 3:30 pm
Posts: 163
So I'm trying to put together a 3D model of earth for a larger, otherwise non-3D project that happens to require a globe, with no experience in OpenGL or any 3D of any kind. I've gotten as far as drawing a really nice sphere using a combination of tutorials and samples online, however, now I'm totally stumped by texturing.

Feel free to download the OpenGL sphere I already have working in Real Studio. There is also a texture and my attempt at getting the texture onto the sphere. There are clearly bits of the image being placed on the sphere but I haven't even the foggiest idea how what is displaying is being generated. There is something wrong with my math, but I've gotten so far and yet am totally lost right at the end. :( If anybody can return with the solution to the problem it would be much appreciated. I'd really hate to literally learn OpenGL to an expertise level just for this one thing.

And, if you just want a shaded and colored sphere, comment out or delete the texturing bits and feel free to use it in your own projects.

http://www.danpalka.net/openglearth.zip

Thanks in advance.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL Sphere - Can you texture this?
PostPosted: Thu Mar 18, 2010 7:00 pm 
Offline

Joined: Fri Sep 30, 2005 6:55 pm
Posts: 1522
Drawing a textured sphere is intro-level stuff, actually -- it only seems harder than it should be because you're supposed to use a 3D modeler to texture it! I was able to texture it in less than a minute in Cheetah3D:

- make a new Cheetah3D project, add a sphere, choose how much detail you want in the sphere, then double-click its icon in the list to convert it into polygons.
- add a new material to the project, change the texture color to white, then load your image as the texture for that material.
- drag the material onto the sphere's icon in the list. Cheetah3D will automatically apply a "best guess" for the texture coordinates, which in this case is exactly what you wanted.

From there you'd export the model as an OBJ file and write an OBJ loader in your app, which is also simple.

EDIT: If you have access to GLUT, there's a glutSolidSphere function that renders a sphere with auto-generated texture coordinates. There are also many tutorials online that show you how to render a globe from start to finish.

_________________
Those who can, do. Those who can't, make excuses.


Last edited by imikedaman on Thu Mar 18, 2010 7:12 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL Sphere - Can you texture this?
PostPosted: Thu Mar 18, 2010 7:11 pm 
Offline
User avatar

Joined: Sun Mar 23, 2008 3:30 pm
Posts: 163
imikedaman wrote:
From there you'd export the model as an OBJ file and write an OBJ loader in your app, which is also simple.


Is there any stand-alone example of one that I can base this off of? At this point I only semi-have-any-idea what you're talking about.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL Sphere - Can you texture this?
PostPosted: Thu Mar 18, 2010 7:13 pm 
Offline

Joined: Fri Sep 30, 2005 6:55 pm
Posts: 1522
http://www.google.com/search?client=saf ... 8&oe=UTF-8

I don't know if there's a REALbasic version. Maybe it's already built-in? It's a very simple format.

_________________
Those who can, do. Those who can't, make excuses.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL Sphere - Can you texture this?
PostPosted: Thu Mar 18, 2010 10:10 pm 
Offline

Joined: Mon Feb 05, 2007 11:35 am
Posts: 98
Looking at your code (I have RB2007 so I cannot compile your stuff), It seems your texture coordinates are off. Based on what I see, I would expect the one of the texture coordinates (I think it's the Y in this case) to update only in the outer loop.

My own GL classes has an OBJ file loader. It's written specifically for GL itself and might be more complicated than you need, but you're free to take from it.
http://www.jcquan.com/REALbasic/GL-v0_31.zip

The GL classes also has a GLUT library included, so there you go.

_________________
Regards,

Jeff Quan
jeff@jcquan.com
http://www.jcquan.com/JQportfolio
My RBGL replacement classes: http://www.jcquan.com/REALbasic


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL Sphere - Can you texture this?
PostPosted: Wed Mar 24, 2010 11:43 am 
Offline
User avatar

Joined: Sun Mar 23, 2008 3:30 pm
Posts: 163
Thanks guys, I've decided to stick with what I know for this project - SuperSpriteSurface - and I'll work around it accordingly.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group