So I got this code. I get black screen as my output. When I render with immediate rendering mode, works nice and all that. With this code, I get black screen.
int size = assets.size();
int vertices = 4;
int vertexSize = 2;
int textureSize = 2;
int colorSize = 4;
int overallSize = size * (vertices * (vertexSize + textureSize + colorSize));
FloatBuffer buffer = BufferUtils.createFloatBuffer(overallSize);
for (Asset asset : assets) {
// class Asset contains: float x, y, width, height, px, py, rot; Sprite sprite; Color color;
Rect rect = new Rect(asset.x, asset.y, asset.width, asset.height); // contains 4 vertices, 8 points. x0, y0, x1, y1, x2, y2, x3, y3
rect.rotate(asset.rot, new vec2(asset.px, asset.py));
Sprite sprite = asset.sprite; // contains: int width, height; SpriteSheet sheet;
//SpriteSheet is basically a class which contains texture handle.
float x0 = (1f / sprite.sheet.width) * sprite.width * sprite.x; // Texture position x0
float y0 = (1f / sprite.sheet.height) * sprite.height * sprite.y; // Texture position y0
float x1 = (1f / sprite.sheet.width) * sprite.width * (sprite.x + 1); // Texture position x1
float y1 = (1f / sprite.sheet.height) * sprite.height * (sprite.y + 1); // Texture position y1
Color color = asset.color; // contains r,g,b,a floats.
buffer.put(rect.x0).put(rect.y0);
buffer.put(x0).put(y0);
buffer.put(color.r).put(color.g).put(color.b).put(color.a);
buffer.put(rect.x1).put(rect.y1);
buffer.put(x1).put(y0);
buffer.put(color.r).put(color.g).put(color.b).put(color.a);
buffer.put(rect.x2).put(rect.y2);
buffer.put(x1).put(y1);
buffer.put(color.r).put(color.g).put(color.b).put(color.a);
buffer.put(rect.x3).put(rect.y3);
buffer.put(x0).put(y1);
buffer.put(color.r).put(color.g).put(color.b).put(color.a);
}
for (Asset asset : assets) {
}
for (Asset asset : assets) {
}
SpriteSheet.sheet.bind(); // Bind the texture.
glBindBuffer(target, handle);
glBufferData(target, buffer, GL_STATIC_DRAW);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
// x1, y1, s1, t1, r1, g1, b1, a1, x2, y2,
int stride = 8 * 4;
glVertexPointer(vertexSize, GL_FLOAT, stride, 0L);
glTexCoordPointer(textureSize, GL_FLOAT, stride, 8L);
glColorPointer(colorSize, GL_FLOAT, stride, 16L);
glDrawArrays(GL_QUADS, 0, size * vertices);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
I will post a fix if I find it before someone helps me.