2
0
Эх сурвалжийг харах

Add GL stencil functions and getParameter (#21)

Pascal Peridont 8 жил өмнө
parent
commit
316815a4fa

+ 3 - 0
libs/sdl/GLImports.h

@@ -7,6 +7,9 @@ GL_IMPORT(glGetUniformLocation, GETUNIFORMLOCATION);
 GL_IMPORT(glGetAttribLocation, GETATTRIBLOCATION);
 GL_IMPORT(glGetAttribLocation, GETATTRIBLOCATION);
 GL_IMPORT(glBlendFuncSeparate, BLENDFUNCSEPARATE);
 GL_IMPORT(glBlendFuncSeparate, BLENDFUNCSEPARATE);
 GL_IMPORT(glBlendEquationSeparate, BLENDEQUATIONSEPARATE);
 GL_IMPORT(glBlendEquationSeparate, BLENDEQUATIONSEPARATE);
+GL_IMPORT(glStencilMaskSeparate, STENCILMASKSEPARATE);
+GL_IMPORT(glStencilFuncSeparate, STENCILFUNCSEPARATE);
+GL_IMPORT(glStencilOpSeparate, STENCILOPSEPARATE);
 GL_IMPORT(glUseProgram, USEPROGRAM);
 GL_IMPORT(glUseProgram, USEPROGRAM);
 GL_IMPORT(glCreateShader, CREATESHADER);
 GL_IMPORT(glCreateShader, CREATESHADER);
 GL_IMPORT(glShaderSource, SHADERSOURCE);
 GL_IMPORT(glShaderSource, SHADERSOURCE);

+ 24 - 0
libs/sdl/gl.c

@@ -114,6 +114,11 @@ HL_PRIM void HL_NAME(gl_pixel_storei)( int key, int value ) {
 	glPixelStorei(key, value);
 	glPixelStorei(key, value);
 }
 }
 
 
+HL_PRIM vbyte *HL_NAME(gl_get_string)(int name) {
+	GLOG("%d", name);
+	return (vbyte*)glGetString(name);
+}
+
 // state changes
 // state changes
 
 
 HL_PRIM void HL_NAME(gl_enable)( int feature ) {
 HL_PRIM void HL_NAME(gl_enable)( int feature ) {
@@ -166,6 +171,21 @@ HL_PRIM void HL_NAME(gl_color_mask)( bool r, bool g, bool b, bool a ) {
 	glColorMask(r, g, b, a);
 	glColorMask(r, g, b, a);
 }
 }
 
 
+HL_PRIM void HL_NAME(gl_stencil_mask_separate)(int face, int mask) {
+	GLOG("%d,%d",face,mask);
+	glStencilMaskSeparate(face, mask);
+}
+
+HL_PRIM void HL_NAME(gl_stencil_func_separate)(int face, int func, int ref, int mask ) {
+	GLOG("%d,%d,%d,%d",face,func,ref,mask);
+	glStencilFuncSeparate(face, func, ref, mask);
+}
+
+HL_PRIM void HL_NAME(gl_stencil_op_separate)(int face, int sfail, int dpfail, int dppass) {
+	GLOG("%d,%d,%d,%d",face,sfail,dpfail,dppass);
+	glStencilOpSeparate(face, sfail, dpfail, dppass);
+}
+
 // program
 // program
 
 
 static vdynamic *alloc_i32(int v) {
 static vdynamic *alloc_i32(int v) {
@@ -484,6 +504,7 @@ DEFINE_PRIM(_VOID,gl_clear_stencil,_I32);
 DEFINE_PRIM(_VOID,gl_viewport,_I32 _I32 _I32 _I32);
 DEFINE_PRIM(_VOID,gl_viewport,_I32 _I32 _I32 _I32);
 DEFINE_PRIM(_VOID,gl_finish,_NO_ARG);
 DEFINE_PRIM(_VOID,gl_finish,_NO_ARG);
 DEFINE_PRIM(_VOID,gl_pixel_storei,_I32 _I32);
 DEFINE_PRIM(_VOID,gl_pixel_storei,_I32 _I32);
+DEFINE_PRIM(_BYTES,gl_get_string,_I32);
 DEFINE_PRIM(_VOID,gl_enable,_I32);
 DEFINE_PRIM(_VOID,gl_enable,_I32);
 DEFINE_PRIM(_VOID,gl_disable,_I32);
 DEFINE_PRIM(_VOID,gl_disable,_I32);
 DEFINE_PRIM(_VOID,gl_cull_face,_I32);
 DEFINE_PRIM(_VOID,gl_cull_face,_I32);
@@ -494,6 +515,9 @@ DEFINE_PRIM(_VOID,gl_blend_equation_separate,_I32 _I32);
 DEFINE_PRIM(_VOID,gl_depth_mask,_BOOL);
 DEFINE_PRIM(_VOID,gl_depth_mask,_BOOL);
 DEFINE_PRIM(_VOID,gl_depth_func,_I32);
 DEFINE_PRIM(_VOID,gl_depth_func,_I32);
 DEFINE_PRIM(_VOID,gl_color_mask,_BOOL _BOOL _BOOL _BOOL);
 DEFINE_PRIM(_VOID,gl_color_mask,_BOOL _BOOL _BOOL _BOOL);
+DEFINE_PRIM(_VOID,gl_stencil_mask_separate,_I32 _I32);
+DEFINE_PRIM(_VOID,gl_stencil_func_separate,_I32 _I32 _I32 _I32);
+DEFINE_PRIM(_VOID,gl_stencil_op_separate,_I32  _I32 _I32 _I32);
 DEFINE_PRIM(_NULL(_I32),gl_create_program,_NO_ARG);
 DEFINE_PRIM(_NULL(_I32),gl_create_program,_NO_ARG);
 DEFINE_PRIM(_VOID,gl_attach_shader,_NULL(_I32) _NULL(_I32));
 DEFINE_PRIM(_VOID,gl_attach_shader,_NULL(_I32) _NULL(_I32));
 DEFINE_PRIM(_VOID,gl_link_program,_NULL(_I32));
 DEFINE_PRIM(_VOID,gl_link_program,_NULL(_I32));

+ 23 - 0
libs/sdl/sdl/GL.hx

@@ -59,6 +59,20 @@ class GL {
 
 
 	public static function pixelStorei( key : Int, value : Int ) {
 	public static function pixelStorei( key : Int, value : Int ) {
 	}
 	}
+	
+	public static function getParameter( name : Int ) : Dynamic {
+		switch( name ){
+			case VENDOR, VERSION, RENDERER, SHADING_LANGUAGE_VERSION:
+				return @:privateAccess String.fromUTF8(getString(name));
+			case _:
+				throw "Not implemented";
+				return null;
+		}
+	}
+
+	static function getString( name : Int ) : hl.Bytes {
+		return null;
+	}
 
 
 	// state changes
 	// state changes
 
 
@@ -92,6 +106,15 @@ class GL {
 	public static function colorMask( r : Bool, g : Bool, b : Bool, a : Bool ) {
 	public static function colorMask( r : Bool, g : Bool, b : Bool, a : Bool ) {
 	}
 	}
 
 
+	public static function stencilMaskSeparate( face : Int, mask : Int ){
+	}
+
+	public static function stencilFuncSeparate( face : Int, func : Int, ref : Int, mask : Int ){
+	}
+
+	public static function stencilOpSeparate( face : Int, sfail : Int, dpfail : Int, dppas : Int ){
+	}
+
 	// program
 	// program
 
 
 	public static function createProgram() : Program {
 	public static function createProgram() : Program {