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  
  VBO has oddly placed vertices/connections on Radeon HD 6670/Intel HD 3000  (Read 414 times)
0 Members and 1 Guest are viewing this topic.
Offline Quaggles

Innocent Bystander





« Posted 2013-06-09 18:40:17 »

I was working on a block world with a chunking system and I encountered a bug with VBOs. My cube world seems to generate random vertices, but only on the Radeon HD 6670 and HD 3000 that I've tested it on. I'm now wondering if this is my code, LWJGL, OpenGL, the 6670/3000, or their drivers bugging out, and if it is something I can fix myself. I have a few screenshots, though none of it working correctly. I tested it on a laptop with an NVidia card in it and it ran perfectly fine. Can anyone tell me what I may be doing wrong? It is intended to generate a square of faces that covers a 16 * 16 * 16 cube grid.

Here are the screenshots: http://imgur.com/a/Q30Y3

And here's the code that creates the VBO and renders it:

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  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
private void updateChunkVertexArray()
{

    thisVertices.clear();

    GL15.glDeleteBuffers(thisVBOID);
    GL15.glDeleteBuffers(thisTexID);

    FloatBuffer bufferedTex = BufferUtils
            .createFloatBuffer(buffer.size() * 8 * 6);

    thisTexID = VBOHandler.createVBO();
    thisVBOID = VBOHandler.createVBO();

    for (int i = 0; i < buffer.size(); i++)
    {

        Vector4f thisVec = buffer.get(i);

        float x = (thisVec.getX() + offsetX);
        float y = (thisVec.getY() + offsetY);
        float z = (thisVec.getZ() + offsetZ);

        float posx = 1.0f * size + x * 0.25f;
        float posy = 1.0f * size + y * 0.25f;
        float posz = 1.0f * size + z * 0.25f;

        float negx = -1.0f * size + x * 0.25f;
        float negy = -1.0f * size + y * 0.25f;
        float negz = -1.0f * size + z * 0.25f;

        if (world.getBlock(x, y, z + 1f) == 0)
        {

            bufferedTex.put(texCoords);

            float[ ] frontFace =
            {
                    // Front Face
                   negx, negy, posz, // Bottom Left
                   posx, negy, posz, // Bottom Right
                   posx, posy, posz, // Top Right Of
                   negx, posy, posz

            };

            for (int t = 0; t < frontFace.length; t++)
            {
                thisVertices.add(Float.valueOf(frontFace[t]));
            }

            //bufferedVertices.put(frontFace);

        }

        if (world.getBlock(x, y, z - 1f) == 0)
        {

            bufferedTex.put(texCoords);

            float[ ] backFace =
            {
                    // Back Face
                   negx, negy, negz, // Bottom Left
                   negx, posy, negz, // Bottom Right
                   posx, posy, negz, // Top Right Of
                   posx, negy, negz

            };

            for (int t = 0; t < backFace.length; t++)
            {
                thisVertices.add(Float.valueOf(backFace[t]));
            }

            //bufferedVertices.put(backFace);

        }

        if (world.getBlock(x, y + 1f, z) == 0)
        {

            bufferedTex.put(texCoords);

            float[ ] topFace =
            {
                    // Top Face
                   negx, posy, negz, // Bottom Left
                   negx, posy, posz, // Bottom Right
                   posx, posy, posz, // Top Right Of
                   posx, posy, negz

            };

            for (int t = 0; t < topFace.length; t++)
            {
                thisVertices.add(Float.valueOf(topFace[t]));
            }

            //bufferedVertices.put(topFace);

        }

        if (world.getBlock(x, y - 1f, z) == 0)
        {

            bufferedTex.put(texCoords);

            float[ ] bottomFace =
            {
                    // Bottom Face
                   negx, negy, negz, // Bottom Left
                   posx, negy, negz, // Bottom Right
                   posx, negy, posz, // Top Right Of
                   negx, negy, posz

            };

            for (int t = 0; t < bottomFace.length; t++)
            {
                thisVertices.add(Float.valueOf(bottomFace[t]));
            }

            //bufferedVertices.put(bottomFace);

        }

        if (world.getBlock(x + 1f, y, z) == 0)
        {

            bufferedTex.put(texCoords);

            float[ ] rightFace =
            {
                    // right Face
                   posx, negy, negz, // Bottom Left
                   posx, posy, negz, // Bottom Right
                   posx, posy, posz, // Top Right Of
                   posx, negy, posz

            };

            for (int t = 0; t < rightFace.length; t++)
            {
                thisVertices.add(Float.valueOf(rightFace[t]));
            }

            //bufferedVertices.put(rightFace);

        }

        if (world.getBlock(x - 1f, y, z) == 0)
        {

            bufferedTex.put(texCoords);

            float[ ] leftFace =
            {
                    // left Face
                   negx, negy, negz, // Bottom Left
                   negx, negy, posz, // Bottom Right
                   negx, posy, posz, // Top Right Of
                   negx, posy, negz

            };

            for (int t = 0; t < leftFace.length; t++)
            {
                thisVertices.add(Float.valueOf(leftFace[t]));
            }

            //bufferedVertices.put(leftFace);

        }

    }

    float[ ] tempVertices = new float[thisVertices.size()];
    for (int i = 0; i < thisVertices.size(); i++)
    {

        Float f = thisVertices.get(i);
        tempVertices[i] = Float.valueOf(f);

    }

    FloatBuffer bufferedVertices = BufferUtils
            .createFloatBuffer(thisVertices.size());

    bufferedVertices.put(tempVertices);

    bufferedVertices.flip();
    bufferedTex.flip();

    VBOHandler.bufferData(thisVBOID, bufferedVertices);
    VBOHandler.bufferData(thisTexID, bufferedTex);

//And now the rendering code...

public void renderChunk()
{

    //GL11.glCallList(chunkDisplayList);

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, thisVBOID);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, thisTexID);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

    GL11.glDrawArrays(GL11.GL_QUADS, 0, thisVertices.size());

    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); // deactivate vertex array
   GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // bind with 0 for normal pointers
   GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
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!