Manual de Apoio 2010
Manual de Apoio 2010
Manual de Apoio 2010
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Carregar e Ler a imagem para a nossa texturaTGAImage img = loadTexture ( textureNames . get (i ));ByteBuffer bb = img . getData ();// Carregar a textura ( comprimida RGB )gl. glTexParameteri ( GL2 . GL_TEXTURE_2D , GL2 . GL_GENERATE_MIPMAP , GL2 . GL_TRUE );gl. glTexImage2D ( GL2 . GL_TEXTURE_2D , 0, GL2 . GL_COMPRESSED_RGB ,img . getWidth () , img . getHeight () , 0, img . getGLFormat () ,GL2 . GL_UNSIGNED_BYTE , bb );// Parametros da texturagl. glTexParameteri ( GL2 . GL_TEXTURE_2D , GL2 . GL_TEXTURE_MAG_FILTER ,GL2 . GL_LINEAR );gl. glTexParameteri ( GL2 . GL_TEXTURE_2D , GL2 . GL_TEXTURE_MIN_FILTER ,GL2 . GL_LINEAR_MIPMAP_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 );}}private void setupCubeMap ( GL2 gl) {// Carregar as texturas do Cubogl. glBindTexture ( GL2 . GL_TEXTURE_CUBE_MAP , textures . get ( CubeStartIn<strong>de</strong>x ));gl. glTexParameteri ( GL2 . GL_TEXTURE_CUBE_MAP , GL2 . GL_TEXTURE_MAG_FILTER ,GL2 . GL_LINEAR );gl. glTexParameteri ( GL2 . GL_TEXTURE_CUBE_MAP , GL2 . GL_TEXTURE_MIN_FILTER ,GL2 . GL_LINEAR );gl. glTexParameteri ( GL2 . GL_TEXTURE_CUBE_MAP , GL2 . GL_TEXTURE_WRAP_S ,GL2 . GL_REPEAT );gl. glTexParameteri ( GL2 . GL_TEXTURE_CUBE_MAP , GL2 . GL_TEXTURE_WRAP_T ,GL2 . GL_REPEAT );gl. glTexParameteri ( GL2 . GL_TEXTURE_CUBE_MAP , GL2 . GL_TEXTURE_WRAP_R ,GL2 . GL_REPEAT );// Restantes texturas preenchem o cubofor ( int i = CubeStartIn<strong>de</strong>x ; i < textureNames . size (); i ++) {// Carregar e Ler a imagem para a nossa texturaTGAImage img = loadTexture ( textureNames . get (i ));ByteBuffer bb = img . getData ();}gl. glTexImage2D ( CubeDirection [i - CubeStartIn<strong>de</strong>x ], 0, GL2 . GL_RGBA ,img . getWidth () , img . getHeight () , 0, img . getGLFormat () ,GL2 . GL_UNSIGNED_BYTE , bb );}gl. glTexGeni ( GL2 .GL_S , GL2 . GL_TEXTURE_GEN_MODE , GL2 . GL_REFLECTION_MAP );gl. glTexGeni ( GL2 .GL_T , GL2 . GL_TEXTURE_GEN_MODE , GL2 . GL_REFLECTION_MAP );gl. glTexGeni ( GL2 .GL_R , GL2 . GL_TEXTURE_GEN_MODE , GL2 . GL_REFLECTION_MAP );private void setupLight ( GL2 gl) {// Setup light parametersgl. glLightMo<strong>de</strong>lfv ( GL2 . GL_LIGHT_MODEL_AMBIENT , fNoLight , 0);gl. glLightMo<strong>de</strong>li ( GL2 . GL_LIGHT_MODEL_COLOR_CONTROL ,GL2 . GL_SEPARATE_SPECULAR_COLOR );gl. glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_AMBIENT , fLowLight , 0);gl. glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_DIFFUSE , fBrightLight , 0);gl. glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_SPECULAR , fBrightLight , 0);gl. glEnable ( GL2 . GL_LIGHTING );134