40package com.jogamp.opengl.util.gl2;
42import com.jogamp.opengl.*;
43import com.jogamp.opengl.fixedfunc.GLLightingFunc;
44import com.jogamp.opengl.glu.*;
45import com.jogamp.opengl.glu.gl2.*;
113 public void glutWireSphere(
final double radius,
final int slices,
final int stacks) {
120 glu.
gluSphere(quadObj, radius, slices, stacks);
123 public void glutSolidSphere(
final double radius,
final int slices,
final int stacks) {
130 glu.
gluSphere(quadObj, radius, slices, stacks);
134 final int slices,
final int stacks) {
141 glu.
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
145 final int slices,
final int stacks) {
152 glu.
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
155 public void glutWireCylinder(
final double radius,
final double height,
final int slices,
final int stacks) {
162 glu.
gluCylinder(quadObj, radius, radius, height, slices, stacks);
165 public void glutSolidCylinder(
final double radius,
final double height,
final int slices,
final int stacks) {
169 final double [] x =
new double[slices];
170 final double [] y =
new double[slices];
171 final double angleDelta = Math.PI * 2 / slices;
173 for (
int i = 0 ; i < slices ; i ++) {
174 angle = i * angleDelta;
175 x[i] = Math.cos(angle) * radius;
176 y[i] = Math.sin(angle) * radius;
183 for (
int i = 0 ; i < slices ; i ++) {
193 for (
int i = 0 ; i < slices ; i ++) {
206 glu.
gluCylinder(quadObj, radius, radius, height, slices, stacks);
217 public void glutWireTorus(
final double innerRadius,
final double outerRadius,
218 final int nsides,
final int rings) {
222 doughnut(gl, innerRadius, outerRadius, nsides, rings);
227 final int nsides,
final int rings) {
329 final int[] swapbytes =
new int[1];
330 final int[] lsbfirst =
new int[1];
331 final int[] rowlength =
new int[1];
332 final int[] skiprows =
new int[1];
333 final int[] skippixels =
new int[1];
334 final int[] alignment =
new int[1];
342 bitmapCharacterImpl(gl, font, character);
354 final int[] swapbytes =
new int[1];
355 final int[] lsbfirst =
new int[1];
356 final int[] rowlength =
new int[1];
357 final int[] skiprows =
new int[1];
358 final int[] skippixels =
new int[1];
359 final int[] alignment =
new int[1];
367 final int len =
string.length();
368 for (
int i = 0; i < len; i++) {
369 bitmapCharacterImpl(gl, font,
string.charAt(i));
381 final BitmapFontRec fontinfo = getBitmapFont(font);
382 final int c = character & 0xFFFF;
383 if (c < fontinfo.first || c >= fontinfo.first + fontinfo.num_chars)
385 final BitmapCharRec ch = fontinfo.ch[c - fontinfo.first];
387 return (
int) ch.advance;
394 final StrokeFontRec fontinfo = getStrokeFont(font);
395 final int c = character & 0xFFFF;
396 if (c < 0 || c >= fontinfo.num_chars)
398 final StrokeCharRec ch = fontinfo.ch[c];
400 for (
int i = 0; i < ch.num_strokes; i++) {
401 final StrokeRec stroke = ch.stroke[i];
403 for (
int j = 0; j < stroke.num_coords; j++) {
404 final CoordRec coord = stroke.coord[j];
415 final StrokeFontRec fontinfo = getStrokeFont(font);
416 final int len =
string.length();
417 for (
int pos = 0; pos < len; pos++) {
418 final int c =
string.charAt(pos) & 0xFFFF;
419 if (c < 0 || c >= fontinfo.num_chars)
421 final StrokeCharRec ch = fontinfo.ch[c];
423 for (
int i = 0; i < ch.num_strokes; i++) {
424 final StrokeRec stroke = ch.stroke[i];
426 for (
int j = 0; j < stroke.num_coords; j++) {
427 final CoordRec coord = stroke.coord[j];
442 final StrokeFontRec fontinfo = getStrokeFont(font);
443 final int c = character & 0xFFFF;
444 if (c < 0 || c >= fontinfo.num_chars)
446 final StrokeCharRec ch = fontinfo.ch[c];
454 final BitmapFontRec fontinfo = getBitmapFont(font);
456 final int len =
string.length();
457 for (
int pos = 0; pos < len; pos++) {
458 final int c =
string.charAt(pos) & 0xFFFF;
459 if (c >= fontinfo.first && c < fontinfo.first + fontinfo.num_chars) {
460 final BitmapCharRec ch = fontinfo.ch[c - fontinfo.first];
462 length += ch.advance;
473 final StrokeFontRec fontinfo = getStrokeFont(font);
475 final int len =
string.length();
476 for (
int i = 0; i < len; i++) {
477 final char c =
string.charAt(i);
478 if (c >= 0 && c < fontinfo.num_chars) {
479 final StrokeCharRec ch = fontinfo.ch[c];
496 for(
int i = 0; i < 12; i++ ) {
517 for(
int i = 0; i < 12; i++ ) {
536 private void quadObjInit(
final GLUgl2 glu) {
537 if (quadObj ==
null) {
540 if (quadObj ==
null) {
545 private static void doughnut(
final GL2 gl,
final double r,
final double R,
final int nsides,
final int rings) {
547 float theta, phi, theta1;
548 float cosTheta, sinTheta;
549 float cosTheta1, sinTheta1;
550 float ringDelta, sideDelta;
552 ringDelta = (float) (2.0 * Math.PI / rings);
553 sideDelta = (float) (2.0 * Math.PI / nsides);
558 for (i = rings - 1; i >= 0; i--) {
559 theta1 = theta + ringDelta;
560 cosTheta1 = (float) Math.cos(theta1);
561 sinTheta1 = (float) Math.sin(theta1);
564 for (j = nsides; j >= 0; j--) {
565 float cosPhi, sinPhi, dist;
568 cosPhi = (float) Math.cos(phi);
569 sinPhi = (float) Math.sin(phi);
570 dist = (float) (R + r * cosPhi);
572 gl.
glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
573 gl.
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, (
float) r * sinPhi);
574 gl.
glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
575 gl.
glVertex3f(cosTheta * dist, -sinTheta * dist, (
float) r * sinPhi);
579 cosTheta = cosTheta1;
580 sinTheta = sinTheta1;
584 private static float[][] boxVertices;
585 private static final float[][] boxNormals = {
593 private static final int[][] boxFaces = {
601 private void drawBox(
final GL2 gl,
final float size,
final int type) {
602 if (boxVertices ==
null) {
603 final float[][] v =
new float[8][];
604 for (
int i = 0; i < 8; i++) {
607 v[0][0] = v[1][0] = v[2][0] = v[3][0] = -0.5f;
608 v[4][0] = v[5][0] = v[6][0] = v[7][0] = 0.5f;
609 v[0][1] = v[1][1] = v[4][1] = v[5][1] = -0.5f;
610 v[2][1] = v[3][1] = v[6][1] = v[7][1] = 0.5f;
611 v[0][2] = v[3][2] = v[4][2] = v[7][2] = -0.5f;
612 v[1][2] = v[2][2] = v[5][2] = v[6][2] = 0.5f;
615 final float[][] v = boxVertices;
616 final float[][] n = boxNormals;
617 final int[][] faces = boxFaces;
618 for (
int i = 5; i >= 0; i--) {
621 float[] vt = v[faces[i][0]];
622 gl.
glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size);
624 gl.
glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size);
626 gl.
glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size);
628 gl.
glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size);
633 private float[][] dodec;
635 private void initDodecahedron() {
636 dodec =
new float[20][];
637 for (
int i = 0; i < dodec.length; i++) {
638 dodec[i] =
new float[3];
643 alpha = (float) Math.sqrt(2.0f / (3.0f + Math.sqrt(5.0)));
644 beta = 1.0f + (float) Math.sqrt(6.0 / (3.0 + Math.sqrt(5.0)) -
645 2.0 + 2.0 * Math.sqrt(2.0 / (3.0 + Math.sqrt(5.0))));
646 dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
647 dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
648 dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
649 dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
650 dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
651 dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
652 dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
653 dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
654 dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
655 dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
656 dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
657 dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
658 dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
659 dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
660 dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
661 dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
662 dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
663 dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
664 dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
665 dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
668 private static void diff3(
final float[] a,
final float[] b,
final float[] c) {
674 private static void crossprod(
final float[] v1,
final float[] v2,
final float[] prod) {
675 final float[] p =
new float[3];
677 p[0] = v1[1] * v2[2] - v2[1] * v1[2];
678 p[1] = v1[2] * v2[0] - v2[2] * v1[0];
679 p[2] = v1[0] * v2[1] - v2[0] * v1[1];
685 private static void normalize(
final float[] v) {
688 d = (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
698 private void pentagon(
final GL2 gl,
final int a,
final int b,
final int c,
final int d,
final int e,
final int shadeType) {
699 final float[] n0 =
new float[3];
700 final float[] d1 =
new float[3];
701 final float[] d2 =
new float[3];
703 diff3(dodec[a], dodec[b], d1);
704 diff3(dodec[b], dodec[c], d2);
705 crossprod(d1, d2, n0);
718 private void dodecahedron(
final GL2 gl,
final int type) {
722 pentagon(gl, 0, 1, 9, 16, 5, type);
723 pentagon(gl, 1, 0, 3, 18, 7, type);
724 pentagon(gl, 1, 7, 11, 10, 9, type);
725 pentagon(gl, 11, 7, 18, 19, 6, type);
726 pentagon(gl, 8, 17, 16, 9, 10, type);
727 pentagon(gl, 2, 14, 15, 6, 19, type);
728 pentagon(gl, 2, 13, 12, 4, 14, type);
729 pentagon(gl, 2, 19, 18, 3, 13, type);
730 pentagon(gl, 3, 0, 5, 12, 13, type);
731 pentagon(gl, 6, 15, 8, 10, 11, type);
732 pentagon(gl, 4, 17, 8, 15, 14, type);
733 pentagon(gl, 4, 12, 5, 16, 17, type);
736 private static void recorditem(
final GL2 gl,
final float[] n1,
final float[] n2,
final float[] n3,
final int shadeType) {
737 final float[] q0 =
new float[3];
738 final float[] q1 =
new float[3];
742 crossprod(q0, q1, q1);
753 private static void subdivide(
final GL2 gl,
final float[] v0,
final float[] v1,
final float[] v2,
final int shadeType) {
755 final float[] w0 =
new float[3];
756 final float[] w1 =
new float[3];
757 final float[] w2 =
new float[3];
762 for (i = 0; i < depth; i++) {
763 for (j = 0; i + j < depth; j++) {
765 for (n = 0; n < 3; n++) {
766 w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
767 w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
769 w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
772 l = (float) Math.sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
776 l = (float) Math.sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
780 l = (float) Math.sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
784 recorditem(gl, w1, w0, w2, shadeType);
789 private static void drawtriangle(
final GL2 gl,
final int i,
final float[][] data,
final int[][] ndx,
final int shadeType) {
790 final float[] x0 = data[ndx[i][0]];
791 final float[] x1 = data[ndx[i][1]];
792 final float[] x2 = data[ndx[i][2]];
793 subdivide(gl, x0, x1, x2, shadeType);
798 private static final float[][] odata =
808 private static final int[][] ondex =
820 private static void octahedron(
final GL2 gl,
final int shadeType) {
823 for (i = 7; i >= 0; i--) {
824 drawtriangle(gl, i, odata, ondex, shadeType);
831 private static final float X = .525731112119133606f;
832 private static final float Z = .850650808352039932f;
834 private static final float[][] idata =
850 private static final int[][] index =
874 private static void icosahedron(
final GL2 gl,
final int shadeType) {
877 for (i = 19; i >= 0; i--) {
878 drawtriangle(gl, i, idata, index, shadeType);
884 private static final double rdod_r[][] =
887 { 0.707106781187, 0.000000000000, 0.5 },
888 { 0.000000000000, 0.707106781187, 0.5 },
889 { -0.707106781187, 0.000000000000, 0.5 },
890 { 0.000000000000, -0.707106781187, 0.5 },
891 { 0.707106781187, 0.707106781187, 0.0 },
892 { -0.707106781187, 0.707106781187, 0.0 },
893 { -0.707106781187, -0.707106781187, 0.0 },
894 { 0.707106781187, -0.707106781187, 0.0 },
895 { 0.707106781187, 0.000000000000, -0.5 },
896 { 0.000000000000, 0.707106781187, -0.5 },
897 { -0.707106781187, 0.000000000000, -0.5 },
898 { 0.000000000000, -0.707106781187, -0.5 },
902 private static final int rdod_v[][] =
918 private static final double rdod_n[][] =
920 { 0.353553390594, 0.353553390594, 0.5 },
921 { -0.353553390594, 0.353553390594, 0.5 },
922 { -0.353553390594, -0.353553390594, 0.5 },
923 { 0.353553390594, -0.353553390594, 0.5 },
924 { 0.000000000000, 1.000000000000, 0.0 },
925 { -1.000000000000, 0.000000000000, 0.0 },
926 { 0.000000000000, -1.000000000000, 0.0 },
927 { 1.000000000000, 0.000000000000, 0.0 },
928 { 0.353553390594, 0.353553390594, -0.5 },
929 { -0.353553390594, 0.353553390594, -0.5 },
930 { -0.353553390594, -0.353553390594, -0.5 },
931 { 0.353553390594, -0.353553390594, -0.5 }
936 private static final float T = 1.73205080756887729f;
938 private static final float[][] tdata =
946 private static final int[][] tndex =
954 private static final void tetrahedron(
final GL2 gl,
final int shadeType) {
955 for (
int i = 3; i >= 0; i--)
956 drawtriangle(gl, i, tdata, tndex, shadeType);
963 private static final int[][] teapotPatchData = {
965 {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
967 {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27},
968 {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40},
970 {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101, 101, 0, 1, 2, 3,},
971 {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117},
973 {118, 118, 118, 118, 124, 122, 119, 121, 123, 126, 125, 120, 40, 39, 38, 37},
975 {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56},
976 {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 28, 65, 66, 67},
978 {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83},
979 {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95}
981 private static final float[][] teapotCPData = {
983 {0.2f, -0.112f, 2.7f},
984 {0.112f, -0.2f, 2.7f},
986 {1.3375f, 0f, 2.53125f},
987 {1.3375f, -0.749f, 2.53125f},
988 {0.749f, -1.3375f, 2.53125f},
989 {0f, -1.3375f, 2.53125f},
990 {1.4375f, 0f, 2.53125f},
991 {1.4375f, -0.805f, 2.53125f},
992 {0.805f, -1.4375f, 2.53125f},
993 {0f, -1.4375f, 2.53125f},
995 {1.5f, -0.84f, 2.4f},
996 {0.84f, -1.5f, 2.4f},
999 {1.75f, -0.98f, 1.875f},
1000 {0.98f, -1.75f, 1.875f},
1001 {0f, -1.75f, 1.875f},
1003 {2f, -1.12f, 1.35f},
1004 {1.12f, -2f, 1.35f},
1012 {2f, -1.12f, 0.45f},
1013 {1.12f, -2f, 0.45f},
1016 {1.5f, -0.84f, 0.225f},
1017 {0.84f, -1.5f, 0.225f},
1018 {0f, -1.5f, 0.225f},
1020 {1.5f, -0.84f, 0.15f},
1021 {0.84f, -1.5f, 0.15f},
1023 {-1.6f, 0f, 2.025f},
1024 {-1.6f, -0.3f, 2.025f},
1025 {-1.5f, -0.3f, 2.25f},
1027 {-2.3f, 0f, 2.025f},
1028 {-2.3f, -0.3f, 2.025f},
1029 {-2.5f, -0.3f, 2.25f},
1031 {-2.7f, 0f, 2.025f},
1032 {-2.7f, -0.3f, 2.025f},
1033 {-3f, -0.3f, 2.25f},
1036 {-2.7f, -0.3f, 1.8f},
1039 {-2.7f, 0f, 1.575f},
1040 {-2.7f, -0.3f, 1.575f},
1041 {-3f, -0.3f, 1.35f},
1043 {-2.5f, 0f, 1.125f},
1044 {-2.5f, -0.3f, 1.125f},
1045 {-2.65f, -0.3f, 0.9375f},
1046 {-2.65f, 0f, 0.9375f},
1048 {-1.9f, -0.3f, 0.6f},
1051 {1.7f, -0.66f, 1.425f},
1052 {1.7f, -0.66f, 0.6f},
1055 {2.6f, -0.66f, 1.425f},
1056 {3.1f, -0.66f, 0.825f},
1059 {2.3f, -0.25f, 2.1f},
1060 {2.4f, -0.25f, 2.025f},
1063 {2.7f, -0.25f, 2.4f},
1064 {3.3f, -0.25f, 2.4f},
1067 {2.8f, -0.25f, 2.475f},
1068 {3.525f, -0.25f, 2.49375f},
1069 {3.525f, 0f, 2.49375f},
1071 {2.9f, -0.15f, 2.475f},
1072 {3.45f, -0.15f, 2.5125f},
1073 {3.45f, 0f, 2.5125f},
1075 {2.8f, -0.15f, 2.4f},
1076 {3.2f, -0.15f, 2.4f},
1080 {0.8f, -0.45f, 3.15f},
1081 {0.45f, -0.8f, 3.15f},
1085 {1.4f, -0.784f, 2.4f},
1086 {0.784f, -1.4f, 2.4f},
1089 {0.4f, -0.224f, 2.55f},
1090 {0.224f, -0.4f, 2.55f},
1093 {1.3f, -0.728f, 2.55f},
1094 {0.728f, -1.3f, 2.55f},
1097 {1.3f, -0.728f, 2.4f},
1098 {0.728f, -1.3f, 2.4f},
1101 {1.425f, -0.798f, 0f},
1104 {0.798f, -1.425f, 0f},
1105 {0f, -1.5f, 0.075f},
1107 {1.5f, -0.84f, 0.075f},
1108 {0.84f, -1.5f, 0.075f}
1112 private static final float[] teapotTex = {
1113 0, 0, 1, 0, 0, 1, 1, 1
1116 private static void teapot(
final GL2 gl,
1120 final boolean backCompatible)
1123 final float[] p =
new float[4*4*3];
1124 final float[] q =
new float[4*4*3];
1125 final float[] r =
new float[4*4*3];
1126 final float[] s =
new float[4*4*3];
1131 gl.
glEnable(GLLightingFunc.GL_NORMALIZE);
1135 if (!backCompatible) {
1138 gl.
glScaled(0.5*scale, 0.5*scale, 0.5*scale);
1144 (
float)(0.5 * scale),
1145 (
float)(0.5 * scale));
1148 for (i = 0; i < 10; i++) {
1149 for (j = 0; j < 4; j++) {
1150 for (k = 0; k < 4; k++) {
1151 for (l = 0; l < 3; l++) {
1152 p[(j*4+k)*3+l] = teapotCPData[teapotPatchData[i][j * 4 + k]][l];
1154 teapotCPData[teapotPatchData[i][j * 4 + (3 - k)]][l];
1156 q[(j*4+k)*3+l] *= -1.0;
1159 teapotCPData[teapotPatchData[i][j * 4 + (3 - k)]][l];
1161 r[(j*4+k)*3+l] *= -1.0;
1162 s[(j*4+k)*3+l] = teapotCPData[teapotPatchData[i][j * 4 + k]][l];
1164 s[(j*4+k)*3+l] *= -1.0;
1166 s[(j*4+k)*3+l] *= -1.0;
1171 gl.
glMap2f(
GL2.
GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, teapotTex, 0);
1172 gl.
glMap2f(
GL2.
GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, p, 0);
1173 gl.
glMapGrid2f(grid, 0.0f, 1.0f, grid, 0.0f, 1.0f);
1174 evaluateTeapotMesh(gl, grid, type, i, !backCompatible);
1175 gl.
glMap2f(
GL2.
GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, q, 0);
1176 evaluateTeapotMesh(gl, grid, type, i, !backCompatible);
1178 gl.
glMap2f(
GL2.
GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, r, 0);
1179 evaluateTeapotMesh(gl, grid, type, i, !backCompatible);
1180 gl.
glMap2f(
GL2.
GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, s, 0);
1181 evaluateTeapotMesh(gl, grid, type, i, !backCompatible);
1188 private static void evaluateTeapotMesh(
final GL2 gl,
1192 final boolean repairSingularities)
1194 if (repairSingularities && (partNum == 5 || partNum == 3)) {
1198 for (
int nv = 0; nv < grid; nv++) {
1208 for (
int nu = 0; nu <= grid; nu++)
1220 for (
int nu = grid; nu >= 0; nu--) {
1237 private static void bitmapCharacterImpl(
final GL2 gl,
final int font,
final char cin) {
1238 final BitmapFontRec fontinfo = getBitmapFont(font);
1239 final int c = cin & 0xFFFF;
1240 if (c < fontinfo.first ||
1241 c >= fontinfo.first + fontinfo.num_chars)
1243 final BitmapCharRec ch = fontinfo.ch[c - fontinfo.first];
1245 gl.
glBitmap(ch.width, ch.height, ch.xorig, ch.yorig,
1246 ch.advance, 0, ch.bitmap, 0);
1250 private static final BitmapFontRec[] bitmapFonts =
new BitmapFontRec[9];
1251 private static final StrokeFontRec[] strokeFonts =
new StrokeFontRec[9];
1253 private static BitmapFontRec getBitmapFont(
final int font) {
1254 BitmapFontRec rec = bitmapFonts[font];
1258 rec = GLUTBitmap9x15.glutBitmap9By15;
1261 rec = GLUTBitmap8x13.glutBitmap8By13;
1264 rec = GLUTBitmapTimesRoman10.glutBitmapTimesRoman10;
1267 rec = GLUTBitmapTimesRoman24.glutBitmapTimesRoman24;
1270 rec = GLUTBitmapHelvetica10.glutBitmapHelvetica10;
1273 rec = GLUTBitmapHelvetica12.glutBitmapHelvetica12;
1276 rec = GLUTBitmapHelvetica18.glutBitmapHelvetica18;
1279 throw new GLException(
"Unknown bitmap font number " + font);
1281 bitmapFonts[font] = rec;
1286 private static StrokeFontRec getStrokeFont(
final int font) {
1287 StrokeFontRec rec = strokeFonts[font];
1291 rec = GLUTStrokeRoman.glutStrokeRoman;
1294 rec = GLUTStrokeMonoRoman.glutStrokeMonoRoman;
1297 throw new GLException(
"Unknown stroke font number " + font);
1303 private static void beginBitmap(
final GL2 gl,
1304 final int[] swapbytes,
1305 final int[] lsbfirst,
1306 final int[] rowlength,
1307 final int[] skiprows,
1308 final int[] skippixels,
1309 final int[] alignment) {
1328 private static void endBitmap(
final GL2 gl,
1329 final int[] swapbytes,
1330 final int[] lsbfirst,
1331 final int[] rowlength,
1332 final int[] skiprows,
1333 final int[] skippixels,
1334 final int[] alignment) {
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Provides access to the OpenGL Utility Library (GLU).
static final int GLU_FILL
static final int GLU_SMOOTH
final void gluQuadricNormals(GLUquadric quad, int normal)
Option (throws GLException if not available in profile).
final GLUquadric gluNewQuadric()
Option (throws GLException if not available in profile).
final void gluCylinder(GLUquadric quad, double base, double top, double height, int slices, int stacks)
Option (throws GLException if not available in profile).
final void gluQuadricDrawStyle(GLUquadric quad, int draw)
Option (throws GLException if not available in profile).
final void gluSphere(GLUquadric quad, double radius, int slices, int stacks)
Option (throws GLException if not available in profile).
static final int GLU_LINE
static final GL2 getCurrentGL2()
Subset of the routines provided by the GLUT interface.
void glutSolidCone(final double base, final double height, final int slices, final int stacks)
void glutSolidTeapot(final double scale)
Renders the teapot as a solid shape of the specified size.
void glutSolidCylinder(final double radius, final double height, final int slices, final int stacks)
static final int BITMAP_TIMES_ROMAN_24
void glutWireOctahedron()
static final int BITMAP_HELVETICA_12
void glutWireTeapot(final double scale)
Renders the teapot as a wireframe shape of the specified size.
void glutWireCone(final double base, final double height, final int slices, final int stacks)
void glutSolidTetrahedron()
void glutSolidDodecahedron()
void glutBitmapCharacter(final int font, final char character)
int glutBitmapWidth(final int font, final char character)
void glutWireTetrahedron()
void glutSolidCube(final float size)
static final int BITMAP_HELVETICA_10
void glutWireTeapot(final double scale, final boolean cStyle)
Renders the teapot as a wireframe shape of the specified size.
void glutWireRhombicDodecahedron()
This function draws a wireframe dodecahedron whose facets are rhombic and whose vertices are at unit ...
int glutStrokeLength(final int font, final String string)
static final int STROKE_ROMAN
void glutSolidSphere(final double radius, final int slices, final int stacks)
void glutWireCylinder(final double radius, final double height, final int slices, final int stacks)
void glutSolidRhombicDodecahedron()
This function draws a solid-shaded dodecahedron whose facets are rhombic and whose vertices are at un...
void glutWireTorus(final double innerRadius, final double outerRadius, final int nsides, final int rings)
float glutStrokeLengthf(final int font, final String string)
void glutSolidIcosahedron()
void glutWireSphere(final double radius, final int slices, final int stacks)
void glutWireCube(final float size)
void glutBitmapString(final int font, final String string)
int glutStrokeWidth(final int font, final char character)
void glutWireIcosahedron()
static final int BITMAP_8_BY_13
void glutSolidOctahedron()
float glutStrokeWidthf(final int font, final char character)
int glutBitmapLength(final int font, final String string)
static final int BITMAP_TIMES_ROMAN_10
static final int BITMAP_9_BY_15
static final int STROKE_MONO_ROMAN
static final int BITMAP_HELVETICA_18
void glutStrokeString(final int font, final String string)
void glutWireDodecahedron()
void glutStrokeCharacter(final int font, final char character)
void glutSolidTorus(final double innerRadius, final double outerRadius, final int nsides, final int rings)
void glutSolidTeapot(final double scale, final boolean cStyle)
Renders the teapot as a solid shape of the specified size.
void glNormal3f(float nx, float ny, float nz)
Entry point to C language function: void {@native glNormal3f}(GLfloat nx, GLfloat ny,...
static final int GL_UNPACK_ROW_LENGTH
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_EXT_unpack_subimage Alias for: GL_UNPACK_ROW_LE...
static final int GL_UNPACK_SKIP_PIXELS
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_EXT_unpack_subimage Alias for: GL_UNPACK_SKIP_P...
static final int GL_UNPACK_SKIP_ROWS
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_EXT_unpack_subimage Alias for: GL_UNPACK_SKIP_R...
static final int GL_QUADS
GL_ES_VERSION_3_2, GL_VERSION_1_1, GL_VERSION_1_0, GL_OES_tessellation_shader, GL_EXT_tessellation_sh...
static final int GL_UNPACK_LSB_FIRST
GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_UNPACK_LSB_FIRST" with expression '0x0CF1',...
static final int GL_UNPACK_SWAP_BYTES
GL_VERSION_1_1, GL_VERSION_1_0 Define "GL_UNPACK_SWAP_BYTES" with expression '0x0CF0',...
static final int GL_FILL
GL_VERSION_1_1, GL_VERSION_1_0, GL_NV_polygon_mode Alias for: GL_FILL_NV Define "GL_FILL" with expre...
void glPolygonMode(int face, int mode)
Entry point to C language function: void {@native glPolygonMode}(GLenum face, GLenum mode) Part of...
static final int GL_LINE
GL_VERSION_1_1, GL_VERSION_1_0, GL_NV_polygon_mode Alias for: GL_LINE_NV Define "GL_LINE" with expre...
void glVertex3d(double x, double y, double z)
Entry point to C language function: void {@native glVertex3d}(GLdouble x, GLdouble y,...
static final int GL_POLYGON_BIT
GL_VERSION_1_0 Define "GL_POLYGON_BIT" with expression '0x00000008', CType: int
void glPopAttrib()
Entry point to C language function: void {@native glPopAttrib}() Part of GL_VERSION_1_0
void glVertex3fv(FloatBuffer v)
Entry point to C language function: void {@native glVertex3fv}(const GLfloat * v) Part of GL_VERSI...
void glBitmap(int width, int height, float xorig, float yorig, float xmove, float ymove, ByteBuffer bitmap)
Entry point to C language function: void {@native glBitmap}(GLsizei width, GLsizei height,...
void glVertex3dv(DoubleBuffer v)
Entry point to C language function: void {@native glVertex3dv}(const GLdouble * v) Part of GL_VERS...
static final int GL_MAP2_VERTEX_3
GL_VERSION_1_0 Define "GL_MAP2_VERTEX_3" with expression '0x0DB7', CType: int
void glEvalCoord2f(float u, float v)
Entry point to C language function: void {@native glEvalCoord2f}(GLfloat u, GLfloat v) Part of GL_...
static final int GL_ENABLE_BIT
GL_VERSION_1_0 Define "GL_ENABLE_BIT" with expression '0x00002000', CType: int
void glBegin(int mode)
Entry point to C language function: void {@native glBegin}(GLenum mode) Part of GL_VERSION_1_0
static final int GL_MAP2_TEXTURE_COORD_2
GL_VERSION_1_0 Define "GL_MAP2_TEXTURE_COORD_2" with expression '0x0DB4', CType: int
static final int GL_AUTO_NORMAL
GL_VERSION_1_0 Define "GL_AUTO_NORMAL" with expression '0x0D80', CType: int
void glVertex3f(float x, float y, float z)
Entry point to C language function: void {@native glVertex3f}(GLfloat x, GLfloat y,...
void glVertex2f(float x, float y)
Entry point to C language function: void {@native glVertex2f}(GLfloat x, GLfloat y) Part of GL_VER...
void glNormal3fv(FloatBuffer v)
Entry point to C language function: void {@native glNormal3fv}(const GLfloat * v) Part of GL_VERSI...
void glEvalMesh2(int mode, int i1, int i2, int j1, int j2)
Entry point to C language function: void {@native glEvalMesh2}(GLenum mode, GLint i1,...
void glEnd()
Entry point to C language function: void {@native glEnd}() Part of GL_VERSION_1_0
void glMapGrid2f(int un, float u1, float u2, int vn, float v1, float v2)
Entry point to C language function: void {@native glMapGrid2f}(GLint un, GLfloat u1,...
void glNormal3dv(DoubleBuffer v)
Entry point to C language function: void {@native glNormal3dv}(const GLdouble * v) Part of GL_VERS...
void glMap2f(int target, float u1, float u2, int ustride, int uorder, float v1, float v2, int vstride, int vorder, FloatBuffer points)
Entry point to C language function: void {@native glMap2f}(GLenum target, GLfloat u1,...
void glNormal3d(double nx, double ny, double nz)
Entry point to C language function: void {@native glNormal3d}(GLdouble nx, GLdouble ny,...
void glScaled(double x, double y, double z)
Entry point to C language function: void {@native glScaled}(GLdouble x, GLdouble y,...
void glPushAttrib(int mask)
Entry point to C language function: void {@native glPushAttrib}(GLbitfield mask) Part of GL_VERSIO...
static final int GL_EVAL_BIT
GL_VERSION_1_0 Define "GL_EVAL_BIT" with expression '0x00010000', CType: int
static final int GL_QUAD_STRIP
GL_VERSION_1_0 Define "GL_QUAD_STRIP" with expression '0x0008', CType: int
void glPixelStorei(int pname, int param)
Entry point to C language function: void {@native glPixelStorei}(GLenum pname, GLint param) Part o...
void glGetIntegerv(int pname, IntBuffer data)
Entry point to C language function: void {@native glGetIntegerv}(GLenum pname, GLint * data) Part ...
static final int GL_LINE_LOOP
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_LINE_LOOP" with expre...
static final int GL_UNPACK_ALIGNMENT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNPACK_ALIGNMENT" wit...
static final int GL_TRIANGLES
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLES" with expre...
void glDisable(int cap)
Entry point to C language function: void {@native glDisable}(GLenum cap) Part of GL_ES_VERSION_2_0...
static final int GL_TRIANGLE_FAN
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLE_FAN" with ex...
static final int GL_LINE_STRIP
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_LINE_STRIP" with expr...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
static final int GL_FRONT_AND_BACK
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FRONT_AND_BACK" with ...
static final int GL_FALSE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FALSE" with expressio...
static final int GL_CW
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_CW" with expression '...
void glFrontFace(int mode)
Entry point to C language function: void {@native glFrontFace}(GLenum mode) Part of GL_ES_VERSION_...
void glPushMatrix()
Push the current matrix to it's stack, while preserving it's values.
void glPopMatrix()
Pop the current matrix from it's stack.
void glTranslatef(float x, float y, float z)
Translate the current matrix.
void glRotatef(float angle, float x, float y, float z)
Rotate the current matrix.
void glScalef(float x, float y, float z)
Scale the current matrix.
Wrapper for a GLU quadric object.