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

OpenGL2 doesn't work #19

Open
eljeffeg opened this issue May 2, 2011 · 6 comments
Open

OpenGL2 doesn't work #19

eljeffeg opened this issue May 2, 2011 · 6 comments

Comments

@eljeffeg
Copy link

eljeffeg commented May 2, 2011

This line needs to be modified for the new class

if ( clazz.getName().equals("processing.opengl.PGraphicsOpenGL"))
isGL = true;

should now be:

  if ( clazz.getName().equals("processing.opengl.PGraphicsOpenGL") || clazz.getName().equals("processing.opengl2.PGraphicsOpenGL2") ) 
    isGL = true;

Similarly... a couple of other lines need to be tweaked in GLDrawableHelper to support OpenGL2.
Field context = PGraphicsOpenGL2.class.getDeclaredField( "context" );
&
Method allocate = PGraphicsOpenGL2.class.getDeclaredMethod( "allocate" );

@eljeffeg
Copy link
Author

Additional issue with OpenGL2.

The problem appears to be in this code.

    PGraphics g = fs.getSketch().g;
    Field field = PGraphics3D.class.getDeclaredField( "textures" );
    field.setAccessible( true ); // make private variable public!
    PImage textures[] = (PImage[]) field.get( g );

Error:
FullScreen: Unknown error: Can not set [Lprocessing.core.PImage; field processing.core.PGraphics3D.textures to processing.opengl2.PGraphicsOpenGL2
java.lang.IllegalArgumentException: Can not set [Lprocessing.core.PImage; field processing.core.PGraphics3D.textures to processing.opengl2.PGraphicsOpenGL2
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
at java.lang.reflect.Field.get(Field.java:358)
at HeliosCore$GLTextureUpdateHelper.update(HeliosCore.java:4345)
at HeliosCore$SoftFullScreen.setFullScreenImpl(HeliosCore.java:3954)
at HeliosCore$SoftFullScreen.access$0(HeliosCore.java:3924)
at HeliosCore$SoftFullScreen$2.action(HeliosCore.java:3918)
at HeliosCore$FullScreenBase$DelayedAction.post(HeliosCore.java:4240)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:680)

@kritzikratzi
Copy link
Owner

opengl2 is a complete standalone library (it doesn't inherit from the classic opengl library) so it also needs to be treated completely seperately.

for now opengl2 has been pulled from the 1.5 releases,
the revision list says it'll be back in the next pre-release which should be a good time to see what's needed to make it work.

the things happening within GLTextureUpdateHandler and GLDrawableHelper mostly fix problems that should be handled inside PGraphicsOpenGL, maybe the situation is already bit better with the opengl2 render.

what happened when you ran the unmodified fs-api with the opengl2 renderer?

@eljeffeg
Copy link
Author

Unmodified fs-api does not work with OpenGL2, using your example code. I get no error.

import fullscreen.*;
import processing.opengl2.PGraphicsOpenGL2;

FullScreen fs;

void setup(){

// set size to 640x480
size(640, 480, OPENGL2);

// 5 fps
frameRate(5);

// Create the fullscreen object
fs = new FullScreen(this);

// enter fullscreen mode
fs.enter();
}

void draw(){
background(0);

// Do your fancy drawing here...
for(int i = 0; i < 10; i++){
fill(
random(255),
random(255),
random(255)
);

rect(
  i*10, i*10,
  width - i*20, height - i*20
); 

}
}

@eljeffeg eljeffeg reopened this May 15, 2011
@eljeffeg
Copy link
Author

They put those "Comment & Close" and "Comment" buttons too close together...

@eljeffeg
Copy link
Author

OpenGL2 has now been set as the default for Processing in the codebase.

So there is no need now to make explicit reference to processing.opengl2.PGraphicsOpenGL2. Using just clazz.getName().equals("processing.opengl.PGraphicsOpenGL works fine now.

However, there is still and issue with this since PGraphics3D is gone.
PGraphics g = fs.getSketch().g;
Field field = PGraphics3D.class.getDeclaredField( "textures" );
field.setAccessible( true ); // make private variable public!
PImage textures[] = (PImage[]) field.get( g );

But due to recent changes in the OpenGL code, are the GL Helpers needed any more?

@kritzikratzi
Copy link
Owner

very brief answer:

helpers needed: not sure, quite likely not.

if you have a fix please just upload and i'll merge ...
else i'll have some time next week so i'll just mark this unread in my inbox and then look into it.

jeez ... my sentences start to look like code ...

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

2 participants