Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 1676 times)
0 Members and 1 Guest are viewing this topic.
Offline Bananni

Senior Newbie




Belive the hype!


« Posted 2010-08-25 20: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
« Reply #1 - Posted 2010-08-26 09: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 11: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!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2010-08-27 10: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 15: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.

 

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

The first screenshot will be displayed as a thumbnail.

BurntPizza (24 views)
2014-09-19 03:14:18

Dwinin (39 views)
2014-09-12 09:08:26

Norakomi (68 views)
2014-09-10 13:57:51

TehJavaDev (93 views)
2014-09-10 06:39:09

Tekkerue (47 views)
2014-09-09 02:24:56

mitcheeb (68 views)
2014-09-08 06:06:29

BurntPizza (51 views)
2014-09-07 01:13:42

Longarmx (38 views)
2014-09-07 01:12:14

Longarmx (44 views)
2014-09-07 01:11:22

Longarmx (40 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!