Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 26m34s
Reviewed-on: #43
156 lines
5.3 KiB
GLSL
156 lines
5.3 KiB
GLSL
#version 120
|
|
// TODO this will fail if we don't have the extension.
|
|
#extension GL_ARB_instanced_arrays : enable
|
|
|
|
#define J2D_DrawPoint 1
|
|
#define J2D_DrawPoints 2
|
|
#define J2D_DrawLine 3
|
|
#define J2D_DrawLines 4
|
|
#define J2D_DrawDottedLine 5
|
|
#define J2D_DrawDashedLine 6
|
|
#define J2D_DrawGradientLine 7
|
|
#define J2D_OutlineRect 8
|
|
#define J2D_OutlineRoundedRect 9
|
|
#define J2D_OutlineChamferRect 10
|
|
#define J2D_FillRect 11
|
|
#define J2D_FillGradientRect 12
|
|
#define J2D_FillRoundedRect 13
|
|
#define J2D_FillChamferRect 14
|
|
#define J2D_DrawRenderTarget 15
|
|
#define J2D_DrawPartialRenderTarget 16
|
|
#define J2D_DrawSprite 17
|
|
#define J2D_DrawAlphaMaskSprite 18
|
|
#define J2D_DrawPartialSprite 19
|
|
#define J2D_DrawMirrorSprite 20
|
|
#define J2D_OutlineCircle 21
|
|
#define J2D_FillCircle 22
|
|
#define J2D_OutlineTriangle 23
|
|
#define J2D_FillTriangle 24
|
|
#define J2D_FillGradientTriangle 25
|
|
#define J2D_DrawCubicBezierCurve 26
|
|
#define J2D_OutlinePolygon 27
|
|
#define J2D_DrawString 28
|
|
#define J2D_DrawArc 29
|
|
|
|
uniform int JGL_RENDERING_ROUTINE;
|
|
uniform bool JGL_INSTANCED_RENDERING;
|
|
|
|
// The color manually set with glColor4f, glColor4ubv etc etc.
|
|
varying vec4 v_color;
|
|
|
|
// Local space vertices for instanced rendering.
|
|
attribute vec2 a_vertex_position; // 0
|
|
|
|
// The position at which to render the instance.
|
|
attribute vec2 a_instance_position; // 1
|
|
|
|
// The scale of the instance.
|
|
attribute vec2 a_instance_size; // 2
|
|
|
|
// The color of the instance.
|
|
attribute vec4 a_instance_color; // 3
|
|
|
|
// The texture coordinates in each texture unit.
|
|
varying vec2 GL_TEXTURE0_COORD;
|
|
varying vec2 GL_TEXTURE1_COORD;
|
|
varying vec2 GL_TEXTURE2_COORD;
|
|
varying vec2 GL_TEXTURE3_COORD;
|
|
varying vec2 GL_TEXTURE4_COORD;
|
|
varying vec2 GL_TEXTURE5_COORD;
|
|
varying vec2 GL_TEXTURE6_COORD;
|
|
varying vec2 GL_TEXTURE7_COORD;
|
|
|
|
vec4 Default() {
|
|
v_color = gl_Color;
|
|
return gl_ModelViewProjectionMatrix * gl_Vertex;
|
|
}
|
|
|
|
vec4 DefaultInstanced() {
|
|
v_color = a_instance_color;
|
|
vec2 scaled = a_vertex_position * a_instance_size;
|
|
vec2 world_pos = scaled + a_instance_position;
|
|
return gl_ModelViewProjectionMatrix * vec4(world_pos, 0.0, 1.0);
|
|
}
|
|
|
|
#include "shared.glsl"
|
|
|
|
void main() {
|
|
GL_TEXTURE0_COORD = gl_MultiTexCoord0.xy;
|
|
GL_TEXTURE1_COORD = gl_MultiTexCoord1.xy;
|
|
GL_TEXTURE2_COORD = gl_MultiTexCoord2.xy;
|
|
GL_TEXTURE3_COORD = gl_MultiTexCoord3.xy;
|
|
GL_TEXTURE4_COORD = gl_MultiTexCoord4.xy;
|
|
GL_TEXTURE5_COORD = gl_MultiTexCoord5.xy;
|
|
GL_TEXTURE6_COORD = gl_MultiTexCoord6.xy;
|
|
GL_TEXTURE7_COORD = gl_MultiTexCoord7.xy;
|
|
|
|
|
|
|
|
/* If you want behavior per JGL draw function, Or for specific ones. The order here matters because some JGL functions call others.
|
|
if (JGL_RENDERING_ROUTINE == J2D_DrawRenderTarget)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawPartialRenderTarget)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawAlphaMaskSprite)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawMirrorSprite)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawSprite)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawPartialSprite)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawPartialSprite)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawString)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawPoint)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawPoints)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawCubicBezierCurve)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawLine)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawLines)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawDottedLine)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawDashedLine)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawGradientLine)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_OutlineRoundedRect)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_FillChamferRect)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_FillRoundedRect)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_FillGradientRect)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_OutlineRect)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_FillRect)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_OutlineCircle)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_FillCircle)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_OutlineTriangle)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_FillTriangle)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_FillGradientTriangle)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_OutlinePolygon)
|
|
gl_Position = Default();
|
|
else if (JGL_RENDERING_ROUTINE == J2D_DrawArc)
|
|
gl_Position = Default();
|
|
else { gl_Position = Default(); }
|
|
*/
|
|
|
|
if (JGL_INSTANCED_RENDERING)
|
|
gl_Position = DefaultInstanced();
|
|
else
|
|
gl_Position = Default();
|
|
}
|