Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (306)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Multitexturing woes  (Read 1044 times)
0 Members and 1 Guest are viewing this topic.
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Posted 2003-05-21 18:05:13 »

Alright, I'm positive I'm doing something stupid, but I am unable to get multitexturing to work. I'm working from the GT40 tutorial from Chman's website. I'm just trying to get a little test done with a brute force renderer, but ran into this issues.

All that is happening is the base texture is applied but no detail texture is showing up. My framerate also drops about 25% from just rendering with normal texturing.

The display is reporting true for ARB_multitexture. Is there something I need to do within LWJGL to set it up?

I'm positive that the detail texture is loaded properly, because if I set it as GL.TEXTURE0_ARB it renders.

Here's my rendering method.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
public void render() {
        float shade;
        float texLeft = 0.0f;
        float texUp = 0.0f;
        float texDown = 0.0f;
       
        float red = 1.0f;
        float green = 1.0f;
        float blue = 1.0f;
       
        if(isDetailed && isTextured) {
              gl.disable(GL.BLEND);
              gl.activeTextureARB(GL.TEXTURE0_ARB);
                  gl.enable(GL.TEXTURE_2D);
                  TextureManager.getTextureManager().bind(textureId);
                  gl.activeTextureARB( GL.TEXTURE1_ARB );
                 
                  gl.texEnvi( GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.COMBINE_ARB );
                  gl.texEnvi( GL.TEXTURE_ENV, GL.RGB_SCALE_ARB, 2 );

                  TextureManager.getTextureManager().bind(id);
        } else if(isTextured) {
              gl.enable(GL.TEXTURE_2D);
              TextureManager.getTextureManager().bind(textureId);
        }

        for (int z = 0; z < terrainSize - 1; z++) {
            gl.begin(GL.TRIANGLE_STRIP);

            if(isTextured) {
                texUp = (float)z/terrainSize;
                      texDown = (float)(z+1)/terrainSize;
            }
           
            for (int x = 0; x < terrainSize - 1; x++) {
                 
                  if(isTextured && isDetailed) {
                              texLeft = (float)x/terrainSize;
                              gl.multiTexCoord2fARB( GL.TEXTURE0_ARB, texLeft, texUp );
                              gl.multiTexCoord2fARB( GL.TEXTURE1_ARB, texLeft*repeatDetailMap,
                                          texUp*repeatDetailMap );
                  }else if(isTextured) {
                    texLeft = (float)x/terrainSize;
                    gl.texCoord2f(texLeft, texUp);
                }
               
                if(isLighted) {
                    shade = lightMap.getShade(x,z);
                    red = shade * lightMap.getColor().x;
                    green = shade * lightMap.getColor().y;
                    blue = shade * lightMap.getColor().z;
                   
                } else {
                    shade = (float)heightData.getTrueHeightAtPoint(x, z);
                    shade /= 255;
                    red = shade;
                    green = shade;
                    blue = shade;
                }
               
                gl.color3f(red, green, blue);

                gl.vertex3f(x, heightData.getScaledHeightAtPoint(x, z), z);

                if(isLighted) {
                    shade = lightMap.getShade(x,z+1);
                              red = shade * lightMap.getColor().x;
                              green = shade * lightMap.getColor().y;
                              blue = shade * lightMap.getColor().z;
                } else {
                    shade = (float)heightData.getTrueHeightAtPoint(x, z+1);
                    shade /= 255;
                              red = shade;
                              green = shade;
                              blue = shade;
                }
                gl.color3f(red, green, blue);
                if(isTextured && isDetailed) {
                              gl.multiTexCoord2fARB( GL.TEXTURE0_ARB, texLeft, texDown );
                              gl.multiTexCoord2fARB( GL.TEXTURE1_ARB, texLeft*repeatDetailMap,
                                    texDown*repeatDetailMap );
                }else if(isTextured) {
                    gl.texCoord2f(texLeft, texDown);
                }

                gl.vertex3f(
                    x,
                    heightData.getScaledHeightAtPoint(x, z + 1),
                    z + 1);
            }

            gl.end();
        }
       
        if(isTextured && isDetailed) {
              gl.activeTextureARB( GL.TEXTURE1_ARB );
              gl.disable( GL.TEXTURE_2D );
              gl.bindTexture( GL.TEXTURE_2D, 0 );
              gl.activeTextureARB( GL.TEXTURE0_ARB );
              gl.disable( GL.TEXTURE_2D );
              gl.bindTexture( GL.TEXTURE_2D, 0 );
             
            }else if(isTextured) {
              gl.disable(GL.TEXTURE_2D);
        }
    }


Thanks for any help.

Don't send a man to do a monkey's work.
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #1 - Posted 2003-05-21 21:44:40 »

Well, I'm not sure what I did. I nuked all the multitexturing code and started over, I retyped it from memory, and it worked. I still don't know what I was doing incorrectly before, and comparing the posted code with the working doesn't reveal any obvious answers. This matter is resolved though.

Don't send a man to do a monkey's work.
Offline princec
« League of Dukes »

JGO Kernel


Medals: 197
Projects: 3


Eh? Who? What? ... Me?


« Reply #2 - Posted 2003-05-23 00:01:46 »

Well, you forgot to enable texturing on unit 1...

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #3 - Posted 2003-05-23 00:39:23 »

Damn... ok, no more responses to this thread... let my stupidity get buried. I was wondering why the second attempt worked... I swore I did the "same" thing.

Don't send a man to do a monkey's work.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
Jesse_Attard (10 views)
2013-06-18 22:03:02

HeroesGraveDev (55 views)
2013-06-15 23:35:23

Vermeer (55 views)
2013-06-14 20:08:06

davedes (54 views)
2013-06-14 16:03:55

alaslipknot (50 views)
2013-06-13 07:56:31

Roquen (67 views)
2013-06-12 04:12:32

alaslipknot (56 views)
2013-06-10 19:30:18

HeroesGraveDev (72 views)
2013-06-09 04:36:03

alaslipknot (60 views)
2013-06-09 03:40:19

CodeHead (60 views)
2013-06-09 02:55:41
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!