added alpha blending for image and text, nodes position are clamped to be integer
This commit is contained in:
@@ -84,7 +84,7 @@
|
||||
<!-- status bar -->
|
||||
<border height="30" width="100%" color=".15" border-color=".3" dir="row" pad="0 0 0 10" align="center">
|
||||
<text text="Status Bar: nothing to show here." font-face="arial" font-size="11"/>
|
||||
<text text="#fuckunity #fromscratch" font-face="arial" font-size="11" margin="0 0 0 10" color=".2 .5 1 1"/>
|
||||
<text text="#opengl #fromscratch" font-face="arial" font-size="11" margin="0 0 0 10" color=".2 .5 1 1"/>
|
||||
</border>
|
||||
</node>
|
||||
</layout>
|
||||
|
||||
@@ -89,7 +89,8 @@ void App::init()
|
||||
"in vec2 uv;"
|
||||
"out vec4 frag;"
|
||||
"void main(){"
|
||||
" frag = vec4(texture(tex, uv).r * col.rgb, col.a);"
|
||||
" float a = texture(tex, uv).r;"
|
||||
" frag = vec4(col.rgb, a);"
|
||||
"}";
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -141,7 +142,10 @@ void App::init()
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glPointSize(5);
|
||||
glLineWidth(2);
|
||||
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
//int n;
|
||||
//glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
//for (int i = 0; i < n; i++)
|
||||
|
||||
@@ -46,8 +46,8 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj)
|
||||
if (m_widget)
|
||||
{
|
||||
glm::mat4 pivot = glm::translate(glm::vec3(.5f, .5f, 0.f));
|
||||
glm::mat4 scale = glm::scale(glm::vec3(m_size, 1.f));
|
||||
glm::mat4 pos = glm::translate(glm::vec3(m_pos, 0));
|
||||
glm::mat4 scale = glm::scale(glm::vec3(glm::ceil(m_size), 1.f));
|
||||
glm::mat4 pos = glm::translate(glm::vec3(glm::floor(m_pos), 0));
|
||||
m_widget->mvp = proj * pos * scale * pivot;
|
||||
m_widget->pos = pos;
|
||||
m_widget->scale = scale;
|
||||
|
||||
@@ -253,7 +253,9 @@ public:
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||
ShaderManager::u_vec4(kShaderUniform::Col, m_color);
|
||||
glEnable(GL_BLEND);
|
||||
m_text_mesh.draw();
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override
|
||||
{
|
||||
@@ -323,6 +325,7 @@ public:
|
||||
{
|
||||
TextureManager::get(m_id).bind();
|
||||
m_sampler.bind(0);
|
||||
glEnable(GL_BLEND);
|
||||
if (m_use_atlas)
|
||||
{
|
||||
ShaderManager::use(kShader::Atlas);
|
||||
@@ -338,6 +341,7 @@ public:
|
||||
m_plane.draw_fill();
|
||||
m_sampler.unbind();
|
||||
TextureManager::get(m_id).unbind();
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
virtual void parse_attributes(kAttribute id, const tinyxml2::XMLAttribute* attr) override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user