Some fixes

This commit is contained in:
Vincent Lejeune 2014-10-17 18:43:39 +02:00
parent f67f207d4b
commit ce7f017adf
4 changed files with 52 additions and 5 deletions

View File

@ -0,0 +1,27 @@
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord;
layout(location = 5) in vec3 Tangent;
layout(location = 6) in vec3 Bitangent;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
in vec2 SecondTexcoord;
in vec3 Tangent;
in vec3 Bitangent;
#endif
out vec2 uv;
out vec4 color;
void main(void)
{
color = Color.zyxw;
gl_Position = vec4(Position, 1.) / vec4(screen, 1., 1.);
uv = Texcoord;
}

View File

@ -665,21 +665,24 @@ void draw2DVertexPrimitiveList(const void* vertices,
return;
}
GLuint tmpvao, tmpvbo, tmpibo;
primitiveCount += 2;
glGenVertexArrays(1, &tmpvao);
glBindVertexArray(tmpvao);
glGenBuffers(1, &tmpvbo);
glBindBuffer(GL_ARRAY_BUFFER, tmpvbo);
glBufferData(GL_ARRAY_BUFFER, vertexCount * getVertexPitchFromType(vType), vertices, GL_STREAM_DRAW);
glGenBuffers(1, &tmpibo);
glBindBuffer(GL_ARRAY_BUFFER, tmpibo);
glBufferData(GL_ARRAY_BUFFER, primitiveCount * sizeof(u16), indexList, GL_STREAM_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tmpibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, primitiveCount * sizeof(u16), indexList, GL_STREAM_DRAW);
glUseProgram(MeshShader::TransparentShader::getInstance()->Program);
MeshShader::TransparentShader::getInstance()->setUniforms(core::IdentityMatrix, core::IdentityMatrix);
VertexUtils::bindVertexArrayAttrib(vType);
glUseProgram(UIShader::Primitive2DList::getInstance()->Program);
UIShader::Primitive2DList::getInstance()->setUniforms();
const video::SOverrideMaterial &m = irr_driver->getVideoDriver()->getOverrideMaterial();
video::ITexture* tex = getUnicolorTexture(video::SColor(255, 255, 255, 255));
compressTexture(tex, false);
MeshShader::TransparentShader::getInstance()->SetTextureUnits({ getTextureGLuint(tex) });
UIShader::Primitive2DList::getInstance()->SetTextureUnits({ getTextureGLuint(tex) });
glDrawElements(GL_TRIANGLE_FAN, primitiveCount, GL_UNSIGNED_SHORT, 0);
glDeleteVertexArrays(1, &tmpvao);

View File

@ -1749,6 +1749,16 @@ namespace FullScreenShader
namespace UIShader
{
Primitive2DList::Primitive2DList()
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/primitive2dlist.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str());
AssignUniforms();
AssignSamplerNames(Program, 0, "tex");
}
TextureRectShader::TextureRectShader()
{
Program = LoadProgram(OBJECT,

View File

@ -580,6 +580,13 @@ public:
namespace UIShader
{
class Primitive2DList : public ShaderHelperSingleton<Primitive2DList>, public TextureRead < Bilinear_Filtered >
{
public:
Primitive2DList();
};
class TextureRectShader : public ShaderHelperSingleton<TextureRectShader, core::vector2df, core::vector2df, core::vector2df, core::vector2df>, public TextureRead<Bilinear_Filtered>
{
public: