Schmavery / reprocessing

ReasonML graphics library inspired by Processing
https://schmavery.github.io/reprocessing/
MIT License
682 stars 24 forks source link

Test createImage/withImage on Linux #76

Closed Schmavery closed 6 years ago

Schmavery commented 6 years ago

@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.

bsansouci commented 6 years ago

cc @zploskey

Schmavery commented 6 years ago

Though if it's not running at all right now on linux that's probably higher priority haha

Schmavery commented 6 years ago

@bsansouci can you link to some example project that uses this functionality to make it easier for someone to test

bsansouci commented 6 years ago

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, ());
zploskey commented 6 years ago

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)
bsansouci commented 6 years ago

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, ());
zploskey commented 6 years ago

Looks like it works.

screenshot from 2018-05-22 08-33-56

bsansouci commented 6 years ago

Amazing, thanks for testing!