Celeron's picture

[SL Multitexturing] - Only one texture with gluSphere

Hi again,
after my first newbie post ( http://www.opentk.com/node/719 , sorry again... ) I've done my homeworks using RenderMonkey to check the vertex/fragment shader syntax.
Well, the result is acceptable as you can see here:

The seguent poor result, instead, is produced by my code:

It seems like only one texture (day) is available and for sure something in my code is going wrong ;-)
A question: does gluSphere support multitexturing? If so, how can I accomplish this task? Reading some examples with Google, I didn't found any reference to this.

For all those wishing help me to understand, I've posted the VB.Net 2005 project that implements - better say "tries to implement" :-) - SL sphere multitexturing.
In the project is included vertex/fragment code (as it appears in the Orange Book - ch. #10), but - obviously - not the textures. These ones are 7200x3600 px jpegs; after all, to compile and run the project, it is possible to use any image you have; the problem - I think - isn't in the textures because they went well in RenderMonkey :-(

Thanks in advance for any help :-)

SphereMultitexturing.zip48.85 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Celeron's picture
the Fiddler wrote:

Two suggestions:

  1. Add the following code to verify that the indices are correct:
                // Verify that we don't access any vertices out of bounds:
                foreach (int index in data)
                    if (index >= segments * rings)
                        throw new IndexOutOfRangeException();

Few days ago, I've read your suggestion too quickly; so I really didn't understand what you wrote, sorry.
Now I've paid more attention on it and so I've attached your checking code without finding any mismatch between the number of indices and the product between segments and rings. In fact, the exception wasn't thrown.

the Fiddler wrote:
  1. Try with fewer segments/rings.

Yes, I've done this twice: first time with 12 rings and 5 segments (see "12segments-5rings.jpg" attached) and then with 30 segments and 30 rings (see "30segments-30rings.jpg" attached).
The object drawn is intentionally without textures to be more clear.

Really don't know what to check:
1. the vertices/indices generation code is completely identical to what theFiddler has posted (I've checked many many times);
2. the VBO loading and drawing do not generate any error;
3. I don't know if could be any mistake using MatrixMode/Viewport, but I don't really think so...

I've attached the entire C# project. It's very basic and I ask you just 5 minutes to watch in it; I will really appreciate this :-)
The code is fully commented to simplify the reading and the understanding of the - very very simple - logic.

Thank you very much; it's very important for me to understand where I'm going wrong :-)

VboAndShaders.zip51.8 KB
30segments-30rings.jpg104.7 KB
12segments-5rings.jpg62.27 KB
Celeron's picture

I think I've done some step ahead; simply, I've spent a couple of hours to find and read a clear tutorial (here it is: http://www.spheregames.com/download.php?name=sky_pdf ).
This reading has pointed my attention to a Fiddler's "key" word that I've left behind (much because a language misunderstanding.. sorry..). The "key" word was skydome

"the Fiddler" wrote:

I just tested here and the code seems to work fine (I'm using it for a skydome/skysphere).

Sure you was right :-)

I was wrong assuming that vertices calculation was referred to a sphere; so, I modified the code to extend the drawing of the negative rings, then I resized the array bounds and fixed the phi calculation... and this is the result:

My next goal - obviously :-) - will be to apply the textures and the SL code.

Thank you very much again. Sometime the silence tells much more things than you think ;-)