add shader strings for open gl

This commit is contained in:
2024-09-30 15:46:19 +01:00
parent c37c8d60e3
commit ae8005dceb
6 changed files with 41 additions and 8 deletions

View File

@@ -7,7 +7,6 @@
unsigned int VERTEX_SHADER = GL_VERTEX_SHADER;
unsigned int FRAGMENT_SHADER = GL_FRAGMENT_SHADER;
unsigned int TRIANGLES = GL_TRIANGLES;
unsigned int TRIANGLE_FAN = GL_TRIANGLE_FAN;
unsigned int STATIC_DRAW = GL_STATIC_DRAW;
unsigned int DYNAMIC_DRAW = GL_DYNAMIC_DRAW;

View File

@@ -10,16 +10,23 @@ struct
(* OpenGL constants used. *)
val (VERTEX_SHADER, _) =
_symbol "VERTEX_SHADER" public : ( unit -> shader_type ) * ( shader_type -> unit );
val VERTEX_SHADER = VERTEX_SHADER ()
val (FRAGMENT_SHADER, _) =
_symbol "FRAGMENT_SHADER" public : ( unit -> shader_type ) * ( shader_type -> unit );
val FRAGMENT_SHADER = FRAGMENT_SHADER ()
val (TRIANGLES, _) =
_symbol "TRIANGLES" public : ( unit -> draw_mode ) * ( draw_mode -> unit );
val (TRIANGLE_FAN, _) =
_symbol "TRIANGLE_FAN" public : ( unit -> draw_mode ) * ( draw_mode -> unit );
val TRIANGLES = TRIANGLES ()
val (STATIC_DRAW, _) =
_symbol "STATIC_DRAW" public : ( unit -> update_mode ) * ( update_mode -> unit );
val STATIC_DRAW = STATIC_DRAW ()
val (DYNAMIC_DRAW, _) =
_symbol "DYNAMIC_DRAW" public : ( unit -> update_mode ) * ( update_mode -> unit );
val DYNAMIC_DRAW = DYNAMIC_DRAW ()
(* OpenGL functions used. *)
val loadGlad = _import "loadGlad" public : unit -> unit;
@@ -44,15 +51,13 @@ struct
val attachShader = _import "attachShader" public : program * shader -> unit;
val linkProgram = _import "linkProgram" public : program -> unit;
val useProgram = _import "useProgram" public : program -> unit;
val deleteShader = _import "deleteShader" public : program -> unit;
val deleteProgram = _import "deleteProgram" public : program -> unit;
val clearColor =
_import "clearColor" public : Real32.real * Real32.real * Real32.real * Real32.real -> unit;
val clear = _import "clear" public : unit -> unit;
val drawArrays = _import "drawArrays" public : draw_mode * int * int -> unit;
val getUniformLocation =
_import "getUniformLocation" public : program * string -> int;
val uniform4f =
_import "uniform4f" public : int * Real32.real * Real32.real * Real32.real * Real32.real -> unit;
val drawArrays = _import "drawArrays" public : draw_mode * int * int -> unit;
end

View File

@@ -5,8 +5,13 @@ struct
(* Constants. *)
val (PRESS, _) =
_symbol "PRESS" public : ( unit -> int ) * ( int -> unit );
val PRESS = PRESS ()
val (REPEAT, _) =
_symbol "REPEAT" public : ( unit -> int ) * ( int -> unit );
val REPEAT = REPEAT ()
val (RELEASE, _) =
_symbol "RELEASE" public : ( unit -> int ) * ( int -> unit );
val RELEASE = RELEASE ()
end

23
shell/gl-shaders.sml Normal file
View File

@@ -0,0 +1,23 @@
structure GlShaders =
struct
val xyrgbVertexShaderString =
"#version 300 es\n\
\layout (location = 0) in vec2 apos;\n\
\layout (location = 1) in vec3 col;\n\
\out vec3 frag_col;\n\
\void main()\n\
\{\n\
\ frag_col = col;\n\
\ gl_Position = vec4(apos.x, apos.y, 0.0f, 1.0f);\n\
\}"
val rgbFragmentShaderString =
"#version 300 es\n\
\precision mediump float;\n\
\in vec3 frag_col;\n\
\out vec4 FragColor;\n\
\void main()\n\
\{\n\
\ FragColor = vec4(frag_col.x, frag_col.y, frag_col.z, 1.0f);\n\
\}"
end

BIN
shf

Binary file not shown.

View File

@@ -14,4 +14,5 @@ in
ffi/glfw-input.sml
end
shell/gl-shaders.sml
shell/shell.sml