com.jogamp.opengl.GL2ES2 Java Examples

The following examples show how to use com.jogamp.opengl.GL2ES2. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TextureSeqButton.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) {
    final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory());
    if(corner == 0.0f) {
        createSharpOutline(shape, 0f);
    } else {
        createCurvedOutline(shape, 0f);
    }
    shape.setIsQuadraticNurbs();
    shape.setSharpness(shapesSharpness);
    region.addOutlineShape(shape, null, rgbaColor);
    box.resize(shape.getBounds());

    final float[] ctr = box.getCenter();
    setRotationOrigin( ctr[0], ctr[1], ctr[2]);

    if( DRAW_DEBUG_BOX ) {
        System.err.println("XXX.UIShape.TextureSeqButton: Added Shape: "+shape+", "+box);
    }
}
 
Example #2
Source File: UIGLListener01.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
public void display(final GLAutoDrawable drawable) {
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    final int[] sampleCount = { 4 };
    final float[] translate = button.getTranslate();

    final RegionRenderer regionRenderer = getRegionRenderer();
    final PMVMatrix pmv = regionRenderer.getMatrix();
    pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmv.glLoadIdentity();
    pmv.glTranslatef(getXTran(), getYTran(), getZoom());
    pmv.glRotatef(getAngle(), 0, 1, 0);
    pmv.glTranslatef(translate[0], translate[1], 0);
    button.drawShape(gl, regionRenderer, sampleCount);
}
 
Example #3
Source File: MyParticleSystem.java    From PixelFlow with MIT License 6 votes vote down vote up
public void resize(DwPixelFlow context, int num_particels_x, int num_particels_y){
  this.context = context;
  
  context.begin();
  
  release(); // just in case its not the first resize call
  
  MAX_PARTICLES = particles_x * particles_y;
  System.out.println("ParticelSystem: texture size = "+particles_x+"/"+particles_y +" ("+MAX_PARTICLES+" particles)");
  
  // create shader
  String dir = "data/";
  shader_particleSpawn  = context.createShader(dir + "particleSpawn.frag");
  shader_particleUpdate = context.createShader(dir + "particleUpdate.frag");
  shader_particleRender = context.createShader(dir + "particleRender.glsl", dir + "particleRender.glsl");
  shader_particleRender.vert.setDefine("SHADER_VERT", 1);
  shader_particleRender.frag.setDefine("SHADER_FRAG", 1);

  // allocate texture
  tex_particles.resize(context, GL2ES2.GL_RGBA32F, particles_x, particles_y, GL2ES2.GL_RGBA, GL2ES2.GL_FLOAT, GL2ES2.GL_NEAREST, 4, 4);

  context.end("ParticleSystem.resize");
 
  reset();  // initialize particles
}
 
Example #4
Source File: DwUtils.java    From PixelFlow with MIT License 6 votes vote down vote up
static public void changeTextureFormat(PGraphicsOpenGL pg, int internal_format, int format, int type, int filter, int wrap){
  Texture tex = pg.getTexture();
  if(!tex.available()){
    System.out.println("ERROR DwGLTextureUtils.changeTextureFormat: PGraphicsOpenGL texture not available.");
    return;
  }
  
  PGL pgl = pg.beginPGL();
  pgl.bindTexture  (tex.glTarget, tex.glName);
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_MIN_FILTER, filter); // GL_NEAREST, GL_LINEAR
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_MAG_FILTER, filter); 
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_WRAP_S, wrap);
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_WRAP_T, wrap);
  pgl.texImage2D   (tex.glTarget, 0, internal_format, tex.glWidth, tex.glHeight, 0, format, type, null);
  pgl.bindTexture  (tex.glTarget, 0);
  pg.endPGL();
  
  pg.beginDraw();
  pg.clear();
  pg.endDraw();
}
 
Example #5
Source File: TestTextRendererNEWTBugXXXX.java    From jogl-samples with MIT License 6 votes vote down vote up
void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final Font font, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
    final int height = drawable.getSurfaceHeight();

    int dx = 0;
    int dy = height;
    if(0>row) {
        row = lastRow + 1;
    }
    final AABBox textBox = font.getMetricBounds(text, fontSize);
    dx += font.getAdvanceWidth('X', fontSize) * column;
    dy -= (int)textBox.getHeight() * ( row + 1 );

    final PMVMatrix pmv = renderer.getMatrix();
    pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmv.glLoadIdentity();
    pmv.glTranslatef(dx, dy, z0);
    textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount);

    lastRow = row;
}
 
Example #6
Source File: DwFluidStreamLines2D.java    From PixelFlow with MIT License 6 votes vote down vote up
public void resize(int num_lines_x_, int num_lines_y_){
  
  if(this.lines_x  == num_lines_x_ && 
     this.lines_y  == num_lines_y_ ){
    return;
  }
  
  context.begin();
     
  this.lines_x      = num_lines_x_;
  this.lines_y      = num_lines_y_;

  // create shader
  shader_streamlineInit   = context.createShader(DwPixelFlow.SHADER_DIR+"Streamlines/streamlineInit.frag");
  shader_streamlineUpdate = context.createShader(DwPixelFlow.SHADER_DIR+"Streamlines/streamlineUpdate.frag");
  shader_streamlineRender = context.createShader(DwPixelFlow.SHADER_DIR+"Streamlines/streamlineRender.vert", DwPixelFlow.SHADER_DIR+"Streamlines/streamlineRender.frag");
  
  // allocate texture
  tex_vertices.resize(context, GL2ES2.GL_RG32F, lines_x, lines_y, GL2ES2.GL_RG, GL2ES2.GL_FLOAT, GL2ES2.GL_NEAREST, 2, 4);
  tex_vertices.clear(0);
  
  context.end("Streamlines.resize");
}
 
Example #7
Source File: DwGLSLProgram.java    From PixelFlow with MIT License 6 votes vote down vote up
public static void getProgramInfoLog(GL2ES2 gl, int program_id, String info) {
    if(program_id==-1) return;
    
    IntBuffer log_len = IntBuffer.allocate(1);
    gl.glGetProgramiv(program_id, GL2ES2.GL_INFO_LOG_LENGTH, log_len);

    ByteBuffer buffer = ByteBuffer.allocate(log_len.get(0));
    gl.glGetProgramInfoLog(program_id, log_len.get(0), null, buffer);
    
//    buffer.put(log_len.get(0)-1, (byte) ' ');
    String log = Charset.forName("US-ASCII").decode(buffer).toString();
    
    if( log.length() > 1 && log.charAt(0) != 0){
      System.out.println(info);
      System.out.println(log);
    }
  }
 
Example #8
Source File: TestTextRendererNEWT10.java    From jogl-samples with MIT License 6 votes vote down vote up
void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
    final int height = drawable.getSurfaceHeight();

    int dx = 0;
    int dy = height;
    if(0>row) {
        row = lastRow + 1;
    }
    final AABBox textBox = font.getMetricBounds(text, fontSize);
    dx += font.getAdvanceWidth('X', fontSize) * column;
    dy -= (int)textBox.getHeight() * ( row + 1 );

    final PMVMatrix pmv = renderer.getMatrix();
    pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmv.glLoadIdentity();
    pmv.glTranslatef(dx, dy, z0);
    textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount);

    lastRow = row;
}
 
Example #9
Source File: DwGLFrameBuffer.java    From PixelFlow with MIT License 6 votes vote down vote up
public void allocate(GL2ES2 gl){
    if(!isFBO()){
      this.gl = gl;
      if(gl.isGL3()){
        this.gl3 = gl.getGL3();
      }
      gl.glGenFramebuffers(1, HANDLE_fbo, 0);
      
      int[] buf = new int[1];
//      gl.glGetIntegerv(GL2.GL_MAX_COLOR_ATTACHMENTS, buf, 0);
//      max_color_attachments = buf[0];
      gl.glGetIntegerv(GL2.GL_MAX_DRAW_BUFFERS, buf, 0);
      max_draw_buffers = buf[0];
      
//      max_bind = Math.min(max_draw_buffers, max_color_attachments);
      
//      max_bind = max_draw_buffers;
    }
  }
 
Example #10
Source File: DwGLFrameBuffer.java    From PixelFlow with MIT License 6 votes vote down vote up
public void bind(DwGLTexture ... tex){
 
  if(IS_ACTIVE){
    unbind(); // unbind, in case of bind() is called consecutively
  }
  
  int count = tex.length;  
  if(count > max_draw_buffers){
    System.out.println("WARNING: DwGLFrameBuffer.bind(...) number of textures exceeds max limit: "+count+" > "+max_draw_buffers);
    count = max_draw_buffers;
  }
  bind_color_attachments = new int[count];
  bind_targets           = new int[count];
  
  bindFBO();
  for(int i = 0; i < count; i++){
    bind_color_attachments[i] = GL2ES2.GL_COLOR_ATTACHMENT0 + i;
    bind_targets          [i] = tex[i].target;
    gl.glFramebufferTexture2D(GL2ES2.GL_FRAMEBUFFER, bind_color_attachments[i], tex[i].target, tex[i].HANDLE[0], 0);
  }
  
  
  gl.glDrawBuffers(bind_color_attachments.length, bind_color_attachments, 0);
  IS_ACTIVE = true;
}
 
Example #11
Source File: DwGLFrameBuffer.java    From PixelFlow with MIT License 6 votes vote down vote up
public void bind(DwGLTexture3D[] tex, int[] layer){
 
  if(IS_ACTIVE){
    unbind(); // unbind, in case of bind() is called consecutively
  }

  int count = tex.length;  
  if(count > max_draw_buffers){
    System.out.println("WARNING: DwGLFrameBuffer.bind(...) number of textures exceeds max limit: "+count+" > "+max_draw_buffers);
    count = max_draw_buffers;
  }
  bind_color_attachments = new int[count];
  bind_targets           = new int[count];
  
  bindFBO();
  for(int i = 0; i < count; i++){
    bind_color_attachments[i] = GL2ES2.GL_COLOR_ATTACHMENT0 + i;
    bind_targets          [i] = tex[i].target;
    gl.glFramebufferTexture3D(GL2ES2.GL_FRAMEBUFFER, bind_color_attachments[i], tex[i].target, tex[i].HANDLE[0], 0, layer[i]);
  }
  
  gl.glDrawBuffers(bind_color_attachments.length, bind_color_attachments, 0);
  IS_ACTIVE = true;
}
 
Example #12
Source File: Es_200_draw_elements.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
protected boolean begin(GL gl) {

    GL2ES2 gl2es2 = (GL2ES2) gl;

    boolean validated = true;

    System.out.println("Vendor " + gl2es2.glGetString(GL_VENDOR));
    System.out.println("Renderer " + gl2es2.glGetString(GL_RENDERER));
    System.out.println("Version " + gl2es2.glGetString(GL_VERSION));
    System.out.println("Extensions " + gl2es2.glGetString(GL_EXTENSIONS));

    if (validated) {
        validated = initProgram(gl2es2);
    }
    if (validated) {
        validated = initBuffer(gl2es2);
    }

    return validated;
}
 
Example #13
Source File: DwGLFrameBuffer.java    From PixelFlow with MIT License 6 votes vote down vote up
public void unbind(){ 
  for(int i = 0; i < bind_color_attachments.length; i++){
    if(bind_targets == null && gl3 != null)
    {
      gl3.glFramebufferTexture(GL3.GL_FRAMEBUFFER, bind_color_attachments[i], 0, 0);
    }
    else 
    {
      if(   bind_targets[i] == GL2.GL_TEXTURE_2D_ARRAY
         || bind_targets[i] == GL2.GL_TEXTURE_3D){
        gl.glFramebufferTexture3D(GL2ES2.GL_FRAMEBUFFER, bind_color_attachments[i], bind_targets[i], 0, 0, 0);
      } else {
        gl.glFramebufferTexture2D(GL2ES2.GL_FRAMEBUFFER, bind_color_attachments[i], bind_targets[i], 0, 0);
      }
    }
  }
  bind_color_attachments = new int[0];
  unbindFBO();
  IS_ACTIVE = false;
}
 
Example #14
Source File: UIShape.java    From jogl-samples with MIT License 6 votes vote down vote up
/**
 * Validates the shape's underlying {@link GLRegion}.
 *
 * @param gl
 * @param renderer
 */
public final void validate(final GL2ES2 gl, final RegionRenderer renderer) {
    if( isShapeDirty() || null == region ) {
        box.reset();
        if( null == region ) {
            region = createGLRegion();
        } else {
            region.clear(gl);
        }
        addShapeToRegion(gl, renderer);
        if( DRAW_DEBUG_BOX ) {
            region.clear(gl);
            final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory());
            shape.setSharpness(shapesSharpness);
            shape.setIsQuadraticNurbs();
            region.addOutlineShape(shape, null, rgbaColor);
        }
        region.setQuality(regionQuality);
        dirty &= ~(DIRTY_SHAPE|DIRTY_STATE);
    } else if( isStateDirty() ) {
        region.markStateDirty();
        dirty &= ~DIRTY_STATE;
    }
}
 
Example #15
Source File: UIShape.java    From jogl-samples with MIT License 6 votes vote down vote up
/**
 * Destroys all data
 * @param gl
 * @param renderer
 */
public void destroy(final GL2ES2 gl, final RegionRenderer renderer) {
    destroyImpl(gl, renderer);
    translate[0] = 0f;
    translate[1] = 0f;
    translate[2] = 0f;
    rotation.setIdentity();
    rotOrigin[0] = 0f;
    rotOrigin[1] = 0f;
    rotOrigin[2] = 0f;
    scale[0] = 1f;
    scale[1] = 1f;
    scale[2] = 1f;
    box.reset();
    markShapeDirty();
}
 
Example #16
Source File: UIShape.java    From jogl-samples with MIT License 6 votes vote down vote up
/**
 * Clears all data and reset all states as if this instance was newly created
 * @param gl TODO
 * @param renderer TODO\
 */
public void clear(final GL2ES2 gl, final RegionRenderer renderer) {
    clearImpl(gl, renderer);
    translate[0] = 0f;
    translate[1] = 0f;
    translate[2] = 0f;
    rotation.setIdentity();
    rotOrigin[0] = 0f;
    rotOrigin[1] = 0f;
    rotOrigin[2] = 0f;
    scale[0] = 1f;
    scale[1] = 1f;
    scale[2] = 1f;
    box.reset();
    markShapeDirty();
}
 
Example #17
Source File: GPURegionGLListener02.java    From jogl-samples with MIT License 6 votes vote down vote up
public void display(final GLAutoDrawable drawable) {
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    final RegionRenderer regionRenderer = getRenderer();

    final PMVMatrix pmv = regionRenderer.getMatrix();
    pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmv.glLoadIdentity();
    pmv.glTranslatef(getXTran(), getYTran(), getZTran());
    pmv.glRotatef(getAngle(), 0, 1, 0);
    if( weight != regionRenderer.getRenderState().getWeight() ) {
        regionRenderer.getRenderState().setWeight(weight);
    }
    region.draw(gl, regionRenderer, getSampleCount());

}
 
Example #18
Source File: GPURegionGLListener01.java    From jogl-samples with MIT License 6 votes vote down vote up
public void display(final GLAutoDrawable drawable) {
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    final RegionRenderer regionRenderer = getRenderer();
    final PMVMatrix pmv = regionRenderer.getMatrix();
    pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmv.glLoadIdentity();
    pmv.glTranslatef(getXTran(), getYTran(), getZTran());
    pmv.glRotatef(getAngle(), 0, 1, 0);
    if( weight != regionRenderer.getRenderState().getWeight() ) {
        regionRenderer.getRenderState().setWeight(weight);
    }
    region.draw(gl, regionRenderer, getSampleCount());
}
 
Example #19
Source File: GPUTextGLListener0A.java    From jogl-samples with MIT License 6 votes vote down vote up
public void init(final GLAutoDrawable drawable) {
    if(drawable instanceof GLWindow) {
        final GLWindow glw = (GLWindow) drawable;
        attachInputListenerTo(glw);
    }
    super.init(drawable);

    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    final RenderState rs = getRenderer().getRenderState();

    gl.setSwapInterval(1);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glEnable(GL.GL_BLEND);
    rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
}
 
Example #20
Source File: Compiler.java    From jogl-samples with MIT License 6 votes vote down vote up
public static boolean checkProgram(GL2ES2 gl2, int programName) {

        if (programName == 0) {
            return false;
        }

        int[] result = {GL_FALSE};
        gl2.glGetProgramiv(programName, GL_LINK_STATUS, result, 0);

        if (result[0] == GL_TRUE) {
            return true;
        }

        int[] infoLogLength = {0};
        gl2.glGetProgramiv(programName, GL_INFO_LOG_LENGTH, infoLogLength, 0);
        if (infoLogLength[0] > 0) {
            byte[] buffer = new byte[infoLogLength[0]];
            gl2.glGetProgramInfoLog(programName, infoLogLength[0], null, 0, buffer, 0);
            System.out.println(new String(buffer));
        }

        return result[0] == GL_TRUE;
    }
 
Example #21
Source File: Compiler.java    From jogl-samples with MIT License 6 votes vote down vote up
public static boolean check(GL2ES2 gl2es2, int shaderName) {

        boolean success = true;

        {
            int[] result = {GL_FALSE};
            gl2es2.glGetShaderiv(shaderName, GL_COMPILE_STATUS, result, 0);

            if (result[0] == GL_FALSE) {
                return false;
            }

            int[] infoLogLength = {0};
            gl2es2.glGetShaderiv(shaderName, GL_INFO_LOG_LENGTH, infoLogLength, 0);
            if (infoLogLength[0] > 0) {
                byte[] infoLog = new byte[infoLogLength[0]];
                gl2es2.glGetShaderInfoLog(shaderName, infoLogLength[0], null, 0, infoLog, 0);
                System.out.println(new String(infoLog));
            }

            success = success && result[0] == GL_TRUE;
        }

        return success;
    }
 
Example #22
Source File: DwGLSLShader.java    From PixelFlow with MIT License 6 votes vote down vote up
public static void getShaderInfoLog(GL2ES2 gl, int shader_id, String info) {
  if(shader_id==-1) return;

  IntBuffer log_len = IntBuffer.allocate(1);
  gl.glGetShaderiv(shader_id, GL2ES2.GL_INFO_LOG_LENGTH, log_len);

  ByteBuffer buffer = ByteBuffer.allocate(log_len.get(0));
  gl.glGetShaderInfoLog(shader_id, log_len.get(0), null, buffer);

  String log = Charset.forName("US-ASCII").decode(buffer).toString();

  if( log.length() > 1 && log.charAt(0) != 0){
    System.out.println(info);
    System.out.println(log);
  }
}
 
Example #23
Source File: DwPixelFlow.java    From PixelFlow with MIT License 5 votes vote down vote up
public GL2ES2 begin(){
//    System.out.printf("%"+(scope_depth*2+1)+"s GLScope.begin %d\n", " ", scope_depth);
    if(scope_depth == 0){
      pjogl = (PJOGL) papplet.beginPGL(); 
      gl = pjogl.gl.getGL2ES2();
      framebuffer.allocate(gl);
    }
    scope_depth++;
    return gl;
  }
 
Example #24
Source File: UIListenerBase01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void reshape(final GLAutoDrawable drawable, final int xstart, final int ystart, final int width, final int height) {
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    gl.glViewport(xstart, ystart, width, height);
    rRenderer.reshapePerspective(45.0f, width, height, 0.1f, 7000.0f);
    dumpMatrix();
}
 
Example #25
Source File: DwPixelFlow.java    From PixelFlow with MIT License 5 votes vote down vote up
public void endDraw(){
  if(ACTIVE_FRAMEBUFFER){
    if(framebuffer != null && framebuffer.isActive()){
      framebuffer.unbind();
    } else {
      gl.glBindFramebuffer(GL2ES2.GL_FRAMEBUFFER, 0);
    }
 
    if(pgl_dst != null){
      updateFBO(pgl_dst);
      pgl_dst = null;
    }
  }
  ACTIVE_FRAMEBUFFER = false;
}
 
Example #26
Source File: GLInfo.java    From constellation with Apache License 2.0 5 votes vote down vote up
public GLInfo(final GL gl) {
    final StringBuilder sb = new StringBuilder();
    sb.append(String.format("OpenGL version: %s\n", gl.glGetString(GL.GL_VERSION)));
    sb.append(String.format("Vendor: %s\n", gl.glGetString(GL.GL_VENDOR)));
    sb.append(String.format("Renderer: %s\n", gl.glGetString(GL.GL_RENDERER)));
    if (gl instanceof GL2ES2) {
        sb.append(String.format("Shading language version: %s\n", gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION)));
    }

    basicInfo = sb.toString();
    extensions = gl.glGetString(GL.GL_EXTENSIONS);
}
 
Example #27
Source File: DwGLFrameBuffer.java    From PixelFlow with MIT License 5 votes vote down vote up
public void clearTexture(float r, float g, float b, float a, DwGLTexture ... tex){
  bind(tex);
  int w = tex[0].w();
  int h = tex[0].h();
  gl.glViewport(0, 0, w, h);
  gl.glColorMask(true, true, true, true);
  gl.glClearColor(r,g,b,a);
  gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT);
  unbind();
  DwGLError.debug(gl, "DwGLFrameBuffer.clearTexture");
}
 
Example #28
Source File: DwGLFrameBuffer.java    From PixelFlow with MIT License 5 votes vote down vote up
public void clearTexture(float r, float g, float b, float a, DwGLTexture3D[] tex, int[] layer){
  bind(tex, layer);
  int w = tex[0].w();
  int h = tex[0].h();
  gl.glViewport(0, 0, w, h);
  gl.glColorMask(true, true, true, true);
  gl.glClearColor(r,g,b,a);
  gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT);
  unbind();
  DwGLError.debug(gl, "DwGLFrameBuffer.clearTexture");
}
 
Example #29
Source File: GPURendererListenerBase01.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
    final Object upObj = drawable.getUpstreamWidget();
    if( upObj instanceof Window ) {
        final Window window = (Window) upObj;
        final float[] sDPI = window.getPixelsPerMM(new float[2]);
        sDPI[0] *= 25.4f;
        sDPI[1] *= 25.4f;
        System.err.println("DPI "+sDPI[0]+" x "+sDPI[1]);

        final float[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new float[2]);
        System.err.println("HiDPI PixelScale: "+hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
    }
    autoDrawable = drawable;
    GL2ES2 gl = drawable.getGL().getGL2ES2();
    if(debug) {
        gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ).getGL2ES2();
    }
    if(trace) {
        gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2();
    }
    System.err.println("*** "+gl.getContext().getGLVersion());
    System.err.println("*** GLDebugMessage "+gl.getContext().isGLDebugMessageEnabled());
    MSAATool.dump(drawable);
    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    getRenderer().init(gl, renderModes);
}
 
Example #30
Source File: TextRendererGLELBase.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
    if( null != renderer ) {
        final GL2ES2 gl = drawable.getGL().getGL2ES2();
        renderer.enable(gl, true);
        if( exclusivePMVMatrix ) {
            // renderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 1000.0f);
            renderer.reshapeOrtho(width, height, 0.1f, 1000.0f);
            pixelScale = 1.0f;
        } else {
            renderer.reshapeNotify(width, height);
        }
        renderer.enable(gl, false);
    }
}