mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Update to latest JOGL
This commit is contained in:
@@ -5,6 +5,5 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
|
||||
<classpathentry kind="lib" path="library/gluegen-rt.jar"/>
|
||||
<classpathentry kind="lib" path="library/jogl.all.jar"/>
|
||||
<classpathentry kind="lib" path="library/nativewindow.all.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
srcdir="src" destdir="bin"
|
||||
encoding="UTF-8"
|
||||
includeAntRuntime="false"
|
||||
classpath="../../../core/core.jar; library/jogl.all.jar; library/gluegen-rt.jar; library/nativewindow.all.jar" />
|
||||
classpath="../../../core/core.jar; library/jogl.all.jar; library/gluegen-rt.jar" />
|
||||
|
||||
<!-- Copy the shaders to the bin folder.
|
||||
Eclipse does this automatically. -->
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
PImage img;
|
||||
int level = 2;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200, P3D);
|
||||
frameRate(90);
|
||||
smooth(level);
|
||||
|
||||
img = loadImage("milan_rubbish.jpg");
|
||||
}
|
||||
|
||||
public void draw () {
|
||||
background(0);
|
||||
|
||||
tint(255, 150);
|
||||
image(img, 0, 0, width, height);
|
||||
|
||||
fill(255);
|
||||
text("current smooth: " + level, mouseX, mouseY);
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
level = 4;
|
||||
smooth(level);
|
||||
}
|
||||
|
||||
+4
-1
@@ -17,7 +17,8 @@ int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 360, P3D);
|
||||
frameRate(120);
|
||||
frameRate(60);
|
||||
noSmooth();
|
||||
noStroke();
|
||||
}
|
||||
|
||||
@@ -49,6 +50,8 @@ void draw() {
|
||||
}
|
||||
popMatrix();
|
||||
|
||||
hint(ENABLE_DEPTH_TEST);
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
|
||||
@@ -11,7 +11,8 @@ int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 360, P3D);
|
||||
frameRate(120);
|
||||
frameRate(60);
|
||||
noSmooth();
|
||||
noStroke();
|
||||
|
||||
grid = createShape(PShape.GROUP);
|
||||
@@ -98,6 +99,8 @@ void draw() {
|
||||
shape(grid);
|
||||
popMatrix();
|
||||
|
||||
hint(ENABLE_DEPTH_TEST);
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P3D);
|
||||
frameRate(240);
|
||||
frameRate(120);
|
||||
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P3D);
|
||||
frameRate(240);
|
||||
frameRate(120);
|
||||
|
||||
particles = createShape(PShape.GROUP);
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
@@ -16,6 +16,8 @@ float ry =0;
|
||||
|
||||
void setup() {
|
||||
size(1024, 768, P3D);
|
||||
noSmooth();
|
||||
frameRate(120);
|
||||
radio = height/3.5;
|
||||
|
||||
lista = new pelo[cuantos];
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(800, 600, P3D);
|
||||
frameRate(240);
|
||||
frameRate(60);
|
||||
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(800, 600, P3D);
|
||||
frameRate(240);
|
||||
frameRate(60);
|
||||
|
||||
particles = createShape(PShape.GROUP);
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
void setup() {
|
||||
size(400, 400, P3D);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255, 0, 0);
|
||||
ellipse(mouseX, mouseY, 100, 50);
|
||||
println("draw");
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
redraw();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
void setup() {
|
||||
size(400, 400, P3D);
|
||||
frame.setResizable(true);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255, 0, 0);
|
||||
ellipse(width/2, height/2, 100, 50);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
void setup() {
|
||||
size(400, 400, P3D);
|
||||
smooth(2);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255, 0, 0);
|
||||
ellipse(mouseX, mouseY, 100, 100);
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
if (key == '1') smooth(1);
|
||||
else if (key == '2') smooth(2);
|
||||
else if (key == '3') smooth(4);
|
||||
else if (key == '4') smooth(8);
|
||||
else if (key == '5') smooth(16);
|
||||
else if (key == '6') smooth(32);
|
||||
}
|
||||
|
||||
@@ -8,3 +8,9 @@ name = OpenGL
|
||||
# on the user's computer, rather than increasing the download size with
|
||||
# the versions for each platform.
|
||||
applet = opengl.jar
|
||||
|
||||
application.macosx=opengl.jar,jogl.all.jar,gluegen-rt.jar,jogl-all-natives-macosx-universal.jar,gluegen-rt-natives-macosx-universal.jar
|
||||
application.windows32=opengl.jar,jogl.all.jar,gluegen-rt.jar,jogl-all-natives-windows-i586.jar,gluegen-rt-natives-windows-i586.jar
|
||||
application.windows64=opengl.jar,jogl.all.jar,gluegen-rt.jar,jogl-all-natives-windows-amd64.jar,gluegen-rt-natives-windows-amd64.jar
|
||||
application.linux32=opengl.jar,jogl.all.jar,gluegen-rt.jar,jogl-all-natives-linux-i586.jar,gluegen-rt-natives-linux-i586.jar
|
||||
application.linux64=opengl.jar,jogl.all.jar,gluegen-rt.jar,jogl-all-natives-linux-amd64.jar,gluegen-rt-natives-linux-amd64.jar
|
||||
@@ -51,8 +51,7 @@ import java.util.HashMap;
|
||||
class PFontTexture implements PConstants {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL pg;
|
||||
protected PGL pgl;
|
||||
protected PGL.Context context;
|
||||
protected PGL pgl;
|
||||
protected PFont font;
|
||||
|
||||
protected int maxTexWidth;
|
||||
@@ -72,7 +71,6 @@ class PFontTexture implements PConstants {
|
||||
this.font = font;
|
||||
pg = (PGraphicsOpenGL)parent.g;
|
||||
pgl = pg.pgl;
|
||||
context = pgl.getContext();
|
||||
|
||||
initTexture(maxw, maxh);
|
||||
}
|
||||
@@ -220,6 +218,21 @@ class PFontTexture implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
public boolean contextIsOutdated() {
|
||||
boolean outdated = false;
|
||||
for (int i = 0; i < textures.length; i++) {
|
||||
if (textures[i].contextIsOutdated()) {
|
||||
outdated = true;
|
||||
}
|
||||
}
|
||||
if (outdated) {
|
||||
for (int i = 0; i < textures.length; i++) {
|
||||
textures[i].glID = 0;
|
||||
}
|
||||
}
|
||||
return outdated;
|
||||
}
|
||||
|
||||
// Adds this glyph to the opengl texture in PFont.
|
||||
protected void addToTexture(int idx, PFont.Glyph glyph) {
|
||||
// We add one pixel to avoid issues when sampling the font texture at fractional
|
||||
|
||||
@@ -38,10 +38,14 @@ import java.nio.IntBuffer;
|
||||
*
|
||||
* By Andres Colubri.
|
||||
*/
|
||||
|
||||
// TODO: restart framebuffer when context changes
|
||||
|
||||
public class PFramebuffer implements PConstants {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL pg;
|
||||
protected PGL pgl;
|
||||
protected PGL.Context context; // The context that created this framebuffer.
|
||||
|
||||
public int glFboID;
|
||||
public int glDepthBufferID;
|
||||
@@ -187,6 +191,9 @@ public class PFramebuffer implements PConstants {
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
// if context is outdated ??
|
||||
|
||||
|
||||
if (screenFb) {
|
||||
if (PGraphicsOpenGL.fboSupported) {
|
||||
pgl.glBindFramebuffer(PGL.GL_FRAMEBUFFER, 0);
|
||||
@@ -341,10 +348,11 @@ public class PFramebuffer implements PConstants {
|
||||
protected void allocate() {
|
||||
release(); // Just in the case this object is being re-allocated.
|
||||
|
||||
context = pgl.getContext();
|
||||
|
||||
if (screenFb) {
|
||||
glFboID = 0;
|
||||
} else if (fboMode) {
|
||||
//glFboID = ogl.createGLResource(PGraphicsAndroid3D.GL_FRAME_BUFFER);
|
||||
} else if (fboMode) {
|
||||
glFboID = pg.createFrameBufferObject();
|
||||
} else {
|
||||
glFboID = 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,6 @@ package processing.opengl;
|
||||
import processing.core.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* This class encapsulates a GLSL shader program, including a vertex
|
||||
@@ -37,6 +36,7 @@ public class PShader {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsOpenGL pg;
|
||||
protected PGL pgl;
|
||||
protected PGL.Context context; // The context that created this shader.
|
||||
|
||||
protected URL vertexURL;
|
||||
protected URL fragmentURL;
|
||||
@@ -48,14 +48,6 @@ public class PShader {
|
||||
protected int vertexShader;
|
||||
protected int fragmentShader;
|
||||
|
||||
protected FloatBuffer vec1f;
|
||||
protected FloatBuffer vec2f;
|
||||
protected FloatBuffer vec3f;
|
||||
protected FloatBuffer vec4f;
|
||||
protected FloatBuffer mat2x2;
|
||||
protected FloatBuffer mat3x3;
|
||||
protected FloatBuffer mat4x4;
|
||||
|
||||
public PShader() {
|
||||
parent = null;
|
||||
pg = null;
|
||||
@@ -226,91 +218,49 @@ public class PShader {
|
||||
|
||||
public void set1FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec1f == null || vec1f.capacity() != vec.length) {
|
||||
vec1f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec1f.rewind();
|
||||
vec1f.put(vec);
|
||||
vec1f.flip();
|
||||
pgl.glUniform1fv(loc, vec.length, vec1f);
|
||||
pgl.glUniform1fv(loc, vec.length, vec, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set2FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec2f == null || vec2f.capacity() != vec.length) {
|
||||
vec2f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec2f.rewind();
|
||||
vec2f.put(vec);
|
||||
vec2f.flip();
|
||||
pgl.glUniform2fv(loc, vec.length / 2, vec2f);
|
||||
pgl.glUniform2fv(loc, vec.length / 2, vec, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set3FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec3f == null || vec3f.capacity() != vec.length) {
|
||||
vec3f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec3f.rewind();
|
||||
vec3f.put(vec);
|
||||
vec3f.flip();
|
||||
pgl.glUniform3fv(loc, vec.length / 3, vec3f);
|
||||
pgl.glUniform3fv(loc, vec.length / 3, vec, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set4FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec4f == null || vec4f.capacity() != vec.length) {
|
||||
vec4f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec4f.rewind();
|
||||
vec4f.put(vec);
|
||||
vec4f.flip();
|
||||
pgl.glUniform4fv(loc, vec.length / 4, vec4f);
|
||||
pgl.glUniform4fv(loc, vec.length / 4, vec, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set2x2MatUniform(int loc, float[] mat) {
|
||||
if (-1 < loc) {
|
||||
if (mat2x2 == null) {
|
||||
mat2x2 = pgl.createFloatBuffer(2 * 2);
|
||||
}
|
||||
mat2x2.rewind();
|
||||
mat2x2.put(mat);
|
||||
mat2x2.flip();
|
||||
pgl.glUniformMatrix2fv(loc, 1, false, mat2x2);
|
||||
pgl.glUniformMatrix2fv(loc, 1, false, mat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set3x3MatUniform(int loc, float[] mat) {
|
||||
if (-1 < loc) {
|
||||
if (mat3x3 == null) {
|
||||
mat3x3 = pgl.createFloatBuffer(3 * 3);
|
||||
}
|
||||
mat3x3.rewind();
|
||||
mat3x3.put(mat);
|
||||
mat3x3.flip();
|
||||
pgl.glUniformMatrix3fv(loc, 1, false, mat3x3);
|
||||
pgl.glUniformMatrix3fv(loc, 1, false, mat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set4x4MatUniform(int loc, float[] mat) {
|
||||
if (-1 < loc) {
|
||||
if (mat4x4 == null) {
|
||||
mat4x4 = pgl.createFloatBuffer(4 * 4);
|
||||
}
|
||||
mat4x4.rewind();
|
||||
mat4x4.put(mat);
|
||||
mat4x4.flip();
|
||||
pgl.glUniformMatrix4fv(loc, 1, false, mat4x4);
|
||||
pgl.glUniformMatrix4fv(loc, 1, false, mat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +293,9 @@ public class PShader {
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
if (programObject == 0) {
|
||||
if (programObject == 0 || contextIsOutdated()) {
|
||||
|
||||
context = pgl.getContext();
|
||||
programObject = pg.createGLSLProgramObject();
|
||||
|
||||
if (vertexFilename != null) {
|
||||
@@ -371,6 +323,17 @@ public class PShader {
|
||||
}
|
||||
|
||||
|
||||
protected boolean contextIsOutdated() {
|
||||
boolean outdated = !pgl.contextIsCurrent(context);
|
||||
if (outdated) {
|
||||
programObject = 0;
|
||||
vertexShader = 0;
|
||||
fragmentShader = 0;
|
||||
}
|
||||
return outdated;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads and compiles the vertex shader contained in file.
|
||||
*
|
||||
@@ -473,4 +436,3 @@ public class PShader {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,7 +42,7 @@ public class PTexture implements PConstants {
|
||||
public int width, height;
|
||||
|
||||
protected PApplet parent; // The Processing applet
|
||||
protected PGraphicsOpenGL pg; // The main renderer
|
||||
protected PGraphicsOpenGL pg; // The main renderer
|
||||
protected PGL pgl; // The interface between Processing and OpenGL.
|
||||
protected PGL.Context context; // The context that created this texture.
|
||||
|
||||
@@ -67,8 +67,6 @@ public class PTexture implements PConstants {
|
||||
protected int[] tempPixels = null;
|
||||
protected PFramebuffer tempFbo = null;
|
||||
|
||||
protected IntBuffer texels;
|
||||
|
||||
protected Object bufferSource;
|
||||
protected LinkedList<BufferData> bufferCache = null;
|
||||
protected Method disposeBufferMethod;
|
||||
@@ -103,8 +101,7 @@ public class PTexture implements PConstants {
|
||||
this.parent = parent;
|
||||
|
||||
pg = (PGraphicsOpenGL)parent.g;
|
||||
pgl = pg.pgl;
|
||||
context = pgl.getContext();
|
||||
pgl = pg.pgl;
|
||||
|
||||
glID = 0;
|
||||
|
||||
@@ -120,8 +117,7 @@ public class PTexture implements PConstants {
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -777,6 +773,7 @@ public class PTexture implements PConstants {
|
||||
|
||||
pgl.enableTexturing(glTarget);
|
||||
|
||||
context = pgl.getContext();
|
||||
glID = pg.createTextureObject();
|
||||
|
||||
pgl.glBindTexture(glTarget, glID);
|
||||
@@ -808,6 +805,14 @@ public class PTexture implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
protected boolean contextIsOutdated() {
|
||||
boolean outdated = !pgl.contextIsCurrent(context);
|
||||
if (outdated) {
|
||||
glID = 0;
|
||||
}
|
||||
return outdated;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Utilities.
|
||||
@@ -846,21 +851,14 @@ public class PTexture implements PConstants {
|
||||
protected void setTexels(int[] pix, int x, int y, int w, int h) {
|
||||
setTexels(pix, 0, x, y, w, h);
|
||||
}
|
||||
|
||||
protected void setTexels(int[] pix, int level, int x, int y, int w, int h) {
|
||||
pgl.glTexSubImage2D(glTarget, level, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(pix));
|
||||
}
|
||||
|
||||
protected void setTexels(IntBuffer buffer, int x, int y, int w, int h) {
|
||||
setTexels(buffer, 0, x, y, w, h);
|
||||
}
|
||||
|
||||
protected void setTexels(int[] pix, int level, int x, int y, int w, int h) {
|
||||
if (texels == null || texels.capacity() != width * height) {
|
||||
texels = pgl.createIntBuffer(width * height);
|
||||
}
|
||||
texels.position(0);
|
||||
texels.limit(pix.length);
|
||||
texels.put(pix);
|
||||
texels.flip();
|
||||
pgl.glTexSubImage2D(glTarget, level, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, texels);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTexels(IntBuffer buffer, int level, int x, int y, int w, int h) {
|
||||
pgl.glTexSubImage2D(glTarget, level, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
Reference in New Issue
Block a user