Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
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  
  LWJGL glCallLists OpenGL error 1282?  (Read 976 times)
0 Members and 1 Guest are viewing this topic.
Offline sci4me

Junior Duke





« Posted 2013-11-14 04:09:36 »

Hey guys! So, basically when I call glCallLists and pass my IntBuffer of lists to render, it gives OpenGL error 1282... and I can't figure out why. I am fairly certain that this is a texture issue... I am using slick 2d's texture loader. If I remove the Util.checkGLError(), I can get it to render, but the textures aren't correct.. which is the main reason I think it's a texture issue... any ideas? I know that I am not calling any glBegin()/glEnd() pairs during the glCallLists... so.. don't know what else it could be.   
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2013-11-14 04:45:28 »

You need to remove any translate/scale/rotate functions out of between your glCreateList and glEndList
http://stackoverflow.com/questions/6816793/opengl-error-1282-with-glendlist

Offline sci4me

Junior Duke





« Reply #2 - Posted 2013-11-14 05:05:04 »

But.. how could that work... how can the blocks be at the right position in the list...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #3 - Posted 2013-11-14 05:09:26 »

Call translate after your display lists are generated. You're not going to get around it, so just do it. Display lists only allow certain functions to be called when creating a new list. glTranslate is not one of them. So, loop through all your objects and call glTranslate on them in between glPushMatrix and glPopMatrix calls to preserve the matrices.

Offline sci4me

Junior Duke





« Reply #4 - Posted 2013-11-14 05:11:53 »

I still don't understand how to do that..
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
GL11.glNewList(listID, GL11.GL_COMPILE);
      for(int xx = x; xx < x + 16; xx++)
      {
         for(int yy = y; yy < y + 256; yy++)
         {
            for(int zz = z; zz < z + 16; zz++)
            {
               cube(xx * 2, yy * 2, zz * 2);
            }
         }
      }
      GL11.glEndList();

in the cube method, i do translations and drawing... so.. I don't see how that could be done outside of the list..
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #5 - Posted 2013-11-14 05:15:06 »

Like I said, after you create the list, loop through your objects and translate them to the correct position. Since you seem to be creating a voxel engine, I would recommend not using glTranslate for translating your geometry, its a terrible resource hog. In your cube method, for your glVertexCalls, just use the coordinates you want to render the cubes at, don't use glTranslate. Your code seems like it would be fine without glTranslate though.

Offline sci4me

Junior Duke





« Reply #6 - Posted 2013-11-14 05:16:01 »

hmm.. that will be a lot of changing but that will work. Tongue didnt think of that... thx, ill try.
Offline sci4me

Junior Duke





« Reply #7 - Posted 2013-11-14 05:20:07 »

I removed the translates but I still get the error... check the cube 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  
private void cube(int x, int y, int z)
   {
      Block b = Block.blockList[blocks[(x / 2) - this.x][(y / 2) - this.y][(z / 2) - this.z]];
      if(b == null)
         return;

      GL11.glBegin(GL11.GL_QUADS);
      {
         Texture t = b.getTexture(Side.TOP);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, 1+y, 1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, 1+y, 1+z);

         t = b.getTexture(Side.BOTTOM);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, -1+y, 1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, -1+y, 1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, -1+y, -1+z);

         t = b.getTexture(Side.NORTH);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, -1+y, 1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, -1+y, 1+z);

         t = b.getTexture(Side.SOUTH);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(-1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(-1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(1+x, 1+y, -1+z);

         t = b.getTexture(Side.EAST);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(-1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(-1+x, -1+y, 1+z);

         t = b.getTexture(Side.WEST);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(1+x, -1+y, 1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, -1+y, -1+z);
      }
      GL11.glEnd();
   }
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2013-11-14 05:23:51 »

You can't bind textures whilst creating a display list I believe either. It also will destroy your FPS for very technical reasons. Try removing the bind calls. When you need to render your textures, use a sprite sheet and store your texture coordinates in your block class. Each block type will have different coordinates. Bind the spritesheet right before you render your display list. Trust me, it'll be ridiculously faster than what you're doing now.

Offline sci4me

Junior Duke





« Reply #9 - Posted 2013-11-14 05:25:06 »

Okay, how do I do the coordinates? Still haven't figured that out...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sci4me

Junior Duke





« Reply #10 - Posted 2013-11-14 06:03:19 »

Okay, I got it working... but my textures are 16x16 and i have it in a 512x512 sheet, so i use 0.03125 for my tex coords, but that doesnt correctly line up... its VERY close.. but its a tiny bit off, and i cant seem to make it any better... ideas?      

http://i.imgur.com/Ddw21Xe.png

See how they dont line up? Hmm..
Offline Mac70
« Reply #11 - Posted 2013-11-14 08:36:49 »

You can bind textures and use glTranslate/glRotate/glScale while creating display lists without problems, but binding textures inside display list is rather bad practice. Smiley

Check out my Devblog! Smiley
Offline sci4me

Junior Duke





« Reply #12 - Posted 2013-11-14 12:58:32 »

I removed all those... the issue is now with my texture coords or the sprite sheet...
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.

theagentd (20 views)
2014-10-25 15:46:29

Longarmx (53 views)
2014-10-17 03:59:02

Norakomi (47 views)
2014-10-16 15:22:06

Norakomi (35 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (69 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (74 views)
2014-10-11 23:24:42

BurntPizza (46 views)
2014-10-11 23:10:45
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!