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 (408)
games submitted by our members
Games in WIP (293)
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  
  Problem with: glutSolidSphere & GL_QUADS  (Read 1350 times)
0 Members and 1 Guest are viewing this topic.
Offline Bananni

Senior Newbie




Belive the hype!


« Posted 2010-08-25 22:01:48 »

Hi,
for my battle system im using a Cubemap to fake a full 3D world.
Im using 6 textures, 4 for sides and 2 for ground and sky.
Now i would like to use GL_QUADS to display my 2D battlers.
The problem now is: My Battlers arent display =/
Heres the code/setting im using:
settings:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
        gl.glShadeModel(GL.GL_FLAT);
        gl.glEnable(GL.GL_TEXTURE_2D);
        gl.glEnable(GL.GL_BLEND);
        gl.glColorMask(true, true, true, true);
        double widht = 774;
        double height = 540;
        final float h = (float) width / (float) height;
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(60.0f, h, .1, 10);
        gl.glViewport(0, 0, (int)width, (int)height);
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();

render:
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  
  public void render(GL gl){
    renderBG(gl);
    for(int i=0;i<battler.length;i++){ // 2 Battlers
      Texture tex = battler[i].battler.animations[battler[i].action].getFrame(); // The Texture is a texture with content.
      tex.bind();
      tex.enable();
      gl.glTranslatef(battler[i].coor.xf, battler[i].coor.yf, battler[i].coor.zf); // All Coor are zero.
      TextureCoords coords = tex.getImageTexCoords();
      gl.glBegin(GL.GL_QUADS);
        gl.glTexCoord2f(coords.left(), coords.bottom());
        gl.glVertex3f(0, 0, 0);
        gl.glTexCoord2f(coords.right(), coords.bottom());
        gl.glVertex3f(1, 0, 0);
        gl.glTexCoord2f(coords.right(), coords.top());
        gl.glVertex3f(1, 1, 0);
        gl.glTexCoord2f(coords.left(), coords.top());
        gl.glVertex3f(0, 1, 0);
      gl.glEnd();
      gl.glTranslatef(-battler[i].coor.xf, -battler[i].coor.yf, -battler[i].coor.zf);
    }
  }
  private void useCamera(GL gl){
    gl.glRotatef((float)Math.toDegrees(Camera.v),1f,0f,0f); // is zero.
    gl.glRotatef((float)Math.toDegrees(Camera.h),0f,1f,0f); // is zero.
    gl.glRotatef((float)Math.toDegrees(Camera.c),0f,0f,1f); // is zero.
  }
  private void renderBG(GL gl){
    cubemap.bind();
    cubemap.enable();
    gl.glEnable(GL.GL_LIGHTING);
    gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
    gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
    gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
    gl.glEnable(GL.GL_TEXTURE_GEN_S);
    gl.glEnable(GL.GL_TEXTURE_GEN_T);
    gl.glEnable(GL.GL_TEXTURE_GEN_R);
    gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
    gl.glMatrixMode(GL.GL_TEXTURE);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    useCamera(gl);
    glut.glutSolidSphere(5.0, 40, 20);
    gl.glDisable(GL.GL_LIGHTING);
    gl.glPopMatrix();
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glDisable(GL.GL_TEXTURE_GEN_S);
    gl.glDisable(GL.GL_TEXTURE_GEN_T);
    gl.glDisable(GL.GL_TEXTURE_GEN_R);
  }

Offline gouessej

JGO Ninja


Medals: 33
Projects: 1


TUER


« Reply #1 - Posted 2010-08-26 11:16:05 »

Hi!

Have you ever succeeded in displaying your fighters before using quads?

Offline Bananni

Senior Newbie




Belive the hype!


« Reply #2 - Posted 2010-08-26 13:50:17 »

Yes, in ortho mode they was displayed, before in 3D Mode also, but now its not possible anymore and i dont get it why i cant display them anymore =/
OK! now my system is displaying the Quad, i made a mistake with Z, i used + instead of - and i forgot to use: cubemap.disable();
Thx, can be closed Smiley

Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline gouessej

JGO Ninja


Medals: 33
Projects: 1


TUER


« Reply #3 - Posted 2010-08-27 12:39:26 »

Please can you post the both pieces of code with your corrections? It would allow me to see exactly what you did to make it work.

Offline Bananni

Senior Newbie




Belive the hype!


« Reply #4 - Posted 2010-08-27 17:44:42 »

The upper part i didnt change.
I juz realized that i used .1 to 10 for range.
So i changed the Z Coor of my Battler to -6f and there he was :3
In the next step i saw that my battler has a polygon, but no texture.
I searched for the reason and i saw the line: cubemap.enable();
so i completet it @ the end of my background rendering by: cubemap.disable();
Here are my modifications:
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  
  private void renderBG(GL gl){
    gl.glLoadIdentity();
    cubemap.bind();
    // -------------------------------------- WHERES THE REST? :(
   cubemap.enable();
    // -------------------------------------------------------------------
   gl.glEnable(GL.GL_LIGHTING);

    gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
    gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
    gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);

    gl.glEnable(GL.GL_TEXTURE_GEN_S);
    gl.glEnable(GL.GL_TEXTURE_GEN_T);
    gl.glEnable(GL.GL_TEXTURE_GEN_R);

    gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);

    gl.glMatrixMode(GL.GL_TEXTURE);
    gl.glPushMatrix();
    gl.glLoadIdentity();

    useCamera(gl);

    glut.glutSolidSphere(5.0, 40, 20);

    gl.glDisable(GL.GL_LIGHTING);

    gl.glPopMatrix();
    gl.glMatrixMode(GL.GL_MODELVIEW);

    gl.glDisable(GL.GL_TEXTURE_GEN_S);
    gl.glDisable(GL.GL_TEXTURE_GEN_T);
    gl.glDisable(GL.GL_TEXTURE_GEN_R);
    // ------------------------------------------------- HERE IT IS :3
   cubemap.disable();
    // -------------------------------------------------------------------
 }

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!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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!
cubemaster21 (107 views)
2013-05-17 21:29:12

alaslipknot (115 views)
2013-05-16 21:24:48

gouessej (144 views)
2013-05-16 00:53:38

gouessej (140 views)
2013-05-16 00:17:58

theagentd (152 views)
2013-05-15 15:01:13

theagentd (136 views)
2013-05-15 15:00:54

StreetDoggy (180 views)
2013-05-14 15:56:26

kutucuk (203 views)
2013-05-12 17:10:36

kutucuk (204 views)
2013-05-12 15:36:09

UnluckyDevil (210 views)
2013-05-12 05:09:57
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

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.306 seconds with 21 queries.