Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 1232 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

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


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.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (14 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!