All pastes #2104647 Raw Edit

Miscellany

public text v1 · immutable
#2104647 ·published 2012-01-21 03:12 UTC
rendered paste body
static const char *default_vertex_source =
	"attribute vec4 pos;\n"
	"attribute vec4 color;\n"
	"attribute vec2 texcoord;\n"
	"uniform mat4 projview_matrix;\n"
	"varying vec4 varying_color;\n"
	"varying vec2 varying_texcoord;\n"
	"void main()\n"
	"{\n"
	"  varying_color = color;\n"
	"  varying_texcoord = texcoord;\n"
	"  gl_Position = projview_matrix * pos;\n"
	"}\n";

static const char *default_pixel_source =
	"precision mediump float;\n"
	"uniform bool use_tex;\n"
	"uniform sampler2D tex;\n"
	"uniform bool use_tex_matrix;\n"
	"uniform mat4 tex_matrix;\n"
	"varying vec4 varying_color;\n"
	"varying vec2 varying_texcoord;\n"
	"void main()\n"
	"{\n"
	"  vec4 tmp = varying_color;\n"
	"  vec4 coord = vec4(varying_texcoord, 0.0, 1.0);\n"
	"  if (use_tex_matrix) {\n"
	"     coord = coord * tex_matrix;\n"
	"     vec4 sample = texture2D(tex, coord.st);\n"
	"     tmp *= sample;\n"
	"  }\n"
	"  else if (use_tex) {\n"
	"     vec4 sample = texture2D(tex, coord.st);\n"
	"     tmp *= sample;\n"
	"  }\n"
	"  gl_FragColor = tmp;\n"
	"}\n";