Hot answers tagged

2

GLSL allows a location to be assigned to each in/out variables then the names can be anything you want. Here is an example: Vertex shader: layout(location=0) out vec3 test; Geometery shader: // as long as the location numbers match, the names don't matter layout(location=0) in vec3 testIn; layout(location=0) out vec3 testOut; Fragment shader: // location ...


1

in vec3 dataArray[2][]; // how to do this? Arrays of arrays in GLSL work differently than you might expect. The array indices are read left-to-right. For example, vec2 var[2][3] is a 2-element array of 3-element arrays of vec2s. What you want is an "unsized array of 2 element arrays of vec3". To do that, you need in vec3 dataArray[][2];. ...


1

Change the output of the vertex shader to out vec3[2] dataArray; and the input to the tessellation control shader as in vec3[2] dataArray[]; That should work. Alternatively you could also define the type of dataArray as a struct.


1

I typically like to define a "GPUData" struct containing the fields that are going to the shader, and keep the GPUDatas for all the particles in an array. Then, when it's time to update the GPU buffer, you can just memcpy out of that array to your mapped buffer (or you can pass the array to glBufferSubData, etc). For the CPU state, rather than ...


1

In accord with the GLSL extension, gl_Layer in a mesh shader is part of the predefined gl_MeshPerPrimitiveNV output interface block. It seems to have the expected definition. This is a per-primitive parameter, so you can set it to a different value for each primitive you output. Basically, yes: layered rendering is available in task/mesh shaders. And since ...


1

There are two types of BSP trees, the Axis Aligned BSP (aka k-D tree) and the polygon aligned BSP. Doom used the polygon aligned variety. Polygon aligned BSP tree's can be traversed in occlusion order (back to front, or front to back depending on the needs). This makes them useful in situations where a Z-buffer isn't available and was the original reason BSP ...


1

The viewport as specified by glViewport is just the rectangle in pixels on the screen that you wish to render to. Usually it's from (0,0) to (width, height) in pixels, but you could set it to a smaller region (or larger, for that matter) and it will basically scale the image as it's being rendered. The "affine transformation from normalized device ...


1

OpenGL version 2.1 does not support vertex arrays (vaos), you need OpenGL version 3.0+. Try invoking a core profile and see if that helps. If not then your version might be maxed out at version 2.1 as Apple does not really support OpenGL well (And especially since your graphics card is directly vendored from Apple). Also a handy tip would to consider Apple's ...


Only top voted, non community-wiki answers of a minimum length are eligible