Exemplo n.º 1
0
  /** States for texture, smooth and flat models */
  public void enableStates() {

    if (hasTextureCoordinates()) {
      gl.glEnable(GL.GL_TEXTURE_2D);
    }

    if (isSmoothShadingEnabled()) {
      gl.glShadeModel(GL.GL_SMOOTH);
    } else {
      gl.glShadeModel(GL.GL_FLAT);
    }
  }
Exemplo n.º 2
0
  public void displayInit(Point pickPoint) {
    gl.glShadeModel(GL.GL_SMOOTH);

    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();

    if (pickPoint != null) {
      int[] vp = new int[4];
      gl.glGetIntegerv(GL.GL_VIEWPORT, vp, 0);
      GLU glu = new GLU();
      int px = (int) pickPoint.getX();
      int py = (int) (vp[3] - pickPoint.getY());
      glu.gluPickMatrix(px, py, 1e-2, 1e-2, vp, 0);
    }

    gl.glOrtho(0, bounds.getWidth(), 0, bounds.getHeight(), .1, depth);

    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();

    glu.gluLookAt(0, 0, depth - 0.1, 0, 0, 0, 0, 1, 0);

    gl.glInitNames();
    gl.glPushName(-1);
  }
Exemplo n.º 3
0
 public void init(GLAutoDrawable drawable) {
   GL gl = drawable.getGL();
   System.err.println("INIT GL IS: " + gl.getClass().getName());
   gl.setSwapInterval(1);
   gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
 }
Exemplo n.º 4
0
 public void init(GLAutoDrawable gLDrawable) {
   renderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 36)); // creates textrenderer
   GL gl = gLDrawable.getGL();
   gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
   gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black Background
   gl.glClearDepth(1.0f); // Depth Buffer Setup
   gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
   gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
   // Really Nice Perspective Calculations
   gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
 }
Exemplo n.º 5
0
Arquivo: Mesa.java Projeto: Gubetti/N4
  public void desenhar(GL gl, GLUT glut) {
    gl.glShadeModel(GL.GL_FLAT);
    gl.glNormal3f(0.0f, 0.0f, 1.0f);
    gl.glColor3f(1f, 1f, 1f);

    float corWhite[] = {1.0f, 1.0f, 1.0f, 1.0f};

    // base
    setTexture(Util.loadImage("texture/textureBrick.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, corWhite, 0);
    gl.glEnable(GL.GL_LIGHTING);
    gl.glPushMatrix();
    gl.glTranslatef(0f, -dif, 0f);
    gl.glScalef(getxEscala(), getyEscala(), getzEscala());
    glut.glutSolidCube(1f);
    gl.glPopMatrix();

    // esquerda
    setTexture(Util.loadImage("texture/tijolos/medio2.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glPushMatrix();
    gl.glTranslatef(-(getxEscala() / 2), (getAltura() / 2) - dif, 0f);
    gl.glScalef(0.1f, getAltura(), getzEscala());
    glut.glutSolidCube(1f);
    gl.glPopMatrix();
    gl.glDisable(GL.GL_LIGHTING);

    // direita
    setTexture(Util.loadImage("texture/tijolos/medio2.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glPushMatrix();
    gl.glTranslatef(getxEscala() / 2, (getAltura() / 2) - dif, 0f);
    gl.glScalef(0.1f, getAltura(), getzEscala());
    glut.glutSolidCube(1f);
    gl.glPopMatrix();
    gl.glDisable(GL.GL_LIGHTING);

    // fundo
    setTexture(Util.loadImage("texture/tijolos/fraco.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glPushMatrix();
    gl.glTranslatef(0f, (getAltura() / 2) - dif, -(getzEscala() / 2));
    gl.glScalef(getxEscala(), getAltura(), 0.1f);
    glut.glutSolidCube(1f);
    gl.glPopMatrix();
    gl.glDisable(GL.GL_LIGHTING);
  }
Exemplo n.º 6
0
  public void init(GL gl) {
    // Starts with animation turned off
    setAnimation(false);

    // --- OpenGL Initialization

    // Set background color to sky blue
    gl.glClearColor(0.58f, 0.74f, 0.98f, 0.0f);

    // Turn on Z buffer
    gl.glEnable(GL.GL_DEPTH_TEST);

    // Turn on Gouraud shaded polygons
    gl.glShadeModel(GL.GL_SMOOTH);

    // Turn on automatic normalization for normal vectors
    gl.glEnable(GL.GL_NORMALIZE);
  }
Exemplo n.º 7
0
  /** OpenGL initialization function Called once, on startup */
  @Override
  public void init(GLAutoDrawable auto_drawable) {
    // initialize OpenGL state, load arrays, etc.
    // anything needs to be dont before the drawing calls
    final GL gl = auto_drawable.getGL();
    gl.glShadeModel(GL.GL_SMOOTH);
    gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
    gl.glClearDepth(1.0f);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glDepthFunc(GL.GL_LEQUAL);
    gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

    gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
    gl.glEnableClientState(GL.GL_VERTEX_ARRAY);

    // set the texture mode to decal, so textures are rendered independent of
    // underlying colors
    gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_DECAL);

    // initialize vertex arrays
    initVertexArrays();

    // enable 2D texturing
    gl.glEnable(GL.GL_TEXTURE_2D);

    // load the question texture
    question_Texture = loadTexture("Data/Pictures/question_mark.png");

    // set up fog effect
    float fogColor[] = {0.5f, 0.5f, 0.5f, 1.0f}; // Fog Color

    gl.glFogi(GL.GL_FOG_MODE, GL.GL_LINEAR); // Fog Mode
    gl.glFogfv(GL.GL_FOG_COLOR, FloatArrayToFloatBuffer(fogColor)); // Set Fog Color
    gl.glFogf(GL.GL_FOG_DENSITY, 0.35f); // How Dense Will The Fog Be
    gl.glHint(GL.GL_FOG_HINT, GL.GL_NICEST); // Fog Hint Value
    gl.glFogf(GL.GL_FOG_START, 0.0f); // Fog Start Depth
    gl.glFogf(GL.GL_FOG_END, 3.0f); // Fog End Depth
    gl.glEnable(GL.GL_FOG); // Enables GL_FOG

    // load all textures
    LoadAllGuessModelTextures(guess_model_array);
  }
Exemplo n.º 8
0
  private void initOpenGL() {
    pgl = (PGraphicsOpenGL) g;
    gl = pgl.gl;
    gl.setSwapInterval(1);

    gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
    gl.glClearDepth(1.0f); // Depth Buffer Setup
    gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
    gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
    gl.glHint(
        GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations
    gl.glDisable(GL.GL_TEXTURE_2D);

    // Set up lighting
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, lightAmbient, 0);
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, lightDiffuse, 0);
    //      gl.glLightfv( GL.GL_LIGHT1, GL.GL_SPECULAR, lightSpecular, 0 );
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, lightPosition, 0);
    gl.glEnable(GL.GL_LIGHTING);
    gl.glEnable(GL.GL_LIGHT1);
  }