com.jogamp.opengl.GL2 Java Examples

The following examples show how to use com.jogamp.opengl.GL2. 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: KeystoneHelper.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public void finishRenderToTexture() {
	if (drawKeystoneHelper) {
		drawKeystoneMarks();
	}
	// gl.glDisable(GL2.GL_DEPTH_TEST); // disables depth testing
	final AbstractPostprocessingShader theShader = getShader();
	// unbind the last fbo
	if (fboScene != null) {
		// We verify if it is not null
		fboScene.unbindCurrentFrameBuffer();
		// prepare shader
		theShader.start();
		prepareShader(theShader);
		// build the surface
		createScreenSurface();
		// draw
		final GL2 gl = getGL();
		gl.glDrawElements(GL2.GL_TRIANGLES, 6, GL2.GL_UNSIGNED_INT, 0);
		theShader.stop();
	}

}
 
Example #2
Source File: Shader.java    From Ultraino with MIT License 6 votes vote down vote up
void getUniforms(GL2 gl){
       vertexHandle = gl.glGetAttribLocation(shaderProgramID, "vertexPosition");
normalHandle = gl.glGetAttribLocation(shaderProgramID, "vertexNormal");
textureCoordHandle = gl.glGetAttribLocation(shaderProgramID, "vertexTexCoord");

       lightPosHandle = gl.glGetUniformLocation(shaderProgramID, "lightPos");
eyePosHandle = gl.glGetUniformLocation(shaderProgramID, "eyePos");
       
       mvpMatrixHandle = gl.glGetUniformLocation(shaderProgramID, "modelViewProjectionMatrix");
mvMatrixHandle = gl.glGetUniformLocation(shaderProgramID, "modelViewMatrix");
       mMatrixHandle = gl.glGetUniformLocation(shaderProgramID, "modelMatrix");
       
colorHandle = gl.glGetUniformLocation(shaderProgramID, "colorMod");
ambient = gl.glGetUniformLocation(shaderProgramID, "ambient");
diffuse = gl.glGetUniformLocation(shaderProgramID, "diffuse");
specular = gl.glGetUniformLocation(shaderProgramID, "specular");
shininess = gl.glGetUniformLocation(shaderProgramID, "shininess");
       texDiffuse = gl.glGetUniformLocation(shaderProgramID, "texSampler2D");
   }
 
Example #3
Source File: Local.java    From aparapi-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Render all particles to the OpenGL context
 * @param gl
 */

protected void render(GL2 gl) {
   gl.glBegin(GL2.GL_QUADS);

   for (int i = 0; i < (range.getGlobalSize(0) * 3); i += 3) {
      gl.glTexCoord2f(0, 1);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]);
      gl.glTexCoord2f(0, 0);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 0);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 1);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]);
   }
   gl.glEnd();
}
 
Example #4
Source File: Lighting.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Constructor
 * @param far Far light position or not
 */
public Lighting(boolean far) {        
    this.enable = false;
    this.light = GL2.GL_LIGHT0;
    //this.ambient = new float[]{0.f, 0.f, 0.f, 1.f};
    this.ambient = new float[]{0.2f, 0.2f, 0.2f, 1.f};
    this.diffuse = new float[]{1.f, 1.f, 1.f, 1.f};
    this.specular = new float[]{1.f, 1.f, 1.f, 1.f};
    if (far)
        this.position = new float[]{0.f, 0.f, 1.f, 0.f};
    else
        this.position = new float[]{-1.f, -1.f, 1.f, 1.f};
    this.mat_ambient = new float[]{0.2f, 0.2f, 0.2f, 1.f};
    this.mat_diffuse = new float[]{0.8f, 0.8f, 0.8f, 1.f};
    this.mat_specular = new float[]{ 0.0f, 0.0f, 0.0f, 1.0f };
    this.mat_shininess = 50.0f;
}
 
Example #5
Source File: Skylight_BasicGUI.java    From PixelFlow with MIT License 6 votes vote down vote up
public boolean resizeScene(){
  
  viewport_w = width;
  viewport_h = height;

  boolean[] RESIZED = {false};
  
  pg_aa     = DwUtils.changeTextureSize(this, pg_aa    , width, height, 0, RESIZED);
  pg_render = DwUtils.changeTextureSize(this, pg_render, width, height, 0, RESIZED);
  pg_tmp    = DwUtils.changeTextureSize(this, pg_tmp   , width, height, 0, RESIZED, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT);

  skylight.resize(width, height);
  
  if(RESIZED[0]){
    // nothing here
  }
  peasycam.feed();
  perspective(60 * DEG_TO_RAD, width/(float)height, 2, clip_z_far);
  
  return RESIZED[0];
}
 
Example #6
Source File: ViewportEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public void renderPick(GL2 gl2,double pickX,double pickY) {
       gl2.glMatrixMode(GL2.GL_PROJECTION);
       gl2.glLoadIdentity();
       
       // get the current viewport dimensions to set up the projection matrix
       int[] viewportDimensions = new int[4];
	gl2.glGetIntegerv(GL2.GL_VIEWPORT,viewportDimensions,0);

	GLU glu = GLU.createGLU(gl2);
       
	// Set up a tiny viewport that only covers the area behind the cursor. 
	// Tiny viewports are faster.
	glu.gluPickMatrix(pickX, canvasHeight-pickY, 5.0, 5.0, viewportDimensions,0);

	if(drawOrtho.get()) {
		renderOrtho(gl2);
	} else {
		renderPerspective(gl2);
	}
	
	renderShared(gl2);
}
 
Example #7
Source File: Shadertoy_MengerSponge.java    From PixelFlow with MIT License 6 votes vote down vote up
public void setup() {
  surface.setResizable(true);
  
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  toy = new DwShadertoy(context, "data/MengerSponge.frag");
  
  pg_albedo = (PGraphics2D) createGraphics(512, 512, P2D);
  DwUtils.changeTextureWrap  (pg_albedo, GL2.GL_MIRRORED_REPEAT);
  DwUtils.changeTextureFilter(pg_albedo, GL2.GL_LINEAR, GL2.GL_LINEAR);
  
  pg_albedo.beginDraw();
  pg_albedo.background(200,100,5);
  pg_albedo.endDraw();
  
  frameRate(60);
}
 
Example #8
Source File: DwOpticalFlow.java    From PixelFlow with MIT License 6 votes vote down vote up
public boolean resize(DwPixelFlow context_, int w, int h, boolean grayscale){
  int internalformat = grayscale ? GL2.GL_R16F : GL2.GL_RGBA16F;
  int format         = grayscale ? GL2.GL_RED  : GL2.GL_RGBA;
  int channels       = grayscale ? 1           : 4;

  this.context = context_;
  this.w = w;
  this.h = h;
    
  context.begin();
  boolean resized = false;
  resized |= frame   .resize(context, internalformat, w, h, format     , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, channels, 2);
  resized |= sobelH  .resize(context, internalformat, w, h, format     , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, channels, 2);
  resized |= sobelV  .resize(context, internalformat, w, h, format     , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, channels, 2);
  resized |= velocity.resize(context, GL2.GL_RG16F  , w, h, GL2.GL_RG  , GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, 2       , 2);
  resized |= tmp     .resize(context, GL2.GL_RGBA16F, w, h, GL2.GL_RGBA, GL2.GL_FLOAT, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, 4       , 2);
  context.end();
  return resized;
}
 
Example #9
Source File: Triangle.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        Triangle tr = new Triangle();
        gc.addGLEventListener(tr);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Triangle");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent windowevent) {
                frame.dispose();
                System.exit(0);
            }
        });
        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);
    }
 
Example #10
Source File: J3DBasic.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        J3DBasic b = new J3DBasic();
        gc.addGLEventListener(b);
        gc.setSize(600, 400);

        final JFrame frame = new JFrame("JOGL 3D");

        frame.getContentPane().add(gc);
        frame.setSize(frame.getContentPane().getPreferredSize());
        frame.setVisible(true);
    }
 
Example #11
Source File: PrimitiveSolids.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * draw box based on two corners
 * @param gl2
 * @param bottom minimum bounds
 * @param top maximum bounds
 */
static public void drawBoxWireframe(GL2 gl2,Point3d bottom,Point3d top) {
	gl2.glDisable(GL2.GL_TEXTURE_2D);
	boolean lightWasOn = OpenGLHelper.disableLightingStart(gl2);
	
	double x0=bottom.x;
	double y0=bottom.y;
	double z0=bottom.z;
	double x1=top.x;
	double y1=top.y;
	double z1=top.z;

	gl2.glBegin(GL2.GL_LINE_LOOP);	gl2.glNormal3f( 0, 0,-1);	gl2.glVertex3d(x0,y1,z0);	gl2.glVertex3d(x1,y1,z0);	gl2.glVertex3d(x1,y0,z0);	gl2.glVertex3d(x0,y0,z0);	gl2.glEnd();  // bottom	
	gl2.glBegin(GL2.GL_LINE_LOOP);	gl2.glNormal3f( 0, 0, 1);	gl2.glVertex3d(x1,y1,z1);	gl2.glVertex3d(x0,y1,z1);	gl2.glVertex3d(x0,y0,z1);	gl2.glVertex3d(x1,y0,z1);	gl2.glEnd();  // top
	gl2.glBegin(GL2.GL_LINE_LOOP);	gl2.glNormal3f( 0, 1, 0);	gl2.glVertex3d(x0,y1,z1);	gl2.glVertex3d(x1,y1,z1);	gl2.glVertex3d(x1,y1,z0);	gl2.glVertex3d(x0,y1,z0);	gl2.glEnd();  // side
	gl2.glBegin(GL2.GL_LINE_LOOP);	gl2.glNormal3f( 0,-1, 0);	gl2.glVertex3d(x1,y0,z1);	gl2.glVertex3d(x0,y0,z1);	gl2.glVertex3d(x0,y0,z0);	gl2.glVertex3d(x1,y0,z0);	gl2.glEnd();
	gl2.glBegin(GL2.GL_LINE_LOOP);	gl2.glNormal3f( 1, 0, 0);	gl2.glVertex3d(x1,y1,z0);	gl2.glVertex3d(x1,y1,z1);	gl2.glVertex3d(x1,y0,z1);	gl2.glVertex3d(x1,y0,z0);	gl2.glEnd();
	gl2.glBegin(GL2.GL_LINE_LOOP);	gl2.glNormal3f(-1, 0, 0);	gl2.glVertex3d(x0,y0,z1);	gl2.glVertex3d(x0,y1,z1);	gl2.glVertex3d(x0,y1,z0);	gl2.glVertex3d(x0,y0,z0);	gl2.glEnd();

	OpenGLHelper.disableLightingEnd(gl2,lightWasOn);
}
 
Example #12
Source File: ArrowHead.java    From depan with Apache License 2.0 6 votes vote down vote up
/**
 * Draws and fills an arrowhead on the given <code>GL</code> instantiation.
 * The actual shape depends on the Arrowhead object that is being drawn.
 *
 * @param gl Graphics object that will draw this object.
 */
@Override
public void fill(GL2 gl) {
  // points must be use with the correct order (2-3-0-1) to use triangle fan.
  gl.glPushMatrix();
  float[] translate = GLScene.P(translateX, translateY);
  gl.glTranslatef(translate[0], translate[1], translate[2]);
  gl.glScalef(scaleX, scaleY, scaleZ);
  gl.glRotated(rotation * 180 / Math.PI, 0, 0, 1);
  gl.glBegin(GL2.GL_TRIANGLE_FAN);
  GLPanel.V(gl, controlPoints[2].x, controlPoints[2].y);
  // check if there exists 4 points before drawing the 4th point
  if (controlPoints.length == 4) {
    GLPanel.V(gl, controlPoints[3].x, controlPoints[3].y);
  }
  GLPanel.V(gl, controlPoints[0].x, controlPoints[0].y);
  GLPanel.V(gl, controlPoints[1].x, controlPoints[1].y);
  gl.glEnd();
  gl.glPopMatrix();
}
 
Example #13
Source File: DelaunayTriangulationExample.java    From delaunay-triangulator with MIT License 6 votes vote down vote up
public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glDisable(GL.GL_CULL_FACE);
    gl.glShadeModel(GL2.GL_SMOOTH);
    gl.glClearColor(COLOR_BACKGROUND.getRed() / 255.0f, COLOR_BACKGROUND.getGreen() / 255.0f,
            COLOR_BACKGROUND.getBlue() / 255.0f, 1);
    gl.glClearDepth(1.0f);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glDepthFunc(GL.GL_LEQUAL);
    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

    gl.setSwapInterval(1);
    gl.glDisable(GL2.GL_CULL_FACE);

    delaunayTriangulator = new DelaunayTriangulator(pointSet);
}
 
Example #14
Source File: DwFlowField.java    From PixelFlow with MIT License 6 votes vote down vote up
public void blur(int iterations, int radius){
  if(!tex_vel.isTexture() || iterations <= 0 || radius <= 0){
    return;
  }
  
  tex_tmp.resize(context, tex_vel);
  tex_tmp.setParamWrap(GL2.GL_MIRRORED_REPEAT);
  tex_vel.setParamWrap(GL2.GL_MIRRORED_REPEAT);
  
  for(int i = 0; i < iterations; i++){
    DwFilter.get(context).gaussblur.apply(tex_vel, tex_vel, tex_tmp, radius);
  }
  
  tex_vel.setParamWrap(tex_wrap);
  context.errorCheck("FlowField.blur()");
}
 
Example #15
Source File: Robot_GMF_M100.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void render(GL2 gl2) {
	gl2.glPushMatrix();
		MatrixHelper.applyMatrix(gl2, this.getPose());	
		// Draw models
		float r=1;
		float g=217f/255f;
		float b=33f/255f;
		MaterialEntity mat = new MaterialEntity();
		mat.setDiffuseColor(r,g,b,1);
		mat.render(gl2);
		live.render(gl2);
	gl2.glPopMatrix();
	
	super.render(gl2);
}
 
Example #16
Source File: ModelScene.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public void draw(final OpenGL gl) {

		gl.push(GL2.GL_MODELVIEW);
		gl.setZIncrement(zIncrement);

		layers.forEach((name, layer) -> {
			if (layer != null && !layer.isInvalid()) {
				try {
					layer.draw(gl);
					layer.lock();
				} catch (final RuntimeException r) {
					DEBUG.ERR("Runtime error " + r.getMessage() + " in OpenGL loop");
					r.printStackTrace();
				}
			}
		});
		gl.setZIncrement(0);
		rendered = true;
		gl.pop(GL2.GL_MODELVIEW);
	}
 
Example #17
Source File: AWTShape.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
public void draw(GL2 gl) {
  gl.glPushMatrix();
  gl.glTranslatef(translateX, translateY, translateZ);
  gl.glScalef(scaleX, scaleY, scaleZ);
  draw(gl, shape);
  gl.glPopMatrix();
}
 
Example #18
Source File: FrameBufferObject.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private int createDepthBufferAttachment(final int width, final int height) {
	gl.glGenRenderbuffers(1, depthBufferArray, 0);
	gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, depthBufferArray[0]);
	gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER, GL2.GL_DEPTH_COMPONENT, width, height);
	gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER, GL2.GL_DEPTH_ATTACHMENT, GL2.GL_RENDERBUFFER,
			depthBufferArray[0]);
	return depthBufferArray[0];
}
 
Example #19
Source File: GLScene.java    From depan with Apache License 2.0 5 votes vote down vote up
public static void convertGLVertex(GL2 gl,
    float x, float y, float z,
    float a, float b, float c,
    float k, float h, float p) {

  float[] result = convertVertex(x, y, z, a, b, c, k, h, p);
  //System.out.println(""+x+":"+y+":"+z);
  gl.glVertex3f(result[0], result[1], result[3]);
}
 
Example #20
Source File: Shadertoy_PlasmaGlobe.java    From PixelFlow with MIT License 5 votes vote down vote up
public void setup() {
  surface.setResizable(true);
  
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  toy = new DwShadertoy(context, "data/PlasmaGlobe.frag");
  
  // create noise texture
  // TODO 
  // Figure out how Shadertoy noise textures really work
  // https://shadertoyunofficial.wordpress.com/
  int wh = 256;
  byte[] bdata = new byte[wh * wh * 4];
  ByteBuffer bbuffer = ByteBuffer.wrap(bdata);
  for(int i = 0; i < bdata.length; i+= 4){
    bdata[i+0] = (byte) random(0, 255);
    bdata[i+1] = (byte) random(0, 255);
    bdata[i+2] = (byte) random(0, 255);
    bdata[i+3] = (byte) random(0, 255);
  }
  
  tex_noise.resize(context, GL2.GL_RGBA8, wh, wh, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, GL2.GL_LINEAR, GL2.GL_MIRRORED_REPEAT, 4, 1, bbuffer);
  tex_noise.generateMipMap();
  
  frameRate(60);
}
 
Example #21
Source File: Renderer.java    From Ultraino with MIT License 5 votes vote down vote up
void enableWriteColor(GL2 gl, boolean enabled){
    if (enabled != writeColor){
        if (enabled){
            gl.glColorMask(true, true, true, true);
        }else{
            gl.glColorMask(false, false, false, false);
        }
        writeColor = enabled;
    }
}
 
Example #22
Source File: AbstractShader.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
protected AbstractShader(final GL2 gl, final String vertexFile, final String fragmentFile) {
	this.gl = gl;
	InputStream vertexInputStream, fragmentInputStream;

	try {
		vertexInputStream = getClass().getResourceAsStream(vertexFile);
		if (vertexInputStream == null) {
			throw new RuntimeException("Cannot locate vertex shader program " + vertexFile);
		}
		fragmentInputStream = getClass().getResourceAsStream(fragmentFile);
		if (fragmentInputStream == null) {
			throw new RuntimeException("Cannot locate vertex shader program " + vertexFile);
		}
	} catch (final Exception e) {
		DEBUG.ERR(e.getMessage());
		vertexShaderID = -1;
		fragmentShaderID = -1;
		return;
	}

	vertexShaderID = loadShader(vertexInputStream, GL2.GL_VERTEX_SHADER);
	fragmentShaderID = loadShader(fragmentInputStream, GL2.GL_FRAGMENT_SHADER);

	// Each shaderProgram must have
	// one vertex shader and one fragment shader.
	programID = this.gl.glCreateProgram();
	this.gl.glAttachShader(programID, vertexShaderID);
	this.gl.glAttachShader(programID, fragmentShaderID);

	// Associate attribute ids with the attribute names inside
	// the vertex shader.
	bindAttributes();

	this.gl.glLinkProgram(programID);
	this.gl.glValidateProgram(programID);

	getAllUniformLocations();
}
 
Example #23
Source File: ViewportEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
public void renderShared(GL2 gl2) {
	// store the projection matrix for later
       double [] m = new double[16];
       gl2.glGetDoublev(GL2.GL_PROJECTION_MATRIX, m, 0);
       projectionMatrix.set(m);

   	gl2.glMatrixMode(GL2.GL_MODELVIEW);
       gl2.glLoadIdentity();
   	
	PoseEntity camera = getAttachedTo();
	Matrix4d mFinal = camera.getPoseWorld();
	mFinal.invert();
	MatrixHelper.applyMatrix(gl2, mFinal);
}
 
Example #24
Source File: OpenGLGFXCMD.java    From sagetv with Apache License 2.0 5 votes vote down vote up
private void drawGLCurve(GL2 gl, float x, float y, float width, float height,
    float angs, float ange, int subdiv, int tlc, int trc, int brc, int blc,
    int xc, int yc, int widthc, int heightc, boolean full,
    int thickness)
{
  if(full)
  {
    gl.glBegin(gl.GL_TRIANGLE_FAN);
    setInterpolatedGLColor(gl, tlc, trc, brc, blc,
        x-xc, y-yc, widthc, heightc);
    gl.glVertex2f(x, y);
  }
  else
  {
    gl.glLineWidth(thickness);
    gl.glBegin(gl.GL_LINE_STRIP);
  }

  for(int i=0; i<=subdiv; i++)
  {
    float posx, posy;
    float ang=angs+(ange-angs)*i/subdiv;
    posx=width * (float)java.lang.Math.cos(ang);
    posy=height * (float)java.lang.Math.sin(ang);
    setInterpolatedGLColor(gl, tlc, trc, brc, blc,
        posx+x-xc, posy+y-yc, widthc, heightc);
    gl.glVertex2f(x + posx, y + posy);
    //System.out.println("x: "+(x+posx)+" y: "+(y+posy));
  }
  gl.glEnd();
}
 
Example #25
Source File: BasicLine.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLJPanel gc = new GLJPanel(cap);
        BasicLine bl = new BasicLine();
        gc.addGLEventListener(bl);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Line");
        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);
    }
 
Example #26
Source File: FXAA.java    From PixelFlow with MIT License 5 votes vote down vote up
protected void setLinearTextureFiltering(int handle_tex){
  context.begin();
  context.gl.glBindTexture      (tex_target, handle_tex);
  context.gl.glGetTexParameteriv(tex_target, GL2ES2.GL_TEXTURE_MIN_FILTER, filter_minmag, 0);
  context.gl.glGetTexParameteriv(tex_target, GL2ES2.GL_TEXTURE_MAG_FILTER, filter_minmag, 1);
  context.gl.glTexParameteri    (tex_target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
  context.gl.glTexParameteri    (tex_target, GL2ES2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
  context.gl.glBindTexture      (tex_target, 0);
  context.end();
}
 
Example #27
Source File: GLScene.java    From depan with Apache License 2.0 5 votes vote down vote up
public static void V(GL2 gl, float x, float y) {
  if (!hyperbolic) {
    gl.glVertex2f(x, y);
  } else {
    //FIXME: uncomment. when grip static is totally fixed
    //x = x+grip.xoff;
    //y = y+grip.yoff;
    convertGLVertex(
        gl, x-GLConstants.FACTOR/2.0f, y-GLConstants.FACTOR/2.0f);
  }
}
 
Example #28
Source File: JLight.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();
    gl.glColor3f(1f, 0f, 0f);
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glRotatef(rotation, 1.0f, 1.0f, 0.0f);

    gl.glBegin(GL2.GL_TRIANGLES);

    gl.glVertex2d(0, 0.5);

    gl.glVertex2d(-0.5, -0.5);

    gl.glVertex2d(0.5, -0.5);

    gl.glEnd();

    gl.glFlush();
    //Angle  
    rotation += 0.6f;

    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_LIGHT0);
    gl.glEnable(GL2.GL_DEPTH_TEST);

    float[] ambientLight = {0f, 0f, 1f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambientLight, 0);

    float[] specularLight = {1f, 0f, 0f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specularLight, 0);

    float[] diffuseLight = {1f, 0f, 0f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuseLight, 0);
}
 
Example #29
Source File: PoseEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
public void renderLineage(GL2 gl2) {
	boolean isTex = gl2.glIsEnabled(GL2.GL_TEXTURE_2D);
	gl2.glDisable(GL2.GL_TEXTURE_2D);

	// save the lighting mode
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);

	IntBuffer depthFunc = IntBuffer.allocate(1);
	gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc);
	gl2.glDepthFunc(GL2.GL_ALWAYS);
	//boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	//gl2.glDisable(GL2.GL_DEPTH_TEST);

	gl2.glColor4d(1,1,1,1);
	gl2.glBegin(GL2.GL_LINES);
	// connection to children
	for(Entity e : children ) {
		if(e instanceof PoseEntity) {					
			Vector3d p = ((PoseEntity)e).getPosition();
			gl2.glVertex3d(0, 0, 0);
			gl2.glVertex3d(p.x,p.y,p.z);
		}
	}
	gl2.glEnd();

	//if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
	gl2.glDepthFunc(depthFunc.get());
	// restore lighting
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(isTex) gl2.glDisable(GL2.GL_TEXTURE_2D);
}
 
Example #30
Source File: CameraEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void render(GL2 gl2) {
	gl2.glPushMatrix();
		MatrixHelper.applyMatrix(gl2, pose);
		PrimitiveSolids.drawStar(gl2, 10);
	gl2.glPopMatrix();
}