Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Texturing Only Part Of The Sphere

This thread is locked; no one can reply to it. rss feed Print
Texturing Only Part Of The Sphere
Scooter
Member #16,799
January 2018

Hi all:
I am trying to put 4 small textures, 90 degrees apart, on a sphere. I tried
to get pixels from the texture, convert to spherical coordinates and plot them
on the sphere. CodeBlocks was NOT happy and kicked it out with this error:
'free or corruption'. I thought this would have worked but didn't. I have
looked on the internet for a solution, but no go. I guess nobody has ever done
this sort of thing before. If someone could supply a small bit of code or a
direction on how to do this it would help me. I have posted some code above
to explain what I am trying to do. The textures are on the sphere but not
mapped to the sphere. Thanks for any help you can supply.
This was done on a linux machine.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Scooter, it's called sphere mapping. It's been done before, you just have to know what you're talking about.

I ran your example code, and it works fine, the marios are plastered on the outside of the sphere in a quad. What did you expect? They won't map to the sphere unless you use a shader.

jmasterx
Member #11,410
October 2009

it's called sphere mapping. It's been done before,

:o:o:o:o:o:o

Wait.... you mean to tell me people have made spheres with more than one texture ?????????

I thought Scooter was really on to something here with these multitextured spheres. Can't believe it's been done before :o

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Scooter
Member #16,799
January 2018

Edgar:
SHADERS! I hate to hear that. There has got to be a simple way to map these
to the sphere. If not, I better stick to texturing flat objects. I am too new
to opengl to fool with shaders at this time. Thanks for the info.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Scooter
Member #16,799
January 2018

Edgar:
Yeah I know! You just saved me from hours of frustration. Wished I had posted
this 2 weeks ago. From now on, I will stay away from curved surfaces.
Thanks again for helping me with the soccer ball. It looks neat!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

For a small example of what this problem entails, look up the Mercator Projection. It's the classic reverse of this problem, projecting a sphere onto a rectangle.

Since you have pentagons, you can paste your texture onto your pentagon, as long as you don't draw over the edge of the polygon, you're fine.

I should be able to adapt your soccer ball demo to use mario on a few of the pentagons in a little while.

{"name":"612336","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/c\/fc347f54e755d602748eca7ce02c11c6.png","w":256,"h":256,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/c\/fc347f54e755d602748eca7ce02c11c6"}612336

EDIT

Source file attached and image file as well.

{"name":"612339","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/4\/549aa907c7e7dec2f71ab7d075b883f9.png","w":640,"h":360,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/4\/549aa907c7e7dec2f71ab7d075b883f9"}612339

Scooter
Member #16,799
January 2018

Edgar:
Sorry I got tied up and couldn't get back to you. I downloaded your file but
I could not run it. Says it was a syntax error. It didn't tell me where it was.
I will try to track it down tomorrow. I could see by the photo that you were
indeed able to attach mario to a pentagon. Great job! I will get back to you
later.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: