13.07.2015 Views

Manual de Apoio 2010

Manual de Apoio 2010

Manual de Apoio 2010

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Activar as Luzesgl. glEnable ( GL2 . GL_LIGHTING );// Configurar e Activar a luzgl. glLightMo<strong>de</strong>lfv ( GL2 . GL_LIGHT_MODEL_AMBIENT , whiteLight , 0);gl. glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_AMBIENT , sourceLight , 0);gl. glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_DIFFUSE , sourceLight , 0);gl. glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_POSITION , lightPos . toArray () , 0);gl. glEnable ( GL2 . GL_LIGHT0 );// Activar o Color Trackinggl. glEnable ( GL2 . GL_COLOR_MATERIAL );// Proprieda<strong>de</strong>s dos materiais obe<strong>de</strong>cem ’a luzgl. glColorMaterial ( GL2 . GL_FRONT , GL2 . GL_AMBIENT_AND_DIFFUSE );// Carregar e Ler a imagem para a nossa texturatry {InputStream stream = Pyramid . class . getResourceAsStream (" stone . tga ");img = TGAImage . read ( stream );bb = img . getData ();stream . close ();} catch ( IOException e) {e. printStackTrace ();}gl. glTexImage2D ( GL2 . GL_TEXTURE_2D , 0, GL2 . GL_RGBA ,img . getWidth () , img . getHeight () ,0, img . getGLFormat () , GL2 . GL_UNSIGNED_BYTE , bb );// Parametros da textura ( ignorar para ja)gl. glTexParameteri ( GL2 . GL_TEXTURE_2D ,GL2 . GL_TEXTURE_MIN_FILTER , GL2 . GL_LINEAR );gl. glTexParameteri ( GL2 . GL_TEXTURE_2D ,GL2 . GL_TEXTURE_MAG_FILTER , GL2 . GL_LINEAR );gl. glTexParameteri ( GL2 . GL_TEXTURE_2D ,GL2 . GL_TEXTURE_WRAP_S , GL2 . GL_CLAMP_TO_EDGE );gl. glTexParameteri ( GL2 . GL_TEXTURE_2D ,GL2 . GL_TEXTURE_WRAP_T , GL2 . GL_CLAMP_TO_EDGE );// Configuracao do Texture Environmentgl. glTexEnvi ( GL2 . GL_TEXTURE_ENV ,GL2 . GL_TEXTURE_ENV_MODE , GL2 . GL_MODULATE );// Activar as texturasgl. glEnable ( GL2 . GL_TEXTURE_2D );// Cantos da Pirami<strong>de</strong>cTop = new GLVector (0.0f, .80f, 0.0 f);cBackLeft = new GLVector ( -0.5f, 0.0f, -.50f);cBackRight = new GLVector (0.5f, 0.0f, -0.50 f);cFrontRight = new GLVector (0.5f, 0.0f, 0.5 f);cFrontLeft = new GLVector ( -0.5f, 0.0f, 0.5 f);}private float yRot = 0f;@Overri<strong>de</strong>public void display ( GLAutoDrawable drawable ) {GL2 gl = drawable . getGL (). getGL2 ();yRot += .1f;if( yRot >= GlTools . GL_PI * 2f)yRot = 0;124

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!