add Slice9 type
This commit is contained in:
@@ -6,7 +6,7 @@ App App::I; // singleton
|
||||
void App::create()
|
||||
{
|
||||
width = 800;
|
||||
height = 600;
|
||||
height = 800;
|
||||
}
|
||||
|
||||
void App::init()
|
||||
@@ -27,7 +27,7 @@ void App::init()
|
||||
"in vec2 uv;"
|
||||
"out vec4 frag;"
|
||||
"void main(){"
|
||||
" frag = texture(tex, uv, 0.0);"
|
||||
" frag = texture(tex, uv);"
|
||||
"}";
|
||||
static const char* shader_uv_f =
|
||||
"#version 150\n"
|
||||
@@ -55,12 +55,11 @@ void App::init()
|
||||
shader_color.create(shader_color_v, shader_color_f);
|
||||
shader_uv.create(shader_v, shader_uv_f);
|
||||
plane.create<5>(50, 50);
|
||||
longPlane.create<1>(50, 25);
|
||||
circle.create<6>(25, 12);
|
||||
circle1.create<4>(25, 12);
|
||||
circle.create<6>(25);
|
||||
circle2.create<15>(25, 12);
|
||||
rounded.create<5>(50, 50, 10);
|
||||
if (!tex.load("data/image.png"))
|
||||
rounded.create<3>(50, 50, 10);
|
||||
slice.create(50, 50, 10);
|
||||
if (!tex.load("data/uvs.jpg"))
|
||||
printf("error loading image\n");
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
@@ -97,49 +96,46 @@ void App::update(float dt)
|
||||
|
||||
glm::mat4 proj = glm::ortho<float>(0, width, height, 0, -1, 1);
|
||||
|
||||
Shape* shapes[] = { &circle, &circle1, &circle2, &plane, &longPlane };
|
||||
Shape* shapes[] = { &circle, &circle2, &plane, &rounded, &slice };
|
||||
|
||||
//glClearColor(red, 0, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
auto s = glm::scale(glm::vec3(2));
|
||||
// for (int i = 0; i < 5; i++)
|
||||
// {
|
||||
// shader.use();
|
||||
//
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
// glActiveTexture(GL_TEXTURE0);
|
||||
// tex.bind();
|
||||
// shader.u_int("tex", 0);
|
||||
// shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 1, 75 + 120 * i, 0.f}) * s);
|
||||
// shapes[i]->draw_fill();
|
||||
// tex.unbind();
|
||||
//
|
||||
// shader_color.use();
|
||||
// shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 2, 75 + 120 * i, 0.f}) * s);
|
||||
// shader_color.u_vec4("col", {1, 1, 1, 1});
|
||||
// shapes[i]->draw_stroke();
|
||||
//
|
||||
// shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 0, 75 + 120 * i, 0.f}) * s);
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
// shapes[i]->draw_fill();
|
||||
//
|
||||
// shader_uv.use();
|
||||
// shader_uv.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 3, 75 + 120 * i, 0.f}) * s);
|
||||
// shader_uv.u_int("tex", 0);
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
// shapes[i]->draw_fill();
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
// shader_uv.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 4, 75 + 120 * i, 0.f}) * s);
|
||||
// shapes[i]->draw_fill();
|
||||
// tex.unbind();
|
||||
// }
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
shader_uv.use();
|
||||
shader_uv.u_mat4("mvp", proj * glm::translate(glm::vec3{width/2, height/2, 0.f}) * glm::scale(glm::vec3(10)));
|
||||
shader_uv.u_int("tex", 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
tex.bind();
|
||||
rounded.draw_fill();
|
||||
tex.unbind();
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
shader.use();
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
tex.bind();
|
||||
shader.u_int("tex", 0);
|
||||
shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 1, 75 + 120 * i, 0.f}) * s);
|
||||
shapes[i]->draw_fill();
|
||||
tex.unbind();
|
||||
|
||||
shader_color.use();
|
||||
shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 2, 75 + 120 * i, 0.f}) * s);
|
||||
shader_color.u_vec4("col", {1, 1, 1, 1});
|
||||
shapes[i]->draw_stroke();
|
||||
|
||||
shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 0, 75 + 120 * i, 0.f}) * s);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
shapes[i]->draw_fill();
|
||||
|
||||
shader_uv.use();
|
||||
shader_uv.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 3, 75 + 120 * i, 0.f}) * s);
|
||||
shader_uv.u_int("tex", 0);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
shapes[i]->draw_fill();
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
shader_uv.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + 120 * 4, 75 + 120 * i, 0.f}) * s);
|
||||
shapes[i]->draw_fill();
|
||||
tex.unbind();
|
||||
}
|
||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
// shader_color.use();
|
||||
// shader_color.u_mat4("mvp", proj * glm::translate(glm::vec3{width/2, height/2, 0.f}) * glm::scale(glm::vec3(8)));
|
||||
// shader_color.u_vec4("col", {1, 1, 1, 1});
|
||||
// slice.draw_fill();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user