added image widget with atlas support and global texture manager
This commit is contained in:
@@ -38,6 +38,26 @@ void App::init()
|
||||
"void main(){"
|
||||
" frag = vec4(uv.xy,0,1);"
|
||||
"}";
|
||||
static const char* shader_atlas_v =
|
||||
"#version 150\n"
|
||||
"uniform mat4 mvp;"
|
||||
"uniform vec2 tof;"
|
||||
"uniform vec2 tsz;"
|
||||
"in vec2 pos;"
|
||||
"in vec2 uvs;"
|
||||
"out vec2 uv;"
|
||||
"void main(){"
|
||||
" uv = tof + uvs * tsz;"
|
||||
" gl_Position = mvp * vec4(pos, 0, 1);"
|
||||
"}";
|
||||
static const char* shader_atlas_f =
|
||||
"#version 150\n"
|
||||
"uniform sampler2D tex;"
|
||||
"in vec2 uv;"
|
||||
"out vec4 frag;"
|
||||
"void main(){"
|
||||
" frag = texture(tex, uv);"
|
||||
"}";
|
||||
static const char* shader_color_v =
|
||||
"#version 150\n"
|
||||
"uniform mat4 mvp;"
|
||||
@@ -99,7 +119,7 @@ void App::init()
|
||||
const char* ttf = "/Library/Fonts/Arial.ttf";
|
||||
#endif
|
||||
FontManager::init();
|
||||
FontManager::load(kFont::Arial_11, ttf, 13);
|
||||
FontManager::load(kFont::Arial_11, ttf, 15);
|
||||
FontManager::load(kFont::Arial_30, ttf, 30);
|
||||
|
||||
layout.load("data/layout.xml");
|
||||
@@ -110,7 +130,9 @@ void App::init()
|
||||
ShaderManager::create(kShader::Color, shader_color_v, shader_color_f);
|
||||
ShaderManager::create(kShader::UVs, shader_v, shader_uv_f);
|
||||
ShaderManager::create(kShader::Font, shader_font_v, shader_font_f);
|
||||
WidgetBorder::m_plane.create<1>(1, 1);
|
||||
ShaderManager::create(kShader::Atlas, shader_atlas_v, shader_atlas_f);
|
||||
WidgetBorder::init();
|
||||
WidgetImage::init();
|
||||
|
||||
if (!tex.load("data/uvs.jpg"))
|
||||
printf("error loading image\n");
|
||||
|
||||
Reference in New Issue
Block a user