Package javax.media.opengl

Examples of javax.media.opengl.GL


    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public void display(GLAutoDrawable glDrawable) {
        GL gl = glDrawable.getGL();

        // Store old matrices
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glPushMatrix();
        gl.glLoadIdentity();
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glPushMatrix();
        gl.glLoadIdentity();

        gl.glViewport(0, 0, glDrawable.getWidth(), glDrawable.getHeight());

        // Store enabled state and disable lighting, texture mapping and the depth buffer
        gl.glPushAttrib(GL.GL_ENABLE_BIT);
        gl.glDisable(GL.GL_BLEND);
        gl.glDisable(GL.GL_LIGHTING);
        gl.glDisable(GL.GL_TEXTURE_2D);
        gl.glDisable(GL.GL_DEPTH_TEST);

        // Retrieve the current viewport and switch to orthographic mode
        IntBuffer viewPort = BufferUtil.newIntBuffer(4);
        gl.glGetIntegerv(GL.GL_VIEWPORT, viewPort);
        glu.gluOrtho2D(0, viewPort.get(2), viewPort.get(3), 0);

        // Render the text
        gl.glColor3f(1, 1, 1);

        int x = OFFSET;
        int maxx = 0;
        int y = OFFSET + CHAR_HEIGHT;

        if (keyboardEntries.size() > 0) {
            gl.glRasterPos2i(x, y);
            glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, KEYBOARD_CONTROLS);
            maxx = Math.max(maxx, OFFSET + glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, KEYBOARD_CONTROLS));

            y += OFFSET;
            x += INDENT;
            for (int i = 0; i < keyboardEntries.size(); i++) {
                gl.glRasterPos2f(x, y);
                String text = (String) keyboardEntries.get(i);
                glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, text);
                maxx = Math.max(maxx, OFFSET + glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, text));
                y += OFFSET;
            }
        }

        if (mouseEntries.size() > 0) {
            x = maxx + OFFSET;
            y = OFFSET + CHAR_HEIGHT;
            gl.glRasterPos2i(x, y);
            glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, MOUSE_CONTROLS);

            y += OFFSET;
            x += INDENT;
            for (int i = 0; i < mouseEntries.size(); i++) {
                gl.glRasterPos2f(x, y);
                glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, (String) mouseEntries.get(i));
                y += OFFSET;
            }
        }

        // Restore enabled state
        gl.glPopAttrib();

        // Restore old matrices
        gl.glPopMatrix();
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glPopMatrix();
    }
View Full Code Here


   * Main loop
   */
  public void display(GLAutoDrawable arg0) {
    if(!draw) return;
   
    GL gl = arg0.getGL();
   
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)//Clear the buffers
    gl.glLoadIdentity();                      //Reset the view
    gl.glTranslatef(0.0f, -2.0f, zOffset);              //Translate the scene backwards   
   
    gl.glPolygonMode(GL.GL_FRONT_AND_BACK, render_mode);
    gl.glCullFace(GL.GL_FRONT);
    gl.glEnable(GL.GL_CULL_FACE);/**/
   
        gl.glRotatef(xRot, 1f, 0f, 0f);
        gl.glRotatef(yRot, 0f, 1f, 0f);
        gl.glRotatef(zRot, 0f, 0f, 1f);

        // render the mechs
    for(int x=0;x<16;x++){
      for(int y=0;y<16;y++){
        mechNoLOT(gl, x, y);
View Full Code Here

  }
 

 
  public void reshape(GLAutoDrawable glDrawable, int x, int y, int width, int height) {
    final GL gl = glDrawable.getGL();
    final GLU glu = new GLU();

    if(height <= 0)
      height = 1;

    gl.glViewport(0, 0, width, height);

    gl.glMatrixMode(GL.GL_PROJECTION);                //Select the Projectionmatrix
    gl.glLoadIdentity();                    //Reset the current matrix
    glu.gluPerspective(45.0f, width / height, 0.1f, 1000.0f)//set the Viewing Volume

    gl.glMatrixMode(GL.GL_MODELVIEW);        //select The Modelview Matrix
    gl.glLoadIdentity();              //set the ModelView matrix to identity
  }
View Full Code Here

  public void init(GLAutoDrawable glDrawable) {
     renderer = new TextRenderer(
         new Font("SansSerif", Font.BOLD, 10)
      );
   
    final GL gl = glDrawable.getGL();
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    gl.glClearDepth(1.0);                  //Enable Clearing of the Depth buffer
    gl.glDepthFunc(GL.GL_LEQUAL);              //Type of Depth test
    gl.glEnable(GL.GL_DEPTH_TEST);              //Enable Depth Testing

    gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

    // light
      gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, lightAmbient, 0);
      //Diffuse light component
      gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, lightDiffuse, 0);
      //Light position
      gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0);
     
      //Enable the first light and the lighting mode
      gl.glEnable(GL.GL_LIGHT0);
      gl.glEnable(GL.GL_LIGHTING);
       
      // material
        gl.glEnable(GL.GL_COLOR_MATERIAL)// Enable Color Material
    gl.glEnable(GL.GL_ALPHA);
        // shading
        gl.glShadeModel(GL.GL_SMOOTH);
        gl.glEnable(GL.GL_TEXTURE_2D);
        gl.glActiveTexture(GL.GL_TEXTURE0);
        try {
      GetTextures(gl);
      System.out.println("Textures");
     
    } catch (IOException e1) {
View Full Code Here

  public void dispose(GLAutoDrawable d) {
  }

  @Override
  public void init(GLAutoDrawable d) {
    GL gl = d.getGL();
    Class<?> type = gl.getClass();
   
    try {
      if (d.getGL().isFunctionAvailable("glGenVertexArrays") &&
        d.getGL().isFunctionAvailable("glBindVertexArray")) {
        Method glGenVertexArrays = type.getMethod("glGenVertexArrays", int.class, int[].class, int.class);
View Full Code Here

  }

  @Override
  public void reshape(GLAutoDrawable d, int x, int y, int width, int height) {
    try {
      GL gl = d.getGL();
      Class<?> type = gl.getClass();
     
      Method glMatrixMode = type.getMethod("glMatrixMode", int.class);
      Method glLoadIdentity = type.getMethod("glLoadIdentity");
     
      glMatrixMode.invoke(gl, GL2.GL_PROJECTION);
      glLoadIdentity.invoke(gl);
     
      GLU glu = new GLU();
      glu.gluOrtho2D(0.0f, width, 0.0, height);
     
      glMatrixMode.invoke(gl, GL2.GL_MODELVIEW);
      glLoadIdentity.invoke(gl);
     
      gl.glViewport(0, 0, width, height);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
View Full Code Here

  }
 
  @Override
  public void init(GLAutoDrawable drawable) {
    canvas.setAutoSwapBufferMode(false);
    GL gl = drawable.getGL();
    gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    onInit(drawable);
  }
View Full Code Here

    onInit(drawable);
  }

  @Override
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    GL gl = drawable.getGL();
    gl.glViewport(x, y, width, height);
    onReshape(drawable, x, y, width, height);
  }
View Full Code Here

    onReshape(drawable, x, y, width, height);
  }
 
  @Override
  public void display(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    onDisplay(drawable);
    canvas.swapBuffers();
  }
View Full Code Here

    public JoglRenderer() {
        logger.fine("JoglRenderer created.");
    }

    public void setBackgroundColor(final ReadOnlyColorRGBA c) {
        final GL gl = GLContext.getCurrentGL();

        _backgroundColor.set(c);
        gl.glClearColor(_backgroundColor.getRed(), _backgroundColor.getGreen(), _backgroundColor.getBlue(),
                _backgroundColor.getAlpha());
    }
View Full Code Here

TOP

Related Classes of javax.media.opengl.GL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.