All pastes #2112426 Raw Edit

Miscellany

public text v1 · immutable
#2112426 ·published 2012-02-08 14:31 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"
#ifndef __linux__
		"   gl_PointSize = 1.0;\n"
#endif
		"   gl_Position = projview_matrix * pos;\n"
		"}\n";



	static const char *main_pixel_source =
#ifdef IPHONE
	"precision mediump float;\n"
#endif
	"uniform bool use_tex;\n"
	"uniform sampler2D tex;\n"
	"uniform bool use_tex_matrix;\n"
	"uniform mat4 tex_matrix;\n"
	"varying lowp vec4 varying_color;\n"
	"varying vec2 varying_texcoord;\n"
	"void main()\n"
	"{\n"
	"  lowp 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"
	"     lowp vec4 sample = texture2D(tex, coord.st);\n"
	"     tmp *= sample;\n"
	"  }\n"
	"  else if (use_tex) {\n"
	"     lowp vec4 sample = texture2D(tex, coord.st);\n"
	"     tmp *= sample;\n"
	"  }\n"
	"  gl_FragColor = tmp;\n"
	"}\n";