Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2D/P3D and Opengl render not working #1

Open
joaodafonseca opened this issue Feb 17, 2016 · 10 comments
Open

P2D/P3D and Opengl render not working #1

joaodafonseca opened this issue Feb 17, 2016 · 10 comments

Comments

@joaodafonseca
Copy link

The library doesn't work in any of the above renders, any way to make this working?

@ffd8
Copy link

ffd8 commented Jul 25, 2016

Just ran into this bug which left me pretty confused. Happy to have found this message and can confirm that in Processing 3.1.1 it also failed to allow drag + drop when using P3D render.

@clankill3r
Copy link

+1 for processing 3.1.2

@markusand
Copy link

The same for 3.2.1.
I don't know what are the changes in this library from the original one, but I was hoping this would work correctly in P2D at least. I think it's a really needed feature.

@armthethinker
Copy link

+1

Same for 3.3.6 and 3.3.7

@ffd8
Copy link

ffd8 commented Apr 1, 2018

A quasi workaround is to create a 2nd window applet for the drag+drop function using default renderer:

// DRAG + DROP
import drop.*;
SDrop drop;
MyDropListener m;

PImage img;
String imgPath = "";

// second window
SecondApplet sa;
boolean saInit = true;

void settings() {
  size(512, 512, P3D);
}

void setup() {
  surface.setResizable(true);

  String[] args = {"blah"};
  sa = new SecondApplet();
  PApplet.runSketch(args, sa);
}

void draw() {
  background(0);
  if (img != null) {
    image(img, 0, 0);
  }
}

// a custom DropListener class.
class MyDropListener extends DropListener {
  int myC = 0;

  MyDropListener() {
    setTargetRect(0, 0, sa.width, sa.height);
  }

  void draw() {
    sa.noStroke();
    sa.fill(0, 255, 0, myC);
    sa.rect(0, 0, sa.width, sa.height);
    sa.stroke(0);
  }
  void dropEnter() {
    myC = 100;
  }
  void dropLeave() {
    myC = 0;
  }

  void dropEvent(DropEvent theEvent) {
    img = null;
    imgPath = theEvent.toString();
    println("imgPath: " + imgPath);
    img = loadImage(imgPath);
  }
}

public class SecondApplet extends PApplet {
  public void settings() {
    size(200, 200);
  }
  public void setup() {
    surface.setTitle("dragImage");
    drop = new SDrop(this);
    m = new MyDropListener();
    drop.addDropListener(m);
  }
  public void draw() {
    if (saInit) {
      surface.setLocation(0, 0);
      saInit= false;
    }
    background(255);
    m.draw();
    frame.setLocation(200, 200);
  }
}

@transfluxus
Copy link
Owner

sorry people,
I didn't even used that library much when I ported it. It was a early version of 3.
If somebody could make a pull-request, or fork it that would be great.

Maybe Andreas Schlegel version is also still flying around somewhere to have a look at that...

@micycle1
Copy link

micycle1 commented Jan 9, 2020

If somebody could make a pull-request, or fork it that would be great.

I might take a look at this. Which renderers does it work with at the moment? Just the default and FX2D?

@transfluxus
Copy link
Owner

yeah the default should go

@Devostated
Copy link

If somebody could make a pull-request, or fork it that would be great.

I might take a look at this. Which renderers does it work with at the moment? Just the default and FX2D?

@micycle1 did you happen to look into it?
Or does anyone else know a workaround to get drag in drop of 3D objects without a second window?

@micycle1
Copy link

micycle1 commented Feb 13, 2022

@Devostated I looked into it but wasn't able to find an obvious solution.

This is the original code for setup with a JOGL (P2D/P3D) surface:

surfaceType = SurfaceType.JOGL;
setup(((PSurfaceJOGL) surface).getComponent(), applet);

First problem is .getComponent() (which returns a NewtCanvasAWT) returns a null value when the surface has not been initialized off-screen. I tried creating a canvas from the surface's GLWindow (to create a non-null NewtCanvasAWT), as per below, but that didn't fix anything.

surfaceType = SurfaceType.JOGL;
PSurfaceJOGL joglSurface = (PSurfaceJOGL) surface;
GLWindow window = (GLWindow) joglSurface.getNative();
NewtCanvasAWT canvas = new NewtCanvasAWT(window);
setup(canvas, applet);

Also, drop doesn't work with the FX2D renderer either and that's because it doesn't have an AWT canvas object whatsoever... The drag-and-drop feature for JavaFX will need to be completely rebuilt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants