|
1 /* |
|
2 * Copyright (c) 2009 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 #include "javax_microedition_m3g_VertexBuffer.h" |
|
19 |
|
20 JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setTexCoords |
|
21 (JNIEnv* aEnv, jclass, jint aHBuffer, jint aTexUnit, jint aHArray, jfloat aScale, jfloatArray aSrcArray) |
|
22 { |
|
23 int biasLength = 0; |
|
24 float *bias = NULL; |
|
25 if (aSrcArray) |
|
26 { |
|
27 bias = (float *)aEnv->GetFloatArrayElements(aSrcArray, NULL); |
|
28 if (bias == NULL) |
|
29 { |
|
30 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
31 return; |
|
32 } |
|
33 } |
|
34 |
|
35 biasLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; |
|
36 |
|
37 M3G_DO_LOCK |
|
38 m3gSetTexCoordArray((M3GVertexBuffer)aHBuffer, aTexUnit, (M3GVertexArray)aHArray, aScale, bias, biasLength); |
|
39 M3G_DO_UNLOCK(aEnv) |
|
40 |
|
41 if (aSrcArray) |
|
42 { |
|
43 aEnv->ReleaseFloatArrayElements(aSrcArray, bias, JNI_ABORT); |
|
44 } |
|
45 } |
|
46 |
|
47 JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1getArray |
|
48 (JNIEnv* aEnv, jclass, jint aHBuffer, jint aWhich, jfloatArray aDstArray) |
|
49 { |
|
50 int dstLength = 0; |
|
51 float *dstData = NULL; |
|
52 if (aDstArray) |
|
53 { |
|
54 dstData = (float *)aEnv->GetFloatArrayElements(aDstArray, NULL); |
|
55 if (dstData == NULL) |
|
56 { |
|
57 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
58 return 0; |
|
59 } |
|
60 } |
|
61 |
|
62 dstLength = aDstArray ? aEnv->GetArrayLength(aDstArray) : 0; |
|
63 |
|
64 M3G_DO_LOCK |
|
65 M3Guint ret = (M3Guint)m3gGetVertexArray((M3GVertexBuffer)aHBuffer, aWhich, dstData, dstLength); |
|
66 M3G_DO_UNLOCK(aEnv) |
|
67 |
|
68 if (aDstArray) |
|
69 { |
|
70 aEnv->ReleaseFloatArrayElements(aDstArray, dstData, 0); |
|
71 } |
|
72 |
|
73 return ret; |
|
74 } |
|
75 |
|
76 JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1getDefaultColor |
|
77 (JNIEnv* aEnv, jclass, jint aHBuffer) |
|
78 { |
|
79 M3G_DO_LOCK |
|
80 jint color = (M3Guint)m3gGetVertexDefaultColor((M3GVertexBuffer)aHBuffer); |
|
81 M3G_DO_UNLOCK(aEnv) |
|
82 return color; |
|
83 } |
|
84 |
|
85 JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1ctor |
|
86 (JNIEnv* aEnv, jclass, jint aM3g) |
|
87 { |
|
88 M3G_DO_LOCK |
|
89 M3GVertexBuffer vb = m3gCreateVertexBuffer((M3GInterface)aM3g); |
|
90 M3G_DO_UNLOCK(aEnv) |
|
91 return (M3Guint) vb; |
|
92 } |
|
93 |
|
94 JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setNormals |
|
95 (JNIEnv* aEnv, jclass, jint aHBuffer, jint aHArray) |
|
96 { |
|
97 M3G_DO_LOCK |
|
98 m3gSetNormalArray((M3GVertexBuffer) aHBuffer, (M3GVertexArray) aHArray); |
|
99 M3G_DO_UNLOCK(aEnv) |
|
100 } |
|
101 |
|
102 JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setDefaultColor |
|
103 (JNIEnv* aEnv, jclass, jint aHBuffer, jint aARGB) |
|
104 { |
|
105 M3G_DO_LOCK |
|
106 m3gSetVertexDefaultColor((M3GVertexBuffer)aHBuffer, aARGB); |
|
107 M3G_DO_UNLOCK(aEnv) |
|
108 } |
|
109 |
|
110 JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setColors |
|
111 (JNIEnv* aEnv, jclass, jint aHBuffer, jint aHArray) |
|
112 { |
|
113 M3G_DO_LOCK |
|
114 m3gSetColorArray((M3GVertexBuffer) aHBuffer, (M3GVertexArray) aHArray); |
|
115 M3G_DO_UNLOCK(aEnv) |
|
116 } |
|
117 |
|
118 JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setVertices |
|
119 (JNIEnv* aEnv, jclass, jint aHBuffer, jint aHArray, jfloat aScale, jfloatArray aSrcArray) |
|
120 { |
|
121 int biasLength = 0; |
|
122 float *bias = NULL; |
|
123 if (aSrcArray) |
|
124 { |
|
125 bias = (float *)aEnv->GetFloatArrayElements(aSrcArray, NULL); |
|
126 if (bias == NULL) |
|
127 { |
|
128 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
129 return; |
|
130 } |
|
131 } |
|
132 |
|
133 biasLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; |
|
134 |
|
135 M3G_DO_LOCK |
|
136 m3gSetVertexArray((M3GVertexBuffer)aHBuffer, (M3GVertexArray)aHArray, aScale, bias, biasLength); |
|
137 M3G_DO_UNLOCK(aEnv) |
|
138 |
|
139 if (aSrcArray) |
|
140 { |
|
141 aEnv->ReleaseFloatArrayElements(aSrcArray, bias, JNI_ABORT); |
|
142 } |
|
143 } |
|
144 |
|
145 JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1getVertexCount |
|
146 (JNIEnv* aEnv, jclass, jint aHBuffer) |
|
147 { |
|
148 M3G_DO_LOCK |
|
149 jint count = (M3Guint)m3gGetVertexCount((M3GVertexBuffer)aHBuffer); |
|
150 M3G_DO_UNLOCK(aEnv) |
|
151 return count; |
|
152 } |