@@ -334,6 +334,13 @@ public PGL(PGraphicsOpenGL pg) {
334
334
}
335
335
336
336
337
+ /**
338
+ * Return the native canvas the OpenGL context associated to this PGL object
339
+ * is rendering to (if any).
340
+ */
341
+ public abstract Object getCanvas ();
342
+
343
+
337
344
protected abstract void setFps (float fps );
338
345
339
346
@@ -836,7 +843,7 @@ protected void initTexture(int target, int format, int width, int height,
836
843
int initColor ) {
837
844
int [] glcolor = new int [16 * 16 ];
838
845
Arrays .fill (glcolor , javaToNativeARGB (initColor ));
839
- IntBuffer texels = PGL . allocateDirectIntBuffer (16 * 16 );
846
+ IntBuffer texels = allocateDirectIntBuffer (16 * 16 );
840
847
texels .put (glcolor );
841
848
texels .rewind ();
842
849
for (int y = 0 ; y < height ; y += 16 ) {
@@ -987,8 +994,8 @@ protected void drawTexture2D(int id, int texW, int texH, int scrW, int scrH,
987
994
uniform1i (tex2DSamplerLoc , 0 );
988
995
989
996
texData .position (0 );
990
- bindBuffer (PGL . ARRAY_BUFFER , texGeoVBO );
991
- bufferData (PGL . ARRAY_BUFFER , 16 * SIZEOF_FLOAT , texData , PGL . STATIC_DRAW );
997
+ bindBuffer (ARRAY_BUFFER , texGeoVBO );
998
+ bufferData (ARRAY_BUFFER , 16 * SIZEOF_FLOAT , texData , STATIC_DRAW );
992
999
993
1000
vertexAttribPointer (tex2DVertLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 0 );
994
1001
vertexAttribPointer (tex2DTCoordLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 2 * SIZEOF_FLOAT );
@@ -1113,8 +1120,8 @@ protected void drawTextureRect(int id, int texW, int texH, int scrW, int scrH,
1113
1120
uniform1i (texRectSamplerLoc , 0 );
1114
1121
1115
1122
texData .position (0 );
1116
- bindBuffer (PGL . ARRAY_BUFFER , texGeoVBO );
1117
- bufferData (PGL . ARRAY_BUFFER , 16 * SIZEOF_FLOAT , texData , PGL . STATIC_DRAW );
1123
+ bindBuffer (ARRAY_BUFFER , texGeoVBO );
1124
+ bufferData (ARRAY_BUFFER , 16 * SIZEOF_FLOAT , texData , STATIC_DRAW );
1118
1125
1119
1126
vertexAttribPointer (texRectVertLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 0 );
1120
1127
vertexAttribPointer (texRectTCoordLoc , 2 , FLOAT , false , 4 * SIZEOF_FLOAT , 2 * SIZEOF_FLOAT );
@@ -1193,7 +1200,7 @@ protected static int nextPowerOfTwo(int val) {
1193
1200
* endian) to Java ARGB.
1194
1201
*/
1195
1202
protected static int nativeToJavaARGB (int color ) {
1196
- if (PGL . BIG_ENDIAN ) { // RGBA to ARGB
1203
+ if (BIG_ENDIAN ) { // RGBA to ARGB
1197
1204
return (color >>> 8 ) | ((color << 24 ) & 0xFF000000 );
1198
1205
// equivalent to
1199
1206
// ((color >> 8) & 0x00FFFFFF) | ((color << 24) & 0xFF000000)
@@ -1706,7 +1713,7 @@ protected static ByteBuffer allocateByteBuffer(int size) {
1706
1713
1707
1714
protected static ByteBuffer allocateByteBuffer (byte [] arr ) {
1708
1715
if (USE_DIRECT_BUFFERS ) {
1709
- return PGL . allocateDirectByteBuffer (arr .length );
1716
+ return allocateDirectByteBuffer (arr .length );
1710
1717
} else {
1711
1718
return ByteBuffer .wrap (arr );
1712
1719
}
@@ -1717,7 +1724,7 @@ protected static ByteBuffer updateByteBuffer(ByteBuffer buf, byte[] arr,
1717
1724
boolean wrap ) {
1718
1725
if (USE_DIRECT_BUFFERS ) {
1719
1726
if (buf == null || buf .capacity () < arr .length ) {
1720
- buf = PGL . allocateDirectByteBuffer (arr .length );
1727
+ buf = allocateDirectByteBuffer (arr .length );
1721
1728
}
1722
1729
buf .position (0 );
1723
1730
buf .put (arr );
@@ -1795,7 +1802,7 @@ protected static ShortBuffer allocateShortBuffer(int size) {
1795
1802
1796
1803
protected static ShortBuffer allocateShortBuffer (short [] arr ) {
1797
1804
if (USE_DIRECT_BUFFERS ) {
1798
- return PGL . allocateDirectShortBuffer (arr .length );
1805
+ return allocateDirectShortBuffer (arr .length );
1799
1806
} else {
1800
1807
return ShortBuffer .wrap (arr );
1801
1808
}
@@ -1806,7 +1813,7 @@ protected static ShortBuffer updateShortBuffer(ShortBuffer buf, short[] arr,
1806
1813
boolean wrap ) {
1807
1814
if (USE_DIRECT_BUFFERS ) {
1808
1815
if (buf == null || buf .capacity () < arr .length ) {
1809
- buf = PGL . allocateDirectShortBuffer (arr .length );
1816
+ buf = allocateDirectShortBuffer (arr .length );
1810
1817
}
1811
1818
buf .position (0 );
1812
1819
buf .put (arr );
@@ -1884,7 +1891,7 @@ protected static IntBuffer allocateIntBuffer(int size) {
1884
1891
1885
1892
protected static IntBuffer allocateIntBuffer (int [] arr ) {
1886
1893
if (USE_DIRECT_BUFFERS ) {
1887
- return PGL . allocateDirectIntBuffer (arr .length );
1894
+ return allocateDirectIntBuffer (arr .length );
1888
1895
} else {
1889
1896
return IntBuffer .wrap (arr );
1890
1897
}
@@ -1895,7 +1902,7 @@ protected static IntBuffer updateIntBuffer(IntBuffer buf, int[] arr,
1895
1902
boolean wrap ) {
1896
1903
if (USE_DIRECT_BUFFERS ) {
1897
1904
if (buf == null || buf .capacity () < arr .length ) {
1898
- buf = PGL . allocateDirectIntBuffer (arr .length );
1905
+ buf = allocateDirectIntBuffer (arr .length );
1899
1906
}
1900
1907
buf .position (0 );
1901
1908
buf .put (arr );
@@ -1972,7 +1979,7 @@ protected static FloatBuffer allocateFloatBuffer(int size) {
1972
1979
1973
1980
protected static FloatBuffer allocateFloatBuffer (float [] arr ) {
1974
1981
if (USE_DIRECT_BUFFERS ) {
1975
- return PGL . allocateDirectFloatBuffer (arr .length );
1982
+ return allocateDirectFloatBuffer (arr .length );
1976
1983
} else {
1977
1984
return FloatBuffer .wrap (arr );
1978
1985
}
@@ -1983,7 +1990,7 @@ protected static FloatBuffer updateFloatBuffer(FloatBuffer buf, float[] arr,
1983
1990
boolean wrap ) {
1984
1991
if (USE_DIRECT_BUFFERS ) {
1985
1992
if (buf == null || buf .capacity () < arr .length ) {
1986
- buf = PGL . allocateDirectFloatBuffer (arr .length );
1993
+ buf = allocateDirectFloatBuffer (arr .length );
1987
1994
}
1988
1995
buf .position (0 );
1989
1996
buf .put (arr );
0 commit comments