[orx-mesh-generators] Change vertex formats used by meshVertexBuffer and meshVertexBufferWithColor to be Std430 compliant
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package org.openrndr.extra.meshgenerators
|
||||
|
||||
import org.openrndr.draw.BufferWriter
|
||||
import org.openrndr.draw.VertexBuffer
|
||||
import org.openrndr.draw.vertexBuffer
|
||||
import org.openrndr.draw.vertexFormat
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.mod
|
||||
@@ -34,7 +31,7 @@ fun bufferWriter(bw: BufferWriter): VertexWriter {
|
||||
* - `textureCoordinate` (vec2)
|
||||
*/
|
||||
fun meshVertexBuffer(size: Int): VertexBuffer {
|
||||
return vertexBuffer(vertexFormat {
|
||||
return vertexBuffer(vertexFormat(BufferAlignment.STD430) {
|
||||
position(3)
|
||||
normal(3)
|
||||
textureCoordinate(2)
|
||||
@@ -50,7 +47,7 @@ fun meshVertexBuffer(size: Int): VertexBuffer {
|
||||
* - `color` (vec4)
|
||||
*/
|
||||
fun meshVertexBufferWithColor(size: Int): VertexBuffer {
|
||||
return vertexBuffer(vertexFormat {
|
||||
return vertexBuffer(vertexFormat(BufferAlignment.STD430) {
|
||||
position(3)
|
||||
normal(3)
|
||||
textureCoordinate(2)
|
||||
|
||||
@@ -144,7 +144,7 @@ class TriangleMeshBuilder {
|
||||
*/
|
||||
fun toByteBuffer(): MPPBuffer {
|
||||
//val bb = ByteBuffer.allocateDirect(data.size * (3 * 4 + 3 * 4 + 2 * 4 + 4 * 4))
|
||||
val bb = MPPBuffer.allocate(data.size * (3 * 4 + 3 * 4 + 2 * 4 + 4 * 4))
|
||||
val bb = MPPBuffer.allocate(data.size * (4 * 4 + 4 * 4 + 4 * 4 + 4 * 4))
|
||||
|
||||
//bb.order(ByteOrder.nativeOrder())
|
||||
bb.rewind()
|
||||
@@ -152,13 +152,16 @@ class TriangleMeshBuilder {
|
||||
bb.putFloat(d.position.x.toFloat())
|
||||
bb.putFloat(d.position.y.toFloat())
|
||||
bb.putFloat(d.position.z.toFloat())
|
||||
bb.putFloat(0.0f)
|
||||
|
||||
bb.putFloat(d.normal.x.toFloat())
|
||||
bb.putFloat(d.normal.y.toFloat())
|
||||
bb.putFloat(d.normal.z.toFloat())
|
||||
|
||||
bb.putFloat(0.0f)
|
||||
bb.putFloat(d.texCoord.x.toFloat())
|
||||
bb.putFloat(d.texCoord.y.toFloat())
|
||||
bb.putFloat(0.0f)
|
||||
bb.putFloat(0.0f)
|
||||
|
||||
bb.putFloat(d.color.r.toFloat())
|
||||
bb.putFloat(d.color.g.toFloat())
|
||||
|
||||
Reference in New Issue
Block a user