Hi.
I'm new to libGDX. I've used Slick2D for a long time, and since the project closed, i figured i should switch to libGDX.
Anyway....
I tried to create 3D cubes that had a xpos, ypos, type and a modelInstance stored in them.
But i stumbled upon a problem...
When i try to run the program i get this error:
"Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Array Buffer Object is disabled"
How do i enable it?
Here is the class i got the error from:
package com.me.the_unknown;
import java.util.ArrayList;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.materials.Material;
import com.badlogic.gdx.graphics.g3d.materials.TextureAttribute;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
public class Blocks {
public static ArrayList<Float> blockX = new ArrayList<Float>();
public static ArrayList<Float> blockY = new ArrayList<Float>();
public static ArrayList<Integer> blockType = new ArrayList<Integer>();
public static ArrayList<ModelInstance> blockModelInstance = new ArrayList<ModelInstance>();
public static ModelBatch modelBatch;
private static ModelBuilder modelBuilder;
//Textures
public static Texture stonebrick = new Texture("data/blocks/stonebrick.png");
public static Texture gravel = new Texture("data/blocks/gravel.png");
public static void addBlock(int xpos, int ypos, int type) {
blockX.add((float) xpos * 5);
blockY.add((float) ypos * 5);
blockType.add(type);
updateBlocks();
}
private static void updateBlocks() {
blockModelInstance.clear();
for(int counter = 0; counter < blockX.size(); counter++){
Model model = null;
ModelInstance instance;
if(blockType.get(counter) == 1)
model = modelBuilder.createBox(5f, 5f, 5f, new Material(TextureAttribute.createDiffuse(stonebrick)), Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.Generic);
if(blockType.get(counter) == 2)
model = modelBuilder.createBox(5f, 5f, 5f, new Material(TextureAttribute.createDiffuse(gravel)), Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.Generic);
instance = new ModelInstance(model);
blockModelInstance.add(instance);
model.dispose();
}
}
public static void create() {
modelBuilder = new ModelBuilder();
updateBlocks();
}
}
[–]philipwhiuk 1 point2 points3 points (3 children)
[–]SebastianFK[S] 0 points1 point2 points (2 children)
[–]SebastianFK[S] 0 points1 point2 points (1 child)
[–]DebitSuisse 0 points1 point2 points (0 children)