progress binding RGFW and making RGFW shell
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
mlton -const 'Exn.keepHistory true' -link-opt "-lX11 -lXrandr -lGL -lm" \
|
||||
mlton -const 'Exn.keepHistory true' -link-opt "-lX11 -lXrandr -lGL" \
|
||||
-export-header ffi/export.h \
|
||||
shf-tests.mlb \
|
||||
shf-rgfw.mlb \
|
||||
ffi/rgfw-export.c
|
||||
|
||||
25
ffi/export.h
25
ffi/export.h
@@ -1,5 +1,5 @@
|
||||
#ifndef __SHF_ML_H__
|
||||
#define __SHF_ML_H__
|
||||
#ifndef __SHF_RGFW_ML_H__
|
||||
#define __SHF_RGFW_ML_H__
|
||||
|
||||
/* Copyright (C) 2004-2007 Henry Cejtin, Matthew Fluet, Suresh
|
||||
* Jagannathan, and Stephen Weeks.
|
||||
@@ -132,23 +132,23 @@ typedef Pointer Objptr;
|
||||
|
||||
#endif /* _MLTON_EXPORT_H_ */
|
||||
|
||||
#if !defined(PART_OF_SHF) && \
|
||||
!defined(STATIC_LINK_SHF) && \
|
||||
!defined(DYNAMIC_LINK_SHF)
|
||||
#define PART_OF_SHF
|
||||
#if !defined(PART_OF_SHF_RGFW) && \
|
||||
!defined(STATIC_LINK_SHF_RGFW) && \
|
||||
!defined(DYNAMIC_LINK_SHF_RGFW)
|
||||
#define PART_OF_SHF_RGFW
|
||||
#endif
|
||||
|
||||
#if defined(PART_OF_SHF)
|
||||
#if defined(PART_OF_SHF_RGFW)
|
||||
#define MLLIB_PRIVATE(x) PRIVATE x
|
||||
#define MLLIB_PUBLIC(x) PUBLIC x
|
||||
#elif defined(STATIC_LINK_SHF)
|
||||
#elif defined(STATIC_LINK_SHF_RGFW)
|
||||
#define MLLIB_PRIVATE(x)
|
||||
#define MLLIB_PUBLIC(x) PUBLIC x
|
||||
#elif defined(DYNAMIC_LINK_SHF)
|
||||
#elif defined(DYNAMIC_LINK_SHF_RGFW)
|
||||
#define MLLIB_PRIVATE(x)
|
||||
#define MLLIB_PUBLIC(x) EXTERNAL x
|
||||
#else
|
||||
#error Must specify linkage for shf
|
||||
#error Must specify linkage for shf_rgfw
|
||||
#define MLLIB_PRIVATE(x)
|
||||
#define MLLIB_PUBLIC(x)
|
||||
#endif
|
||||
@@ -157,9 +157,6 @@ typedef Pointer Objptr;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MLLIB_PUBLIC(void mltonFramebufferSizeCallback (Int32 x0, Int32 x1);)
|
||||
MLLIB_PUBLIC(void mltonCharCallback (Word32 x0);)
|
||||
MLLIB_PUBLIC(void mltonKeyCallback (Int32 x0, Int32 x1, Int32 x2, Int32 x3);)
|
||||
|
||||
#undef MLLIB_PRIVATE
|
||||
#undef MLLIB_PUBLIC
|
||||
@@ -168,4 +165,4 @@ MLLIB_PUBLIC(void mltonKeyCallback (Int32 x0, Int32 x1, Int32 x2, Int32 x3);)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SHF_ML_H__ */
|
||||
#endif /* __SHF_RGFW_ML_H__ */
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
#include <math.h>
|
||||
#define RGFW_OPENGL
|
||||
#define RGFW_ALLOC_DROPFILES
|
||||
#define RGFW_IMPLEMENTATION
|
||||
#define RGFW_OPENGL /* if this line is not added, OpenGL functions will not be included */
|
||||
#define RGFW_PRINT_ERRORS
|
||||
#define RGFW_DEBUG
|
||||
#define GL_SILENCE_DEPRECATION
|
||||
#include "RGFW.h"
|
||||
#include <GLES3/gl3.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef RGFW_MACOS
|
||||
#include <OpenGL/gl.h> /* why does macOS do this */
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
RGFW_windowFlags OPENGL_WINDOW = RGFW_windowOpenGL;
|
||||
|
||||
RGFW_window* createWindow(char* title, int x, int y, int width, int height, RGFW_windowFlags options) {
|
||||
return RGFW_createWindow(title, x, y, width, height, options);
|
||||
RGFW_window* createWindow(char* title, int x, int y, int width, int height) {
|
||||
return RGFW_createWindow(title, x, y, width, height, RGFW_windowCenter | RGFW_windowOpenGL);
|
||||
}
|
||||
|
||||
void closeWindow(RGFW_window* window) {
|
||||
RGFW_window_close(window);
|
||||
}
|
||||
|
||||
bool shouldCloseWindow(RGFW_window* window) {
|
||||
return RGFW_window_shouldClose(window) != 0;
|
||||
}
|
||||
|
||||
void swapBuffers(RGFW_window* window) {
|
||||
RGFW_window_swapBuffers_OpenGL(window);
|
||||
}
|
||||
|
||||
14
ffi/rgfw-export.sml
Normal file
14
ffi/rgfw-export.sml
Normal file
@@ -0,0 +1,14 @@
|
||||
structure Rgfw =
|
||||
struct
|
||||
type window = MLton.Pointer.t
|
||||
|
||||
(* RGFW functions. *)
|
||||
val createWindow =
|
||||
_import "createWindow" public : string * int * int * int * int -> window;
|
||||
val closeWindow =
|
||||
_import "closeWindow" public : window -> unit;
|
||||
val shouldCloseWindow =
|
||||
_import "shouldCloseWindow" public : window -> bool;
|
||||
val swapBuffers =
|
||||
_import "swapBuffers" public : window -> unit;
|
||||
end
|
||||
21
shell/rgfw-loop.sml
Normal file
21
shell/rgfw-loop.sml
Normal file
@@ -0,0 +1,21 @@
|
||||
structure RgfwLoop =
|
||||
struct
|
||||
fun loop (counter, window) =
|
||||
if Rgfw.shouldCloseWindow window then
|
||||
Rgfw.closeWindow window
|
||||
else
|
||||
let val () = print ("counter = " ^ Int.toString counter ^ "\n")
|
||||
in loop (counter + 1, window)
|
||||
end
|
||||
|
||||
fun main () =
|
||||
let
|
||||
val () = print "15\n"
|
||||
val window = Rgfw.createWindow ("shf", 0, 0, 1920, 1080)
|
||||
val () = print "17\n"
|
||||
in
|
||||
loop (0, window)
|
||||
end
|
||||
end
|
||||
|
||||
val _ = RgfwLoop.main ()
|
||||
10
shf-rgfw.mlb
Normal file
10
shf-rgfw.mlb
Normal file
@@ -0,0 +1,10 @@
|
||||
$(SML_LIB)/basis/basis.mlb
|
||||
|
||||
(* IMPERATIVE SHELL *)
|
||||
$(SML_LIB)/basis/mlton.mlb
|
||||
ann
|
||||
"allowFFI true"
|
||||
in
|
||||
ffi/rgfw-export.sml
|
||||
end
|
||||
shell/rgfw-loop.sml
|
||||
Reference in New Issue
Block a user