1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
@Override
public void onSurfaceChanged(GL10 glUnused, int width_, int height_) {
width = width_;
height = height_;
float screenRatio = (width / height);
float left = -screenRatio;
float right = screenRatio;
float bottom = -1.0f;
float top = 1.0f;
float near = 1.0f;
float far = 10.0f;
if ( width_ > height_ ){
left*=(height/width) ;
right*=(height/width) ;
top*=(height/width) ;
bottom*=(height/width) ;
screenRatioW = width/height ;
screenRatioH = 1 ;
zmax = 3f ;
zmin = 0.2f ;
}else{
screenRatioW = 1 ;
screenRatioH = height/width ;
zmax = 4f ;
zmin = 0.2f ;
}
GLES20.glViewport(0, 0, width_, height_);
Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
mn = Bitmap.createBitmap(Bitmap.createBitmap((int) width / 3, (int) width / 3, Bitmap.Config.ARGB_8888));
for ( int x = 0 ; x < mn.getWidth() ; x ++ ){
for ( int y = 0 ; y < mn.getHeight() ; y ++ ){
mn.setPixel(x,y, Color.WHITE);
}
}
hud.clear();
minimap = RawResourceReader.loadTexture(mn, false) ;
if ( width > height ){
hud.add(new Sprite(minimap,1f,1f,0f,0f,1,1,1,1,-mProjectionMatrix[10]*(width/height)-0.5f ,mProjectionMatrix[10]*screenRatioH +0.5f, true));
hud.add(new Icon(textures[4],0.7f,0.7f,0f,0f,4,4,0,0,-1f-mProjectionMatrix[10]*(width/height)-0.35f ,mProjectionMatrix[10]*screenRatioH +0.35f, true));
hud.add(new Icon(textures[4],0.7f,0.7f,0f,0f,4,4,1,1,-mProjectionMatrix[10]*(width/height)-0.35f ,mProjectionMatrix[10]*screenRatioH+1.35f, true));
}else{
hud.add(new Sprite(minimap,1f,1f,0f,0f,1,1,1,1,-mProjectionMatrix[10]-0.5f ,mProjectionMatrix[10]*screenRatioH +0.5f, true));
hud.add(new Icon(textures[4], 0.7f, 0.7f, 0f, 0f, 4, 4, 0, 0, -1f - mProjectionMatrix[10] - 0.35f, mProjectionMatrix[10] * screenRatioH + 0.35f, true));
hud.add(new Icon(textures[4],0.7f,0.7f,0f,0f,4,4,1,1,-mProjectionMatrix[10]-0.35f ,mProjectionMatrix[10]*screenRatioH+1.35f, true));
}
} |
Partager