This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HLSL (DirectX11) | |
cbuffer MyContantBuffer : register(b2) | |
{ | |
float4x4 matW; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GLSL | |
layout (std140, binding = 2) uniform MyUBO { | |
mat4 matW; | |
}; |
C側からバッファを"register"に指定するID3D11DeviceContext::VSSetConstantBuffers に相当するのは、glBindBufferBaseです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DirectX11 | |
#define POS 2 | |
pDeviceContext->VSSetConstantBuffers(POS, 1, &buffer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OpenGL | |
#define POS 2 | |
glBindBufferBase(GL_UNIFORM_BUFFER, POS, ubo); |
OpenGL ES 3.1はここまでで動作します。
GLSLで"binding"が使えないOpenGL ES 3.0では以下のそれ相当の処理をC側から行う必要があります。これはOpenGL ES 3.1でも有効で、"binding"で指定するのと同じ結果になります。更には、既に"binding"指定があってもC側から上書きすることもできます。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define POS 2 | |
glUniformBlockBinding(program, glGetUniformBlockIndex(program, "MyUBO"), POS); |
No comments:
Post a Comment