Additional raw string shaders

This commit is contained in:
Henrik Rydgård 2018-12-18 10:42:29 +01:00
parent 637b6ce79a
commit a2cc2b39ca
2 changed files with 55 additions and 54 deletions

View file

@ -47,34 +47,33 @@
namespace DX9 {
static const char * vscode =
"struct VS_IN {\n"
" float4 ObjPos : POSITION;\n"
" float2 Uv : TEXCOORD0;\n"
"};"
"struct VS_OUT {\n"
" float4 ProjPos : POSITION;\n"
" float2 Uv : TEXCOORD0;\n"
"};\n"
"VS_OUT main( VS_IN In ) {\n"
" VS_OUT Out;\n"
" Out.ProjPos = In.ObjPos;\n"
" Out.Uv = In.Uv;\n"
" return Out;\n"
"}\n";
static const char *vscode = R"(
struct VS_IN {
float4 ObjPos : POSITION;
float2 Uv : TEXCOORD0;
};"
struct VS_OUT {
float4 ProjPos : POSITION;
float2 Uv : TEXCOORD0;
};
VS_OUT main( VS_IN In ) {
VS_OUT Out;
Out.ProjPos = In.ObjPos;
Out.Uv = In.Uv;
return Out;
};
)";
//--------------------------------------------------------------------------------------
// Pixel shader
//--------------------------------------------------------------------------------------
static const char * pscode =
"sampler s: register(s0);\n"
"struct PS_IN {\n"
" float2 Uv : TEXCOORD0;\n"
"};\n"
"float4 main( PS_IN In ) : COLOR {\n"
" float4 c = tex2D(s, In.Uv);\n"
" return c;\n"
"}\n";
static const char *pscode = R"(
sampler s: register(s0);
struct PS_IN {
float2 Uv : TEXCOORD0;
};
float4 main( PS_IN In ) : COLOR {
float4 c = tex2D(s, In.Uv);
return c;
};
)";
static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },

View file

@ -48,34 +48,36 @@
#include "GPU/GLES/DrawEngineGLES.h"
#include "GPU/GLES/ShaderManagerGLES.h"
static const char tex_fs[] =
"#if __VERSION__ >= 130\n"
"#define varying in\n"
"#define texture2D texture\n"
"#define gl_FragColor fragColor0\n"
"out vec4 fragColor0;\n"
"#endif\n"
"#ifdef GL_ES\n"
"precision mediump float;\n"
"#endif\n"
"uniform sampler2D sampler0;\n"
"varying vec2 v_texcoord0;\n"
"void main() {\n"
" gl_FragColor = texture2D(sampler0, v_texcoord0);\n"
"}\n";
static const char tex_fs[] = R"(
#if __VERSION__ >= 130
#define varying in
#define texture2D texture
#define gl_FragColor fragColor0
out vec4 fragColor0;
#endif
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D sampler0;
varying vec2 v_texcoord0;
void main() {
gl_FragColor = texture2D(sampler0, v_texcoord0);
}
)";
static const char basic_vs[] =
"#if __VERSION__ >= 130\n"
"#define attribute in\n"
"#define varying out\n"
"#endif\n"
"attribute vec4 a_position;\n"
"attribute vec2 a_texcoord0;\n"
"varying vec2 v_texcoord0;\n"
"void main() {\n"
" v_texcoord0 = a_texcoord0;\n"
" gl_Position = a_position;\n"
"}\n";
static const char basic_vs[] = R"(
#if __VERSION__ >= 130
#define attribute in
#define varying out
#endif
attribute vec4 a_position;
attribute vec2 a_texcoord0;
varying vec2 v_texcoord0;
void main() {
v_texcoord0 = a_texcoord0;
gl_Position = a_position;
}
)";
void FramebufferManagerGLES::CompileDraw2DProgram() {
if (!draw2dprogram_) {