Closed Schmavery closed 6 years ago
cc @zploskey
Though if it's not running at all right now on linux that's probably higher priority haha
@bsansouci can you link to some example project that uses this functionality to make it easier for someone to test
This should draw the iconic red square only one to the image, and then always draw the image.
open Reprocessing;
let setup = (env) => {
Env.size(~width=200, ~height=200, env);
Draw.createImage(200, 200, env);
};
let draw = (image, env) => {
Draw.background(Constants.black, env);
if (!Draw.isImageDrawnTo(image)) {
Draw.withImage(image, env, (env) => {
Draw.fill(Constants.red, env);
Draw.rect(~pos=(50, 50), ~width=100, ~height=100, env)
});
};
Draw.image(image, ~pos=(0, 0), env);
};
run(~setup, ~draw, ());
That code complains about draw
having the wrong type.
We've found a bug for you!
/home/zach/src/reprocessing-example/src/index.re 19:14-17
17 │ };
18 │
19 │ run(~setup, ~draw, ());
This is:
Reprocessing_Types.Types.imageT ->
Reprocessing_Types.Types.glEnvT -> unit
But somewhere wanted:
Reprocessing_Types.Types.imageT ->
Reprocessing.glEnvT -> Reprocessing_Types.Types.imageT
The incompatible parts:
unit
vs
Reprocessing_Types.Types.imageT (defined as Reprocessing_Common.imageT)
Sorry I messed up, you need to return image
from draw.
open Reprocessing;
let setup = (env) => {
Env.size(~width=200, ~height=200, env);
Draw.createImage(200, 200, env);
};
let draw = (image, env) => {
Draw.background(Constants.black, env);
if (!Draw.isImageDrawnTo(image)) {
Draw.withImage(image, env, (env) => {
Draw.fill(Constants.red, env);
Draw.rect(~pos=(50, 50), ~width=100, ~height=100, env)
});
};
Draw.image(image, ~pos=(0, 0), env);
image
};
run(~setup, ~draw, ());
Looks like it works.
Amazing, thanks for testing!
@bsansouci recently added the functionality mentioned in #66 😄, but we haven't tested it for Linux machines yet (just windows + mac). We should probably do this at some point to keep compatibility going across the board.
This change involves some slightly hacky updates to reasongl to make it load some frameBuffer-related functions that aren't in GL 2.1 (which is the api we use for the most part), so it's possible there will be some issues.