-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Element array buffer support #15
Comments
Hey @medilies, element drawing is currently not supported. I haven't prioritized element drawing yet, as its benefits truly shine in larger scenes with highly complex geometry. The Does your use case greatly benefit from indexed vertices? Are you implementing skinning or something similar? |
Nah, I'm too noob to play with I just didn't like how verbose it is to write a vertex buffer without indexing. And I also noticed that the instancing example was consuming 100% of my GPU. |
The instancing example renders 125,000 cubes, so it requires a significant amount of GPU power. Additionally, there's considerable overdraw in the example. You can view it as a simple benchmark ;) In VISU there is a simple abstraction around vertex arrays/buffers, which reduces some of the verbosity. Here's an example of instanced rendering of several planes to render images, sprites, rectangles, etc. $vertexLayout = [
2, // position
2, // tex coords
];
$instanceLayout = [
4, // mat4x0
4, // mat4x1
4, // mat4x2
4, // mat4x3
];
$vertexArray = new BasicInstancedVertexArray($gl, $vertexLayout, $instanceLayout);
$vertexArray->uploadVertexData(new FloatBuffer([
// vertex positions
// this makes up the quad
// position // tex coords
-1.0, -1.0, 0.0, -1.0,
1.0, -1.0, 1.0, -1.0,
-1.0, 1.0, 0.0, 0.0,
1.0, 1.0, 1.0, 0.0,
])); Then to render: // allocate a buffer to hold all instance matrices
$buffer = new FloatBuffer();
// create a transform for item A
$itemA = new Transform();
$itemA->position->x = 20;
// and B..
$itemB = new Transform();
$itemB->position->x = 40;
// push the matrices into our buffer
$buffer->pushMat4($transform->getLocalMatrix());
$buffer->pushMat4($transform->getLocalMatrix());
// upload the buffer and draw the vertex array in TRAINGLE_STRIP mode.
$this->vertexArray->uploadInstanceData($buffer);
$this->vertexArray->drawAll(GL_TRIANGLE_STRIP); |
Thank you for the tip 🙇🏼, I'll keep a note to try it when I use VISU. Edit: I think I shouldn't keep this to myself, but I find it a little bit hard to understand the VISU folder structure and dev flow, and I couldn't find any doc. Edit 2: Maybe I find it hard because I'm alien to game dev jargon (scene, node, signals ...) |
Hi, can I currently use
GL_ELEMENT_ARRAY_BUFFER
andglDrawElements
? because I tried some hours ago and got an error (I do not remember its detail but I'll reproduce it if needed)If not, are there any plans to add support?
The text was updated successfully, but these errors were encountered: