| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe0a73e commit cf23a59
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,7 @@ | |||
| 26 | 26 | import processing.opengl.PGraphicsOpenGL; | |
| 27 | 27 | ||
| 28 | 28 | /** | |
| 29 | - * LWJGL renderer. | ||
| 29 | + * GLW renderer. | ||
| 30 | 30 | * | |
| 31 | 31 | */ | |
| 32 | 32 | public class PGraphicsGLW extends PGraphicsOpenGL { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,12 +25,14 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | import javax.media.opengl.GLCapabilities; | |
| 28 | + import javax.media.opengl.GLException; | ||
| 28 | 29 | import javax.media.opengl.GLProfile; | |
| 29 | 30 | ||
| 30 | 31 | import com.jogamp.newt.opengl.GLWindow; | |
| 31 | 32 | import com.jogamp.newt.event.WindowAdapter; | |
| 32 | 33 | import com.jogamp.newt.event.WindowEvent; | |
| 33 | 34 | ||
| 35 | + import processing.core.PGraphics; | ||
| 34 | 36 | import processing.opengl.PGraphicsOpenGL; | |
| 35 | 37 | import processing.opengl.PJOGL; | |
| 36 | 38 | ||
@@ -49,9 +51,43 @@ public PNEWT(PGraphicsOpenGL pg) { | |||
| 49 | 51 | } | |
| 50 | 52 | ||
| 51 | 53 | ||
| 54 | + static public GLWindow getWindow() { | ||
| 55 | + return window; | ||
| 56 | + } | ||
| 57 | + | ||
| 52 | 58 | protected void initSurface(int antialias) { | |
| 53 | 59 | if (profile == null) { | |
| 54 | - profile = GLProfile.getDefault(); | ||
| 60 | + if (PROFILE == 2) { | ||
| 61 | + try { | ||
| 62 | + profile = GLProfile.getGL2ES1(); | ||
| 63 | + } catch (GLException ex) { | ||
| 64 | + profile = GLProfile.getMaxFixedFunc(true); | ||
| 65 | + } | ||
| 66 | + } else if (PROFILE == 3) { | ||
| 67 | + try { | ||
| 68 | + profile = GLProfile.getGL2GL3(); | ||
| 69 | + } catch (GLException ex) { | ||
| 70 | + profile = GLProfile.getMaxProgrammable(true); | ||
| 71 | + } | ||
| 72 | + if (!profile.isGL3()) { | ||
| 73 | + PGraphics.showWarning("Requested profile GL3 but is not available, got: " + profile); | ||
| 74 | + } | ||
| 75 | + } else if (PROFILE == 4) { | ||
| 76 | + try { | ||
| 77 | + profile = GLProfile.getGL4ES3(); | ||
| 78 | + } catch (GLException ex) { | ||
| 79 | + profile = GLProfile.getMaxProgrammable(true); | ||
| 80 | + } | ||
| 81 | + if (!profile.isGL4()) { | ||
| 82 | + PGraphics.showWarning("Requested profile GL4 but is not available, got: " + profile); | ||
| 83 | + } | ||
| 84 | + } else throw new RuntimeException(UNSUPPORTED_GLPROF_ERROR); | ||
| 85 | + | ||
| 86 | + if (2 < PROFILE) { | ||
| 87 | + texVertShaderSource = convertVertexSource(texVertShaderSource, 120, 150); | ||
| 88 | + tex2DFragShaderSource = convertFragmentSource(tex2DFragShaderSource, 120, 150); | ||
| 89 | + texRectFragShaderSource = convertFragmentSource(texRectFragShaderSource, 120, 150); | ||
| 90 | + } | ||
| 55 | 91 | } else { | |
| 56 | 92 | window.removeGLEventListener(listener); | |
| 57 | 93 | pg.parent.remove(canvasNEWT); | |
@@ -74,6 +110,8 @@ protected void initSurface(int antialias) { | |||
| 74 | 110 | window = GLWindow.create(caps); | |
| 75 | 111 | window.setSize(pg.width, pg.height); | |
| 76 | 112 | window.setVisible(true); | |
| 113 | + window.setTitle(pg.parent.frame.getTitle()); | ||
| 114 | + //window.setUndecorated(true); | ||
| 77 | 115 | pg.parent.frame.setVisible(false); | |
| 78 | 116 | ||
| 79 | 117 | canvas = canvasNEWT; | |
@@ -88,6 +126,18 @@ public void windowDestroyNotify(final WindowEvent e) { | |||
| 88 | 126 | ||
| 89 | 127 | registerListeners(); | |
| 90 | 128 | } | |
| 129 | + | ||
| 130 | + protected int getCurrentWidth() { | ||
| 131 | + if (window == null) return 0; | ||
| 132 | + else return window.getWidth(); | ||
| 133 | + } | ||
| 91 | 134 | ||
| 135 | + protected int getCurrentHeight() { | ||
| 136 | + if (window == null) return 0; | ||
| 137 | + else return window.getHeight(); | ||
| 138 | + } | ||
| 92 | 139 | ||
| 140 | + protected boolean displayable() { | ||
| 141 | + return false; | ||
| 142 | + } | ||
| 93 | 143 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments