1919import org .jbox2d .dynamics .World ;
2020import com .jogamp .opengl .GL ;
2121import com .jogamp .opengl .GL2ES1 ;
22+ import com .jogamp .opengl .GL2ES3 ;
2223import com .jogamp .opengl .GL3 ;
2324import com .thomasdiewald .liquidfun .java .DwViewportTransform ;
2425
@@ -45,7 +46,7 @@ public class DwParticleRenderGL extends DwParticleRender{
4546 static public final String SHADER_DIR = "/com/thomasdiewald/liquidfun/glsl/" ;
4647
4748 // GL
48- protected GL3 gl ;
49+ protected GL2ES3 gl ;
4950 protected PJOGL pgl ;
5051
5152 // Shader
@@ -71,13 +72,15 @@ public class DwParticleRenderGL extends DwParticleRender{
7172 , "#version 150 " + NL
7273 , " " + NL
7374 , "uniform mat4 mat_mvp; " + NL
75+ , "uniform float point_size; " + NL
7476 , " " + NL
7577 , "in vec2 pos; " + NL
7678 , "in vec4 col; " + NL
7779 , "out vec4 tint; " + NL
7880 , " " + NL
7981 , "void main() { " + NL
8082 , " gl_Position = mat_mvp * vec4(pos, 0, 1); " + NL
83+ , " gl_PointSize = point_size; " + NL
8184 , " tint = col; " + NL
8285 , "} " + NL
8386 };
@@ -201,6 +204,8 @@ public void display(PGraphics2D canvas){
201204
202205 shader .set ("mat_mvp" , mat_mvp );
203206 shader .set ("tex_sprite" , param .tex_sprite );
207+ shader .set ("point_size" , particle_rad_screen * 2 );
208+
204209 errCheck ("DwParticleRenderGL.display-uniforms" );
205210
206211 // shader vertex attribute: position
@@ -238,18 +243,22 @@ public void display(PGraphics2D canvas){
238243 gl .glBindBuffer (GL .GL_ARRAY_BUFFER , 0 );
239244 errCheck ("DwParticleRenderGL.display-buffers" );
240245
241-
246+
247+
242248 // settings
243- // gl.glEnable(GL.GL_MULTISAMPLE );
249+ // https://github.com/diwi/LiquidFunProcessing/issues/2
244250// gl.glEnable(GL2.GL_POINT_SMOOTH);
251+ // gl.glEnable(GL3.GL_VERTEX_PROGRAM_POINT_SIZE);
252+ // gl.glPointSize(particle_rad_screen * 2);
253+
254+ // ... f***ing OpenGL mess
245255 gl .glEnable (GL3 .GL_PROGRAM_POINT_SIZE );
246- gl .glEnable (GL3 .GL_VERTEX_PROGRAM_POINT_SIZE );
247256 gl .glEnable (GL2ES1 .GL_POINT_SPRITE );
248- gl . glPointSize ( particle_rad_screen * 2 );
257+
249258 errCheck ("DwParticleRenderGL.display-pointRendering" );
250259
251260
252-
261+
253262 // draw particles as points (see fragment shader for details)
254263 if (USE_GROUPS )
255264 {
@@ -263,13 +272,13 @@ public void display(PGraphics2D canvas){
263272 }
264273 int off = group_offsets [id ];
265274 int len = group_lengths [id ];
266- gl .glDrawElements (GL3 .GL_POINTS , len , GL .GL_UNSIGNED_INT , off * 4 );
275+ gl .glDrawElements (GL .GL_POINTS , len , GL .GL_UNSIGNED_INT , off * 4 );
267276 }
268277 gl .glBindBuffer (GL .GL_ELEMENT_ARRAY_BUFFER , 0 );
269278 errCheck ("DwParticleRenderGL.display-glDrawElements" );
270279 }
271280 else {
272- gl .glDrawArrays (GL3 .GL_POINTS , 0 , particle_num );
281+ gl .glDrawArrays (GL .GL_POINTS , 0 , particle_num );
273282 errCheck ("DwParticleRenderGL.display-glDrawArrays" );
274283 }
275284
@@ -292,7 +301,7 @@ public void display(PGraphics2D canvas){
292301 protected void beginGL (){
293302 if (gl == null ){
294303 pgl = (PJOGL ) papplet .beginPGL ();
295- gl = pgl .gl .getGL3 ();
304+ gl = pgl .gl .getGL2ES3 ();
296305 }
297306 }
298307
0 commit comments