@@ -38,7 +38,7 @@ public: | |||
if (!m_ready) | |||
{ | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(01_triangle)); | |||
m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); | |||
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | |||
@@ -75,10 +75,8 @@ public: | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(02_cube)); | |||
m_mvp = m_shader->GetUniformLocation("in_Matrix"); | |||
m_coord = m_shader->GetAttribLocation("in_Vertex", | |||
VertexUsage::Position, 0); | |||
m_color = m_shader->GetAttribLocation("in_Color", | |||
VertexUsage::Color, 0); | |||
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_color = m_shader->GetAttribLocation(VertexUsage::Color, 0); | |||
m_vdecl = | |||
new VertexDeclaration(VertexStream<vec3,vec3>(VertexUsage::Position, | |||
@@ -2,14 +2,14 @@ | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Color; | |||
uniform mat4 in_Matrix; | |||
varying vec3 pass_Color; | |||
void main(void) | |||
{ | |||
gl_Position = in_Matrix * vec4(in_Vertex, 1.0); | |||
gl_Position = in_Matrix * vec4(in_Position, 1.0); | |||
pass_Color = in_Color; | |||
} | |||
@@ -2,14 +2,14 @@ | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Color; | |||
uniform mat4 in_Matrix; | |||
varying vec3 pass_Color; | |||
void main(void) | |||
{ | |||
gl_Position = in_Matrix * vec4(in_Vertex, 1.0); | |||
gl_Position = in_Matrix * vec4(in_Position, 1.0); | |||
pass_Color = in_Color; | |||
} | |||
@@ -58,7 +58,7 @@ public: | |||
if (!m_ready) | |||
{ | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(08_fbo)); | |||
m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); | |||
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_uni_flag = m_shader->GetUniformLocation("in_Flag"); | |||
m_uni_point = m_shader->GetUniformLocation("in_Point"); | |||
m_uni_color = m_shader->GetUniformLocation("in_Color"); | |||
@@ -463,8 +463,8 @@ public: | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(11_fractal)); | |||
m_vertexattrib = m_shader->GetAttribLocation("a_Vertex", VertexUsage::Position, 0); | |||
m_texattrib = m_shader->GetAttribLocation("a_TexCoord", VertexUsage::TexCoord, 0); | |||
m_vertexattrib = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_texattrib = m_shader->GetAttribLocation(VertexUsage::TexCoord, 0); | |||
m_texeluni = m_shader->GetUniformLocation("u_TexelSize"); | |||
m_screenuni = m_shader->GetUniformLocation("u_ScreenSize"); | |||
m_zoomuni = m_shader->GetUniformLocation("u_ZoomSettings"); | |||
@@ -6,14 +6,14 @@ uniform mat4 u_ZoomSettings; | |||
uniform vec4 u_TexelSize; | |||
uniform vec4 u_ScreenSize; | |||
attribute vec2 a_TexCoord; | |||
attribute vec2 a_Vertex; | |||
attribute vec2 in_TexCoord; | |||
attribute vec2 in_Position; | |||
varying vec4 v_CenterX, v_CenterY, v_IndexX, v_IndexY; | |||
void main(void) | |||
{ | |||
gl_Position = vec4(a_Vertex, 0.0, 1.0); | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
/* Center point in [-.5,.5], apply zoom and translation | |||
* transformation, and go back to texture coordinates | |||
* in [0,1]. That's the ideal point we would like to | |||
@@ -33,9 +33,9 @@ void main(void) | |||
u_ZoomSettings[1][1], | |||
u_ZoomSettings[2][1], | |||
u_ZoomSettings[3][1]); | |||
v_CenterX = zoomscale * a_TexCoord.x + zoomtx | |||
v_CenterX = zoomscale * in_TexCoord.x + zoomtx | |||
+ offsets.xyxy * u_TexelSize.x; | |||
v_CenterY = zoomscale * a_TexCoord.y - zoomty | |||
v_CenterY = zoomscale * in_TexCoord.y - zoomty | |||
+ offsets.xyyx * u_TexelSize.y; | |||
/* Precompute the multiple of one texel where our ideal | |||
* point lies. The fragment shader will call floor() on | |||
@@ -2,14 +2,14 @@ | |||
#version 120 | |||
attribute vec2 in_position; | |||
attribute vec2 in_Position; | |||
varying vec2 pass_position; | |||
void main() | |||
{ | |||
pass_position = in_position; | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
pass_position = in_Position; | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
@@ -5,7 +5,7 @@ | |||
#version 120 | |||
attribute vec2 in_position; | |||
attribute vec2 in_Position; | |||
uniform vec2 in_screen_res; | |||
@@ -16,7 +16,7 @@ varying vec2 pass_p[8]; | |||
void main() | |||
{ | |||
//JFA ALGO | |||
pass_pos = ((vec2(1.0) + in_position) * 0.5); | |||
pass_pos = ((vec2(1.0) + in_Position) * 0.5); | |||
float k = in_step; | |||
@@ -30,7 +30,7 @@ void main() | |||
pass_p[6] = p2 + vec2( 0, k); | |||
pass_p[7] = p2 + vec2( k, k); | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
@@ -5,7 +5,7 @@ | |||
#version 120 | |||
attribute vec2 in_position; | |||
attribute vec2 in_Position; | |||
uniform vec2 in_screen_res; | |||
@@ -13,8 +13,8 @@ varying vec2 pass_position; | |||
void main() | |||
{ | |||
pass_position = ((vec2(1.0) + in_position) * 0.5 * in_screen_res); | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
pass_position = ((vec2(1.0) + in_Position) * 0.5 * in_screen_res); | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
@@ -61,9 +61,9 @@ void GpuShaderData::AddUniform(const lol::String &new_uniform) | |||
} | |||
//----------------------------------------------------------------------------- | |||
void GpuShaderData::AddAttribute(const lol::String &new_attribute, VertexUsage usage, int index) | |||
void GpuShaderData::AddAttribute(VertexUsage usage, int index) | |||
{ | |||
m_shader_attrib.Push(new_attribute, m_shader->GetAttribLocation(new_attribute.C(), usage, index)); | |||
m_shader_attrib.Push(m_shader->GetAttribLocation(usage, index)); | |||
} | |||
//----------------------------------------------------------------------------- | |||
@@ -76,11 +76,11 @@ ShaderUniform const *GpuShaderData::GetUniform(const lol::String &uniform) | |||
} | |||
//----------------------------------------------------------------------------- | |||
ShaderAttrib const *GpuShaderData::GetAttribute(const lol::String &attribute) | |||
ShaderAttrib const *GpuShaderData::GetAttribute(VertexUsage usage, int index) | |||
{ | |||
for (int i = 0; i < m_shader_attrib.Count(); ++i) | |||
if (m_shader_attrib[i].m1 == attribute) | |||
return &m_shader_attrib[i].m2; | |||
if (m_shader_attrib[i].GetUsage() == usage && m_shader_attrib[i].GetIndex() == index) | |||
return &m_shader_attrib[i]; | |||
return nullptr; | |||
} | |||
@@ -198,10 +198,10 @@ void GpuEasyMeshData::AddGpuData(GpuShaderData* gpudata, EasyMesh* src_mesh) | |||
ASSERT(!vflags, "Vertex Usage setup is not implemented for %s, feel free to do so.", | |||
VertexUsage::GetNameList(vflags).C()); | |||
if (has_position) gpudata->AddAttribute(gpudata->GetInVertexName(), VertexUsage::Position, 0); | |||
if (has_normal) gpudata->AddAttribute(gpudata->GetInNormalName(), VertexUsage::Normal, 0); | |||
if (has_color) gpudata->AddAttribute(gpudata->GetInColorName(), VertexUsage::Color, 0); | |||
if (has_texcoord) gpudata->AddAttribute(gpudata->GetInTexCoordName(), VertexUsage::TexCoord, 0); | |||
if (has_position) gpudata->AddAttribute(VertexUsage::Position, 0); | |||
if (has_normal) gpudata->AddAttribute(VertexUsage::Normal, 0); | |||
if (has_color) gpudata->AddAttribute(VertexUsage::Color, 0); | |||
if (has_texcoord) gpudata->AddAttribute(VertexUsage::TexCoord, 0); | |||
SetupVertexData(gpudata->m_vert_decl_flags, src_mesh); | |||
@@ -408,10 +408,10 @@ void GpuEasyMeshData::RenderMeshData(mat4 const &model) | |||
int idx = 0; | |||
ShaderAttrib Attribs[4] = { lol::ShaderAttrib(), lol::ShaderAttrib(), lol::ShaderAttrib(), lol::ShaderAttrib() }; | |||
if (has_position) Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInVertexName()); | |||
if (has_normal) Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInNormalName()); | |||
if (has_color) Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInColorName()); | |||
if (has_texcoord) Attribs[idx++] = *gpu_sd.GetAttribute(gpu_sd.GetInTexCoordName()); | |||
if (has_position) Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::Position, 0); | |||
if (has_normal) Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::Normal, 0); | |||
if (has_color) Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::Color, 0); | |||
if (has_texcoord) Attribs[idx++] = *gpu_sd.GetAttribute(VertexUsage::TexCoord, 0); | |||
vdecl->SetStream(vbo, Attribs[0], Attribs[1], Attribs[2], Attribs[3]); | |||
@@ -77,23 +77,19 @@ public: | |||
virtual ~GpuShaderData(); | |||
//-- | |||
void AddUniform(const lol::String &new_uniform); | |||
void AddAttribute(const lol::String &new_attribute, VertexUsage usage, int index); | |||
void AddAttribute(VertexUsage usage, int index); | |||
ShaderUniform const *GetUniform(const lol::String &uniform); | |||
ShaderAttrib const *GetAttribute(const lol::String &attribute); | |||
ShaderAttrib const *GetAttribute(VertexUsage usage, int index); | |||
//-- | |||
virtual void SetupShaderDatas(mat4 const &model) { UNUSED(model); } | |||
//-- | |||
virtual lol::String GetInVertexName() { return lol::String("in_Vertex"); } | |||
virtual lol::String GetInNormalName() { return lol::String("in_Normal"); } | |||
virtual lol::String GetInColorName() { return lol::String("in_Color"); } | |||
virtual lol::String GetInTexCoordName() { return lol::String("in_TexCoord"); } | |||
protected: | |||
uint16_t m_vert_decl_flags; | |||
Shader* m_shader; | |||
DebugRenderMode m_render_mode; | |||
Array<lol::String, ShaderUniform> m_shader_uniform; | |||
Array<lol::String, ShaderAttrib> m_shader_attrib; | |||
Array<ShaderAttrib> m_shader_attrib; | |||
}; | |||
class DefaultShaderData : public GpuShaderData | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
@@ -17,7 +17,7 @@ varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); | |||
vec4 vertex = in_ModelView * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(in_NormalMat * in_Normal); | |||
pass_Vertex = vertex; | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
attribute vec2 in_Index; | |||
@@ -21,7 +21,7 @@ varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); | |||
vec4 vertex = in_ModelView * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(in_NormalMat * in_Normal); | |||
pass_Vertex = vertex; | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
attribute vec2 in_TexCoord; | |||
@@ -19,7 +19,7 @@ varying vec2 pass_TexCoord; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); | |||
vec4 vertex = in_ModelView * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(in_NormalMat * in_Normal); | |||
pass_Vertex = vertex; | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
@@ -17,7 +17,7 @@ varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); | |||
vec4 vertex = in_ModelView * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(in_NormalMat * in_Normal); | |||
pass_Vertex = vertex; | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
@@ -17,7 +17,7 @@ varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); | |||
vec4 vertex = in_ModelView * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(in_Normal); | |||
pass_Vertex = vertex; | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
@@ -17,7 +17,7 @@ varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); | |||
vec4 vertex = in_ModelView * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(in_NormalMat * in_Normal); | |||
pass_Vertex = vertex; | |||
@@ -39,6 +39,24 @@ using namespace std; | |||
namespace lol | |||
{ | |||
static const char* attribute_names[] = { | |||
"in_Position", | |||
"in_BlendWeight", | |||
"in_BlendIndices", | |||
"in_Normal", | |||
"in_PointSize", | |||
"in_TexCoord", | |||
"in_TexCoordExt", | |||
"in_Tangent", | |||
"in_Binormal", | |||
"in_TessFactor", | |||
"in_PositionT", | |||
"in_Color", | |||
"in_Fog", | |||
"in_Depth", | |||
"in_Sample" | |||
}; | |||
/* | |||
* Shader implementation class | |||
*/ | |||
@@ -61,7 +79,7 @@ private: | |||
#elif !defined __CELLOS_LV2__ | |||
GLuint prog_id, vert_id, frag_id; | |||
// Benlitz: using a simple array could be faster since there is never more than a few attribute locations to store | |||
Map<String, GLint> attrib_locations; | |||
Map<uint64_t, GLint> attrib_locations; | |||
#else | |||
CGprogram vert_id, frag_id; | |||
#endif | |||
@@ -322,12 +340,68 @@ Shader::Shader(char const *vert, char const *frag) | |||
{ | |||
Log::Debug("link log for program: %s", errbuf); | |||
} | |||
GLint validated; | |||
glValidateProgram(data->prog_id); | |||
glGetProgramiv(data->prog_id, GL_VALIDATE_STATUS, &validated); | |||
if (validated != GL_TRUE) | |||
{ | |||
Log::Error("failed to validate program"); | |||
} | |||
GLint num_attribs; | |||
glGetProgramiv(data->prog_id, GL_ACTIVE_ATTRIBUTES, &num_attribs); | |||
GLint max_len; | |||
glGetProgramiv(data->prog_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_len); | |||
char* name_buffer = new char[max_len]; | |||
for (int i = 0; i < num_attribs; ++i) | |||
{ | |||
int attrib_len; | |||
int attrib_size; | |||
int attrib_type; | |||
glGetActiveAttrib(data->prog_id, i, max_len, &attrib_len, (GLint*)&attrib_size, (GLenum*)&attrib_type, name_buffer); | |||
String name(name_buffer); | |||
int index = 0; | |||
VertexUsage usage = VertexUsage::Max; | |||
for (int j = 0; j < VertexUsage::Max; ++j) | |||
{ | |||
if (name.StartsWith(attribute_names[j])) | |||
{ | |||
usage = VertexUsage(j); | |||
char* idx_ptr = name.C() + strlen(attribute_names[j]); | |||
index = strtol(idx_ptr, nullptr, 10); | |||
break; | |||
} | |||
} | |||
if (usage == VertexUsage::Max || index == LONG_MIN || index == LONG_MAX) | |||
{ | |||
Log::Error("unable to parse attribute sementic from name: %s", name_buffer); | |||
} | |||
else | |||
{ | |||
GLint location = glGetAttribLocation(data->prog_id, name_buffer); | |||
uint64_t flags = (uint64_t)(uint16_t)usage << 16; | |||
flags |= (uint64_t)(uint16_t)index; | |||
// TODO: this is here just in case. Remove this once everything has been correctly tested | |||
#ifdef _DEBUG | |||
if (data->attrib_locations.HasKey(flags)) | |||
{ | |||
Log::Error("an error occured while parsing attribute sementics"); | |||
} | |||
#endif | |||
data->attrib_locations[flags] = location; | |||
} | |||
} | |||
delete[] name_buffer; | |||
#endif | |||
} | |||
ShaderAttrib Shader::GetAttribLocation(char const *attr, | |||
VertexUsage usage, int index) const | |||
ShaderAttrib Shader::GetAttribLocation(VertexUsage usage, int index) const | |||
{ | |||
ShaderAttrib ret; | |||
ret.m_flags = (uint64_t)(uint16_t)usage << 16; | |||
@@ -336,17 +410,9 @@ ShaderAttrib Shader::GetAttribLocation(char const *attr, | |||
#elif !defined __CELLOS_LV2__ | |||
GLint l; | |||
if (!data->attrib_locations.TryGetValue(attr, l)) | |||
if (!data->attrib_locations.TryGetValue(ret.m_flags, l)) | |||
{ | |||
l = glGetAttribLocation(data->prog_id, attr); | |||
if (l < 0) | |||
{ | |||
Log::Warn("tried to query invalid attribute: %s\n", attr); | |||
} | |||
else | |||
{ | |||
data->attrib_locations[String(attr)] = l; | |||
} | |||
Log::Error("queried attribute is unavailable for this shader"); | |||
} | |||
ret.m_flags |= (uint64_t)(uint32_t)l << 32; | |||
#else | |||
@@ -70,10 +70,10 @@ technique Foo | |||
#version 120 | |||
/* Valid with my GLSL compiler */ | |||
//#pragma lolfx semantic(in_Vertex, POSITION) | |||
//#pragma lolfx semantic(in_Position, POSITION) | |||
//#pragma lolfx semantic(in_Normal, NORMAL) | |||
//#pragma lolfx semantic(in_Color, COLOR) | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
@@ -88,8 +88,8 @@ void Gradient::TickDraw(float seconds) | |||
ShaderUniform uni_mat; | |||
ShaderAttrib attr_pos, attr_col; | |||
attr_pos = data->shader->GetAttribLocation("in_Vertex", VertexUsage::Position, 0); | |||
attr_col = data->shader->GetAttribLocation("in_Color", VertexUsage::Color, 0); | |||
attr_pos = data->shader->GetAttribLocation(VertexUsage::Position, 0); | |||
attr_col = data->shader->GetAttribLocation(VertexUsage::Color, 0); | |||
data->shader->Bind(); | |||
@@ -2,7 +2,7 @@ | |||
#version 130 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec4 in_Color; | |||
varying vec4 pass_Color; | |||
@@ -13,7 +13,7 @@ uniform mat4 model_matrix; | |||
void main() | |||
{ | |||
gl_Position = proj_matrix * view_matrix * model_matrix | |||
* vec4(in_Vertex, 1.0); | |||
* vec4(in_Position, 1.0); | |||
pass_Color = in_Color; | |||
} | |||
@@ -157,8 +157,7 @@ public: | |||
static Shader *Create(char const *lolfx); | |||
static void Destroy(Shader *shader); | |||
ShaderAttrib GetAttribLocation(char const *attr, struct VertexUsage usage, | |||
int index) const; | |||
ShaderAttrib GetAttribLocation(struct VertexUsage usage, int index) const; | |||
ShaderUniform GetUniformLocation(char const *uni) const; | |||
void SetUniform(ShaderUniform const &uni, int i); | |||
@@ -202,8 +202,8 @@ void Scene::RenderTiles() // XXX: rename to Blit() | |||
ShaderUniform uni_mat, uni_tex, uni_texsize; | |||
ShaderAttrib attr_pos, attr_tex; | |||
attr_pos = data->m_tile_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); | |||
attr_tex = data->m_tile_shader->GetAttribLocation("in_TexCoord", VertexUsage::TexCoord, 0); | |||
attr_pos = data->m_tile_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
attr_tex = data->m_tile_shader->GetAttribLocation(VertexUsage::TexCoord, 0); | |||
data->m_tile_shader->Bind(); | |||
@@ -307,8 +307,8 @@ void Scene::RenderLines() // XXX: rename to Blit() | |||
ShaderUniform uni_mat, uni_tex; | |||
ShaderAttrib attr_pos, attr_col; | |||
attr_pos = data->m_line_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); | |||
attr_col = data->m_line_shader->GetAttribLocation("in_Color", VertexUsage::Color, 0); | |||
attr_pos = data->m_line_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
attr_col = data->m_line_shader->GetAttribLocation(VertexUsage::Color, 0); | |||
data->m_line_shader->Bind(); | |||
@@ -2,9 +2,9 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_vertex; | |||
attribute vec4 in_color; | |||
attribute vec4 in_texcoord; | |||
attribute vec3 in_Position; | |||
attribute vec4 in_Color; | |||
attribute vec4 in_TexCoord; | |||
uniform mat4 in_model_view; | |||
uniform mat3 in_normal_mat; | |||
@@ -16,9 +16,9 @@ varying vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_model_view * vec4(in_vertex - vec3(0.0,0.5,0.0), 1.0); | |||
vec4 vertex = in_model_view * vec4(in_Position - vec3(0.0,0.5,0.0), 1.0); | |||
vec3 v_offset = vec3(1.0 * in_texcoord.z, -1.0 * in_texcoord.w, 0.0); | |||
vec3 v_offset = vec3(1.0 * in_TexCoord.z, -1.0 * in_TexCoord.w, 0.0); | |||
float sinX = sin(in_sprite_orientation); | |||
float cosX = cos(in_sprite_orientation); | |||
@@ -31,8 +31,8 @@ void main(void) | |||
vertex.xyz += v_offset; | |||
//pass datas | |||
pass_texcoord = in_texcoord; | |||
pass_color = in_color; | |||
pass_texcoord = in_TexCoord; | |||
pass_color = in_Color; | |||
gl_Position = in_proj * vertex; | |||
} | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
@@ -18,7 +18,7 @@ varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
vec4 vertex = vec4(in_Vertex + (in_Normal * in_Damage), 1.0); | |||
vec4 vertex = vec4(in_Position + (in_Normal * in_Damage), 1.0); | |||
float dam_perc = in_Damage / (0.1 * 40); | |||
vec3 vGravity = vec3(0.0, -0.981, 0.0) * 2.0; | |||
float k = pow(dam_perc, 3); | |||
@@ -2,7 +2,7 @@ | |||
[vert.glsl] | |||
#version 120 | |||
attribute vec3 in_Vertex; | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
attribute vec2 in_TexCoord; | |||
@@ -19,7 +19,7 @@ varying vec2 pass_TexCoord; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_ModelView * vec4(in_Vertex, 1.0); | |||
vec4 vertex = in_ModelView * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(in_NormalMat * in_Normal); | |||
pass_Vertex = vertex; | |||