SimpleRenderer.java


Dosyayı İndir
package com.godoro.androidopengl;

import android.graphics.*;
import android.opengl.*;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.*;

public class SimpleRenderer implements GLSurfaceView.Renderer {

    private SimpleActivity activity;
    private SimpleCube simpleCube = new SimpleCube();
    private SimpleCubeColorful colorfulCube = new SimpleCubeColorful();
    private SimpleCubeTextured texturedCube = new SimpleCubeTextured();
    private SimpleSphereTextured texturedSphere = new SimpleSphereTextured(3,2);

    private float rotationAngle=0;
    private float rotationAngleDelta=-3.0f;

    public SimpleRenderer(SimpleActivity activity) {
        this.activity = activity;
        texturedCube.setTextureBitmap(BitmapFactory.decodeResource(activity.getResources(),R.drawable.maze));
    }

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        texturedSphere.loadGLTexture(gl,activity,R.drawable.maze);

        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);

        gl.glClearDepthf(1.0f);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glEnable(GL10.GL_DEPTH_TEST);
        gl.glDepthFunc(GL10.GL_LEQUAL);

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

    }

    @Override
    public void onDrawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();


        //gl.glRotatef(rotationAngle, 0.0f, 1.0f, 0.0f);
        //rotationAngle += rotationAngleDelta;

        //gl.glTranslatef(0.0f, 0.0f, -10.0f);
        //simpleCube.draw(gl);

        //gl.glTranslatef(0.0f, 0.0f, -10.0f);
        //texturedCube.draw(gl);

        //gl.glTranslatef(0.0f, 0.0f, 5.0f);
        //colorfulCube.draw(gl);

        gl.glTranslatef(0.0f, 0.0f, -10.0f);
        texturedSphere.draw(gl);


        gl.glLoadIdentity();

    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f);
        gl.glViewport(0, 0, width, height);

        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
    }


}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir