javauis/m3g_qt/javasrc/javax/microedition/m3g/VertexArray.java
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 package javax.microedition.m3g;
       
    20 
       
    21 public class VertexArray extends Object3D
       
    22 {
       
    23     //------------------------------------------------------------------
       
    24     // Constructors
       
    25     //------------------------------------------------------------------
       
    26 
       
    27     public VertexArray(int numVertices, int numComponents, int componentSize)
       
    28     {
       
    29         super(createHandle(numVertices,
       
    30                            numComponents,
       
    31                            componentSize));
       
    32     }
       
    33 
       
    34     /**
       
    35      */
       
    36     VertexArray(int handle)
       
    37     {
       
    38         super(handle);
       
    39     }
       
    40 
       
    41     //------------------------------------------------------------------
       
    42     // Public methods
       
    43     //------------------------------------------------------------------
       
    44 
       
    45     public void set(int startIndex, int length, short[] values)
       
    46     {
       
    47         _setShort(handle, startIndex, length, values);
       
    48     }
       
    49 
       
    50     public void set(int startIndex, int length, byte[] values)
       
    51     {
       
    52         _setByte(handle, startIndex, length, values);
       
    53     }
       
    54 
       
    55     // M3G 1.1 Maintenance release getters
       
    56     public void get(int firstVertex, int numVertices, byte[] values)
       
    57     {
       
    58         _getByte(handle, firstVertex, numVertices, values);
       
    59     }
       
    60 
       
    61     public void get(int firstVertex, int numVertices, short[] values)
       
    62     {
       
    63         _getShort(handle, firstVertex, numVertices, values);
       
    64     }
       
    65 
       
    66     public int getComponentCount()
       
    67     {
       
    68         return _getComponentCount(handle);
       
    69     }
       
    70 
       
    71     public int getComponentType()
       
    72     {
       
    73         return _getComponentType(handle);
       
    74     }
       
    75 
       
    76     public int getVertexCount()
       
    77     {
       
    78         return _getVertexCount(handle);
       
    79     }
       
    80 
       
    81     //------------------------------------------------------------------
       
    82     // Private methods
       
    83     //------------------------------------------------------------------
       
    84 
       
    85     private static int createHandle(int numVertices, int numComponents, int componentSize)
       
    86     {
       
    87         Platform.heuristicGC();
       
    88         return  _ctor(Interface.getHandle(),
       
    89                       numVertices,
       
    90                       numComponents,
       
    91                       componentSize);
       
    92     }
       
    93 
       
    94     // Native methods
       
    95     private native static int _ctor(int hInterface,
       
    96                                     int numVertices,
       
    97                                     int numComponents,
       
    98                                     int componentSize);
       
    99     private native static void _setByte(int handle,
       
   100                                         int first,
       
   101                                         int count,
       
   102                                         byte[] src);
       
   103     private native static void _setShort(int handle,
       
   104                                          int first,
       
   105                                          int count,
       
   106                                          short[] src);
       
   107 
       
   108     // M3G 1.1 Maintenance release getters
       
   109     private native static void _getByte(int handle,
       
   110                                         int firstVertex,
       
   111                                         int numVertices,
       
   112                                         byte[] values);
       
   113     private native static void _getShort(int handle,
       
   114                                          int firstVertex,
       
   115                                          int numVertices,
       
   116                                          short[] values);
       
   117     private native static int _getComponentCount(int handle);
       
   118     private native static int _getComponentType(int handle);
       
   119     private native static int _getVertexCount(int handle);
       
   120 }