render target first impl

This commit is contained in:
2018-10-19 14:40:54 +07:00
parent da29a9e456
commit b732d423ce
13 changed files with 1194 additions and 255 deletions

View File

@@ -9,36 +9,38 @@ using namespace e2d;
namespace
{
const char* vs_source_cstr =
"#version 120 \n"
" \n"
"attribute vec3 a_position; \n"
"attribute vec2 a_uv; \n"
"attribute vec4 a_color; \n"
" \n"
"uniform mat4 u_MVP; \n"
" \n"
"varying vec4 v_color; \n"
"varying vec2 v_uv; \n"
" \n"
"void main(){ \n"
" v_color = a_color; \n"
" v_uv = a_uv; \n"
" \n"
" gl_Position = vec4(a_position, 1.0) * u_MVP; \n"
"} \n";
const char* vs_source_cstr = R"glsl(
#version 120
const char* fs_source_cstr =
"#version 120 \n"
" \n"
"uniform sampler2D u_texture; \n"
"varying vec4 v_color; \n"
"varying vec2 v_uv; \n"
" \n"
"void main(){ \n"
" vec2 uv = vec2(v_uv.s, 1.0 - v_uv.t); \n"
" gl_FragColor = v_color * texture2D(u_texture, uv); \n"
"} \n";
attribute vec3 a_position;
attribute vec2 a_uv;
attribute vec4 a_color;
uniform mat4 u_MVP;
varying vec4 v_color;
varying vec2 v_uv;
void main(){
v_color = a_color;
v_uv = a_uv;
gl_Position = vec4(a_position, 1.0) * u_MVP;
}
)glsl";
const char* fs_source_cstr = R"glsl(
#version 120
uniform sampler2D u_texture;
varying vec4 v_color;
varying vec2 v_uv;
void main(){
vec2 uv = vec2(v_uv.s, 1.0 - v_uv.t);
gl_FragColor = v_color * texture2D(u_texture, uv);
}
)glsl";
struct vertex1 {
v3f position;
@@ -182,7 +184,7 @@ int e2d_main() {
const auto indices = generate_cube_indices();
const auto index_buffer = the<render>().create_index_buffer(
buffer(indices.data(), indices.size() * sizeof(indices[0])),
index_declaration(index_declaration::index_type::unsigned_byte),
index_declaration::index_type::unsigned_byte,
index_buffer::usage::static_draw);
const auto vertices1 = generate_cube_vertices(make_vec3(1.f));