Merge pull request #5481 from samcake/punk

GL CORE PROFILE:Fixing a few shader and enableing the INput core profile that breaks on mac
This commit is contained in:
Brad Davis 2015-08-03 13:01:06 -07:00
commit c4d353e3af
10 changed files with 64 additions and 59 deletions

View file

@ -11,13 +11,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
uniform sampler2D colorMap;
uniform vec4 color;
in vec2 varTexcoord;
in vec2 varTexCoord0;
out vec4 outFragColor;
void main(void) {
outFragColor = texture(colorMap, varTexcoord) * color;
outFragColor = texture(colorMap, varTexCoord0) * color;
}

View file

@ -13,27 +13,27 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
uniform vec4 texcoordRect;
out vec2 varTexcoord;
out vec2 varTexCoord0;
void main(void) {
const vec4 UNIT_QUAD[4] = vec4[4](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4(1.0, -1.0, 0.0, 1.0),
vec4(-1.0, 1.0, 0.0, 1.0),
const vec4 UNIT_QUAD[4] = vec4[4](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4(1.0, -1.0, 0.0, 1.0),
vec4(-1.0, 1.0, 0.0, 1.0),
vec4(1.0, 1.0, 0.0, 1.0)
);
vec4 pos = UNIT_QUAD[gl_VertexID];
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
varTexcoord = ((pos.xy + 1) * 0.5) * texcoordRect.zw + texcoordRect.xy;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
varTexCoord0 = ((pos.xy + 1) * 0.5) * texcoordRect.zw + texcoordRect.xy;
}

View file

@ -11,12 +11,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
uniform sampler2D colorMap;
in vec2 varTexcoord;
in vec2 varTexCoord0;
out vec4 outFragColor;
void main(void) {
outFragColor = texture(colorMap, varTexcoord);
outFragColor = texture(colorMap, varTexCoord0);
}

View file

@ -12,12 +12,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
uniform sampler2D colorMap;
in vec2 varTexcoord;
in vec2 varTexCoord0;
out vec4 outFragColor;
void main(void) {
outFragColor = vec4(texture(colorMap, varTexcoord).xyz, 1.0);
outFragColor = vec4(texture(colorMap, varTexCoord0).xyz, 1.0);
}

View file

@ -12,25 +12,25 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
out vec2 varTexcoord;
out vec2 varTexCoord0;
void main(void) {
const vec4 UNIT_QUAD[4] = vec4[4](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4(1.0, -1.0, 0.0, 1.0),
vec4(-1.0, 1.0, 0.0, 1.0),
const vec4 UNIT_QUAD[4] = vec4[4](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4(1.0, -1.0, 0.0, 1.0),
vec4(-1.0, 1.0, 0.0, 1.0),
vec4(1.0, 1.0, 0.0, 1.0)
);
vec4 pos = UNIT_QUAD[gl_VertexID];
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
varTexcoord = (pos.xy + 1) * 0.5;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
varTexCoord0 = (pos.xy + 1) * 0.5;
}

View file

@ -16,7 +16,7 @@
<$declareStandardTransform()$>
out vec2 varTexcoord;
out vec2 varTexCoord0;
void main(void) {
const vec4 UNIT_QUAD[4] = vec4[4](
@ -34,5 +34,5 @@ void main(void) {
<$transformModelToWorldPos(obj, tc, tc)$>
gl_Position = pos;
varTexcoord = tc.xy;
varTexCoord0 = tc.xy;
}

View file

@ -57,7 +57,10 @@ void GLBackend::do_setInputBuffer(Batch& batch, uint32 paramOffset) {
}
}
#define NOT_SUPPORT_VAO
#if (GPU_FEATURE_PROFILE == GPU_CORE)
#define SUPPORT_VAO
#endif
#if defined(SUPPORT_VAO)
#else
@ -95,8 +98,10 @@ void GLBackend::killInput() {
void GLBackend::syncInputStateCache() {
#if defined(SUPPORT_VAO)
for (int i = 0; i < NUM_CLASSIC_ATTRIBS; i++) {
_input._attributeActivation[i] = glIsEnabled(attributeSlotToClassicAttribName[i]);
for (int i = 0; i < _input._attributeActivation.size(); i++) {
GLint active = 0;
glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &active);
_input._attributeActivation[i] = active;
}
//_input._defaultVAO
glBindVertexArray(_input._defaultVAO);

View file

@ -19,8 +19,8 @@ uniform sampler2D originalTexture;
// the interpolated normal
in vec3 _normal;
in vec4 _texCoord0;
in vec4 _color;
in vec3 _color;
in vec2 _texCoord0;
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);

View file

@ -14,18 +14,18 @@
// the texture
uniform sampler2D colorMap;
in vec3 _position;
in vec3 _normal;
in vec2 _texCoord0;
in vec4 _color;
in vec3 varPosition;
in vec3 varNormal;
in vec2 varTexCoord0;
in vec4 varColor;
out vec4 _fragColor;
out vec4 outFragColor;
void main(void) {
vec4 color = texture(colorMap, _texCoord0);
vec4 color = texture(colorMap, varTexCoord0);
// FIXME CORE this isn't working
//_fragColor = color * _color;
//_fragColor = vec4(color.rgb, color.a * _color.a);
//_fragColor = vec4(color.rgb * _color.rgb, color.a);
_fragColor = color;
outFragColor = color;
}

View file

@ -18,19 +18,19 @@
<$declareStandardTransform()$>
out vec3 _position;
out vec3 _normal;
out vec2 _texCoord0;
out vec4 _color;
out vec3 varPosition;
out vec3 varNormal;
out vec2 varTexCoord0;
out vec4 varColor;
void main(void) {
_texCoord0 = inTexCoord0.st;
_color = inColor;
varTexCoord0 = inTexCoord0.st;
varColor = inColor;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
_position = inPosition.xyz;
<$transformModelToEyeDir(cam, obj, inNormal.xyz, varNormal)$>
varPosition = inPosition.xyz;
}