Screen rotation not working with P3D?

edited November 2013 in Android Mode

I'm running a test sketch I've made. It works very well, I'm surprised.

When using P3D, black screen is shown if I rotate to LANDSCAPE view. Whereas using default 2D rotation works.

int x = 0;
int y = 0;
int dx = 1;
int dy = 1;

void setup(){
  size(displayWidth, displayHeight, P3D);
  //size(displayWidth, displayHeight);
}

void draw(){
  background(0);
  stroke(255);

  line(x, 0, x, height);
  line(0, y, width, y);

  x = x + dx;
  y = y + dy;

  if (x <= 0) dx = 1;
  if (x >= width) dx = -1;
  if (y <= 0) dy = 1;
  if (y >= height) dy = -1;

  textAlign(CENTER);
  textSize(28);
  text("x: "+x+"/"+width+"px", width/2, height/2 - 15);
  text("y: "+y+"/"+height+"px", width/2, height/2 + 15);

  textAlign(LEFT);
  textSize(12);
  text(nf(frameRate,2,2)+"fps", 5, 15); 
}
Tagged:

Answers

    1. Where did you use rotation in this program?
    2. Try reinstalling java. Uninstall old java completely restart your system and then install new version of it.
  • blyk, read the question. it's about rotating the device.

    redraw, ignore blyk 8)

  • edited November 2013

    Koogs, may be you are right.. I certainly don't understand what exactly he is asking but one thing for sure he has not used any rotation function in his program as he used P3D in size().

    And device rotation ? :-O :-O I dont see where did he mentioned this ?

  • @blyk: This question is in reference to an Android device's physical screen rotation (i.e. user rotates the hardware and the built-in accelerometer detects a change) being sent as an event to the sketch and the sketch not handling it properly:

    When using P3D, black screen is shown if I rotate to LANDSCAPE view. Whereas using default 2D rotation works.

    Android's default action upon rotation is to re-create the Activity, and Processing has no framework for restoring data between Activity sessions. Normally, I avoid this problem by locking the screen orientation as either PORTRAIT or LANDSCAPE. However, if you want rotation functionality, this might not be an option...

    P3D is built largely on top of OpenGL. Does the OPENGL renderer encounter similar problems?

  • edited November 2013

    calsign ! I didn't notice that it was under android category

  • edited November 2013

    thanks. yes, the Activity is re-created when device is rotated, only in P2D. OPENGL shows the same issue. Anyway, the library is very useful for starters :)...

  • Are you sure that P2D works? P2D is also built on top of OpenGL... The default renderer is Java2D, which may be what you meant.

  • I confused P2D with Java2D. Only works with Java2D, the default renderer yes.

Sign In or Register to comment.