Home | History | Annotate | Download | only in replicaisland
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17  package com.replica.replicaisland;
     18 
     19 import javax.microedition.khronos.opengles.GL10;
     20 
     21 public class BufferLibrary extends BaseObject {
     22     private static final int GRID_LIST_SIZE = 256;
     23     private FixedSizeArray<Grid> mGridList;
     24 
     25     public BufferLibrary() {
     26         super();
     27 
     28         mGridList = new FixedSizeArray<Grid>(GRID_LIST_SIZE);
     29     }
     30 
     31     @Override
     32     public void reset() {
     33         removeAll();
     34     }
     35 
     36     public void add(Grid grid) {
     37          mGridList.add(grid);
     38     }
     39 
     40     public void removeAll() {
     41         mGridList.clear();
     42     }
     43 
     44     public void generateHardwareBuffers(GL10 gl) {
     45     	if (sSystemRegistry.contextParameters.supportsVBOs) {
     46 	        final int count = mGridList.getCount();
     47 	        for (int x = 0; x < count; x++) {
     48 	            Grid grid = mGridList.get(x);
     49 	            grid.generateHardwareBuffers(gl);
     50 	        }
     51     	}
     52     }
     53 
     54     public void releaseHardwareBuffers(GL10 gl) {
     55     	if (sSystemRegistry.contextParameters.supportsVBOs) {
     56 	        final int count = mGridList.getCount();
     57 	        for (int x = 0; x < count; x++) {
     58 	            Grid grid = mGridList.get(x);
     59 	            grid.releaseHardwareBuffers(gl);
     60 	        }
     61     	}
     62     }
     63 
     64     public void invalidateHardwareBuffers() {
     65     	if (sSystemRegistry.contextParameters.supportsVBOs) {
     66 	        final int count = mGridList.getCount();
     67 	        for (int x = 0; x < count; x++) {
     68 	            Grid grid = mGridList.get(x);
     69 	            grid.invalidateHardwareBuffers();
     70 	        }
     71     	}
     72     }
     73 
     74 }
     75