removed glw

This commit is contained in:
codeanticode
2015-02-20 16:45:29 -05:00
parent a8bb95b5dc
commit 14c89ed2ec
12 changed files with 0 additions and 536 deletions

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
<classpathentry kind="lib" path="/processing-core/library/jogl-all.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1 +0,0 @@
/bin

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>processing-glw</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -1,32 +0,0 @@
<?xml version="1.0"?>
<project name="Processing GLW Library" default="build">
<target name="clean" description="Clean the build directories">
<delete dir="bin" />
<delete file="library/glw.jar" />
</target>
<target name="compile" description="Compile sources">
<condition property="core-built">
<available file="../../../core/library/core.jar" />
</condition>
<fail unless="core-built" message="Please build the core library first and make sure it sits in ../../../core/library/core.jar" />
<mkdir dir="bin" />
<javac source="1.7"
target="1.7"
srcdir="src" destdir="bin"
encoding="UTF-8"
includeAntRuntime="false"
classpath="../../../core/library/core.jar; ../../../core/library/jogl-all.jar; ../../../core/library/gluegen-rt.jar"
nowarn="true"
compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
<compilerclasspath path="mode/org.eclipse.jdt.core.jar;
mode/jdtCompilerAdapter.jar" />
</javac>
</target>
<target name="build" depends="compile" description="Build OpenGL LWJGL library">
<jar basedir="bin" destfile="library/glw.jar" />
</target>
</project>

View File

@@ -1,25 +0,0 @@
import processing.glw.*;
PGraphics stage;
void setup() {
// The main window will be hidden, only GLW.RENDERER
// can be used in size()
size(100, 100, GLW.RENDERER);
stage = createGraphics(2560, 1440, GLW.P2D);
GLW.createWindow(stage);
frameRate(180);
}
void draw() {
// The draw() method is used to update the offscreen surfaces,
// but not to draw directly to the screen.
stage.beginDraw();
stage.background(200);
stage.fill(255);
stage.ellipse(mouseX, mouseY, 50, 50);
stage.fill(0);
stage.text(frameRate, 100, 100);
stage.endDraw();
}

View File

@@ -1,28 +0,0 @@
import processing.glw.*;
PGraphics canvas1;
PGraphics canvas2;
void setup() {
size(100, 100, GLW.RENDERER);
canvas1 = createGraphics(320, 240, GLW.P2D);
canvas2 = createGraphics(320, 240, GLW.P2D);
GLW.createWindow(canvas1);
GLW.createWindow(canvas2);
}
void draw() {
canvas1.beginDraw();
canvas1.background(200);
canvas1.ellipse(mouseX, mouseY, 100, 100);
canvas1.endDraw();
canvas2.beginDraw();
canvas2.background(170);
canvas2.ellipse(mouseX, mouseY, 50, 50);
canvas2.endDraw();
}
void keyPressed() {
GLW.getFocusedWindow().setVisible(false);
}

View File

@@ -1 +0,0 @@
/glw.jar

View File

@@ -1,52 +0,0 @@
package processing.glw;
import processing.core.PGraphics;
import com.jogamp.newt.opengl.GLWindow;
import java.util.HashMap;
public class GLW {
static public final String RENDERER = "processing.glw.PGraphicsGLW";
static public final String OPENGL = "processing.glw.PGraphicsGLW";
static public final String P2D = "processing.glw.PGraphics2D";
static public final String P3D = "processing.glw.PGraphics3D";
static protected HashMap<PGraphics, GLWindow> windows =
new HashMap<PGraphics, GLWindow>();
public GLW() {
}
static public void createWindow(PGraphics pg) {
if (pg instanceof PGraphics2D || pg instanceof PGraphics3D) {
windows.put(pg, null);
} else {
throw new RuntimeException("Only GLW.P2D or GLW.P3D surfaces can be attached to a window");
}
}
static public GLWindow getWindow(PGraphics pg) {
return windows.get(pg);
}
static public boolean isFocused(PGraphics pg) {
GLWindow win = windows.get(pg);
return win != null && win.hasFocus();
}
static public PGraphics getFocusedGraphics() {
for (PGraphics pg: windows.keySet()) {
if (isFocused(pg)) return pg;
}
return null;
}
static public GLWindow getFocusedWindow() {
for (PGraphics pg: windows.keySet()) {
if (isFocused(pg)) return windows.get(pg);
}
return null;
}
}

View File

@@ -1,10 +0,0 @@
package processing.glw;
import processing.opengl.PGL;
import processing.opengl.PGraphicsOpenGL;
public class PGraphics2D extends processing.opengl.PGraphics2D {
protected PGL createPGL(PGraphicsOpenGL pg) {
return new PNEWT(pg);
}
}

View File

@@ -1,10 +0,0 @@
package processing.glw;
import processing.opengl.PGL;
import processing.opengl.PGraphicsOpenGL;
public class PGraphics3D extends processing.opengl.PGraphics3D {
protected PGL createPGL(PGraphicsOpenGL pg) {
return new PNEWT(pg);
}
}

View File

@@ -1,85 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.glw;
import processing.opengl.PGL;
import processing.opengl.PGraphicsOpenGL;
/**
* GLW renderer. It's only role is to drive the main animation loop by calling
* requestDraw() and so allowing the offscreen canvases to be drawn inside the
* draw() method of the sketch. Currently, it cannot be used to draw into.
*
*/
public class PGraphicsGLW extends PGraphicsOpenGL {
protected PGL createPGL(PGraphicsOpenGL pg) {
return new PNEWT(pg);
}
public void beginDraw() {
if (primarySurface) {
setCurrentPG(this);
} else {
throw new RuntimeException("GLW renderer cannot be used as an offscreen surface");
}
report("top beginDraw()");
if (!checkGLThread()) {
return;
}
if (drawing) {
return;
}
if (!glParamsRead) {
getGLParameters();
}
drawing = true;
report("bot beginDraw()");
}
public void endDraw() {
report("top endDraw()");
if (!drawing) {
return;
}
if (primarySurface) {
setCurrentPG(null);
} else {
throw new RuntimeException("GLW renderer cannot be used as an offscreen surface.");
}
drawing = false;
report("bot endDraw()");
}
protected void vertexImpl(float x, float y, float z, float u, float v) {
throw new RuntimeException("The main GLW renderer cannot be used to draw to.");
}
}

View File

@@ -1,267 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2011-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.glw;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import processing.core.PApplet;
import processing.core.PGraphics;
import processing.opengl.PGL;
import processing.opengl.PGraphicsOpenGL;
import processing.opengl.PJOGL;
import processing.opengl.Texture;
public class PNEWT extends PJOGL {
static {
WINDOW_TOOLKIT = NEWT;
EVENTS_TOOLKIT = NEWT;
USE_FBOLAYER_BY_DEFAULT = false;
USE_JOGL_FBOLAYER = false;
}
protected static GLCapabilities sharedCaps;
protected static GLAutoDrawable sharedDrawable;
public PNEWT(PGraphicsOpenGL pg) {
super(pg);
}
protected void initSurface(int antialias) {
if (!(pg instanceof PGraphicsGLW)) {
throw new RuntimeException("GLW.RENDERER is the only option in size() when using the GLW library.");
}
if (profile == null) {
if (PROFILE == 2) {
try {
profile = GLProfile.getGL2ES1();
} catch (GLException ex) {
profile = GLProfile.getMaxFixedFunc(true);
}
} else if (PROFILE == 3) {
try {
profile = GLProfile.getGL2GL3();
} catch (GLException ex) {
profile = GLProfile.getMaxProgrammable(true);
}
if (!profile.isGL3()) {
PGraphics.showWarning("Requested profile GL3 but is not available, got: " + profile);
}
} else if (PROFILE == 4) {
try {
profile = GLProfile.getGL4ES3();
} catch (GLException ex) {
profile = GLProfile.getMaxProgrammable(true);
}
if (!profile.isGL4()) {
PGraphics.showWarning("Requested profile GL4 but is not available, got: " + profile);
}
} else throw new RuntimeException(UNSUPPORTED_GLPROF_ERROR);
if (2 < PROFILE) {
texVertShaderSource = convertVertexSource(texVertShaderSource, 120, 150);
tex2DFragShaderSource = convertFragmentSource(tex2DFragShaderSource, 120, 150);
texRectFragShaderSource = convertFragmentSource(texRectFragShaderSource, 120, 150);
}
}
// Setting up the desired capabilities;
sharedCaps = new GLCapabilities(profile);
sharedCaps.setAlphaBits(REQUESTED_ALPHA_BITS);
sharedCaps.setDepthBits(REQUESTED_DEPTH_BITS);
sharedCaps.setStencilBits(REQUESTED_STENCIL_BITS);
sharedCaps.setPBuffer(false);
sharedCaps.setFBO(false);
sharedCaps.setSampleBuffers(false);
fboLayerRequested = false;
sharedDrawable = GLDrawableFactory.getFactory(profile).createDummyAutoDrawable(null, true, sharedCaps, null);
sharedDrawable.display(); // triggers GLContext object creation and native realization.
DummyListener listener = new DummyListener();
sharedDrawable.addGLEventListener(listener);
pg.parent.frame.setVisible(false);
}
protected boolean displayable() {
return false;
}
protected void beginDraw(boolean clear0) {
}
protected void endDraw(boolean clear0) {
}
protected void requestDraw() {
createWindows();
// Calling display() so the main draw() method is triggered, where the
// offscreen GLW canvases can be updated.
sharedDrawable.display();
displayWindows();
}
private void createWindows() {
for (PGraphics pg: GLW.windows.keySet()) {
GLWindow win = GLW.windows.get(pg);
if (win == null) {
win = GLWindow.create(sharedCaps);
win.setSharedAutoDrawable(sharedDrawable);
win.setSize(pg.width, pg.height);
win.setTitle("TEST");
win.setVisible(true);
GLW.windows.put(pg, win);
NEWTListener listener = new NEWTListener(pg);
win.addGLEventListener(listener);
NEWTMouseListener mouseListener = new NEWTMouseListener();
win.addMouseListener(mouseListener);
NEWTKeyListener keyListener = new NEWTKeyListener();
win.addKeyListener(keyListener);
NEWTWindowListener winListener = new NEWTWindowListener();
win.addWindowListener(winListener);
win.addWindowListener(new WindowAdapter() {
@Override
public void windowDestroyNotify(final WindowEvent e) {
}
});
}
}
}
static private void displayWindows() {
int totalCount = 0;
int realizedCount = 0;
for (GLWindow win: GLW.windows.values()) {
if (win != null) {
totalCount++;
if (win.isRealized()) realizedCount++;
win.display();
}
}
if (0 < totalCount && realizedCount == 0) {
// All windows where closed, exit the application
sharedDrawable.destroy();
System.exit(0);
}
}
protected class DummyListener implements GLEventListener {
public DummyListener() {
}
@Override
public void display(GLAutoDrawable glDrawable) {
getGL(glDrawable);
pg.parent.handleDraw();
}
@Override
public void dispose(GLAutoDrawable adrawable) {
}
@Override
public void init(GLAutoDrawable glDrawable) {
getGL(glDrawable);
capabilities = glDrawable.getChosenGLCapabilities();
if (!hasFBOs()) {
throw new RuntimeException(MISSING_FBO_ERROR);
}
if (!hasShaders()) {
throw new RuntimeException(MISSING_GLSL_ERROR);
}
if (USE_JOGL_FBOLAYER && capabilities.isFBO()) {
int maxs = maxSamples();
numSamples = PApplet.min(capabilities.getNumSamples(), maxs);
}
}
@Override
public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {
}
}
protected class NEWTListener implements GLEventListener {
PGraphicsOpenGL pg;
PNEWT pgl;
public NEWTListener(PGraphics pg) {
this.pg = (PGraphicsOpenGL)pg;
pgl = (PNEWT)this.pg.pgl;
}
@Override
public void display(GLAutoDrawable glDrawable) {
pgl.getGL(glDrawable);
Texture tex = pg.getTexture(false);
if (tex != null) {
pgl.disable(PGL.BLEND);
pgl.drawTexture(tex.glTarget, tex.glName,
tex.glWidth, tex.glHeight,
0, 0, pg.width, pg.height);
pgl.enable(PGL.BLEND);
}
}
@Override
public void dispose(GLAutoDrawable adrawable) {
}
@Override
public void init(GLAutoDrawable glDrawable) {
}
@Override
public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {
}
}
}