chbaker0
12-22-2013, 06:58 PM
For some reason, a shape I'm attempting to draw a sphere without any transformations (other than a camera projection) won't draw correctly. This:
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
gl_Position = CameraMat * ModelMat * InPosition;
FragColor = InColor;
}
1205
causes a blank screen when drawing with ModelMat set to an identity matrix, while when it is set to ANYTHING else, it draws fine (correctly transformed as well). When I use this vertex shader:
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
gl_Position = CameraMat * InPosition;
FragColor = InColor;
}
1203
It draws perfectly fine, in the center of my world. It's quite odd that when I remove the term it draws fine, but when I leave it, it doesn't work...even weirder is this:
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
mat4 TestMat(1.0f);
gl_Position = CameraMat * TestMat * InPosition;
FragColor = InColor;
}
1204
It draws a big black sphere filling the whole window, when it is supposed to be green and not the size of the window. ??? I'm baffled. My C++ code remained exactly the same through all these samples, only the vertex shader changed. And, when I use the original shader (that gives no sphere with an identity ModelMat) with a translate, it draws it correctly.
EDIT: Turns out this:
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
mat4 TestMat(1.0f);
gl_Position = CameraMat * ModelMat * InPosition;
FragColor = InColor;
}
causes the big black sphere as well...so it is just the declaration of TestMat (and not the use of it) that causes that issue. I'm even more confused now.
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
gl_Position = CameraMat * ModelMat * InPosition;
FragColor = InColor;
}
1205
causes a blank screen when drawing with ModelMat set to an identity matrix, while when it is set to ANYTHING else, it draws fine (correctly transformed as well). When I use this vertex shader:
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
gl_Position = CameraMat * InPosition;
FragColor = InColor;
}
1203
It draws perfectly fine, in the center of my world. It's quite odd that when I remove the term it draws fine, but when I leave it, it doesn't work...even weirder is this:
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
mat4 TestMat(1.0f);
gl_Position = CameraMat * TestMat * InPosition;
FragColor = InColor;
}
1204
It draws a big black sphere filling the whole window, when it is supposed to be green and not the size of the window. ??? I'm baffled. My C++ code remained exactly the same through all these samples, only the vertex shader changed. And, when I use the original shader (that gives no sphere with an identity ModelMat) with a translate, it draws it correctly.
EDIT: Turns out this:
#version 330 core
layout (location = 0) in vec4 InPosition;
layout (location = 1) in vec4 InColor;
uniform mat4 CameraMat;
uniform mat4 ModelMat;
smooth out vec4 FragColor;
void main()
{
mat4 TestMat(1.0f);
gl_Position = CameraMat * ModelMat * InPosition;
FragColor = InColor;
}
causes the big black sphere as well...so it is just the declaration of TestMat (and not the use of it) that causes that issue. I'm even more confused now.