13.07.2015 Views

Manual de Apoio 2010

Manual de Apoio 2010

Manual de Apoio 2010

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• GL TEXTURE CUBE MAP POSITIVE Z• GL TEXTURE CUBE MAP NEGATIVE ZAs constantes representam a direcção no ambiente real para a textura que estamos a carregar. Por exemplopara <strong>de</strong>finirmos a textura para a direcção x positiva, po<strong>de</strong>riamos utilizar a função glTexImage2D da seguinteforma:TGAImage img = loadImage (" facex . tga ");glTexImage2D ( GL2 . GL_TEXTURE_CUBE_MAP_POSITIVE_X , 0,img . getGLFormat () , img . getWidth () , img . getHeight () , 0,GL_RGBA , GL_UNSIGNED_BYTE , img . getData ());O excerto <strong>de</strong> código em baixo pertence ao programa CubeMap.java, e ilustra a forma como as texturaspo<strong>de</strong>riam carregadas para o cube map:// Obter os i<strong>de</strong>ntificadoresIntBuffer textures = IntBuffer . allocate ( NumTextures );gl. glGenTextures ( NumTextures , textures );// ...// Direccoes para as texuras do cuboList < String > textureNames = new ArrayList < String >();private static final int [] CubeDirection = {GL2 . GL_TEXTURE_CUBE_MAP_POSITIVE_X ,GL2 . GL_TEXTURE_CUBE_MAP_NEGATIVE_X ,GL2 . GL_TEXTURE_CUBE_MAP_POSITIVE_Y ,GL2 . GL_TEXTURE_CUBE_MAP_NEGATIVE_Y ,GL2 . GL_TEXTURE_CUBE_MAP_POSITIVE_Z ,GL2 . GL_TEXTURE_CUBE_MAP_NEGATIVE_Z};// ...// Texturas do Cube MaptextureNames . add (" cubemap / right . tga ");textureNames . add (" cubemap / left . tga ");textureNames . add (" cubemap /up.tga ");textureNames . add (" cubemap / down . tga ");textureNames . add (" cubemap / backward . tga ");textureNames . add (" cubemap / forward . tga ");// ...// Carregar as texturas do Cubogl. glBindTexture ( GL2 . GL_TEXTURE_CUBE_MAP , textures . get ( CubeStartIn<strong>de</strong>x ));// Parametros das texturas do cube mapgl. 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 );97

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

Saved successfully!

Ooh no, something went wrong!