aboutsummaryrefslogtreecommitdiffstats
path: root/Tesselation.txt
blob: 10b45fe2c5a3099806fe32d34997cfe5a25d0014 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

Since GL4Java 2.2.0, tesselation is supported !
================================================

Please look in the sources and/or javadoc
of: 
	gl4java.GLUTFunc

There exist also many demos:

	demos/MiscDemos/tess
	demos/MiscDemos/tessdemo
	demos/MiscDemos/tesswind

DETAILS
=======

The native callback manager of GL4Java seeks the 
callback function with:
	- callback method-type (the "which" argument of the Callback function)
	- the current gl-context

Because the callback manager functions do not know the 
tessellator/nurbs/quadratics id,
only ONE callback-method for one gl-context and "which"-method
is supported !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Tesselation FAQ:
=================

Jean-Yves BRUD asked:

> What is the meaning of parameter signature ?
> If my callback method name is myVertexCallBack (for a GLU_TESS_VERTEX
> callback),
> what is the value of the signature parameter ?

public void  gluTessCallback(     long tobj, int which,
			          Object methodClassInstance, 
			          String methodName, 
				  String signature,
				  int voidArrayLen1,
				  int voidArrayLen2,
				  int voidArrayLen3,
				  int voidArrayLen4,
				  int voidArrayLen5
				  );


Example (tessdemo.java line 337):
	glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, gl,
			      "glVertex2fv", "([F)V",
			      2, 0, 0, 0, 0);

The signature "([F)V" is the original java style signature of the
argument-list, your callback method takes (here: glVertex2fv) !

	void glVertex2fv( const GLfloat v[2] ) 

	(...) := within the brackets are function arguments signature part
	[F    := float array
	V     := void - 
                 the signature part after the brackets 
		 means the return value

Read SUN's Java Documentation for Java-Callback methods:
         http://java.sun.com/docs/books/tutorial/native1.1/implementing/method.html

Here you can find the mapping of function arguments to its corresponding
string signature representation !

Jean-Yves BRUD asked:

>
> What is the meaning of the 5 parameters: voidArrayLen1, voidArrayLen2,
> voidArrayLen3,
> voidArrayLen4, voidArrayLen5, and what value do I need to put ?
>

public void  gluTessCallback(     long tobj, int which,
			          Object methodClassInstance, 
			          String methodName, 
				  String signature,
				  int voidArrayLen1,
				  int voidArrayLen2,
				  int voidArrayLen3,
				  int voidArrayLen4,
				  int voidArrayLen5
				  );

The maximum number of arrays within the argumentlist of 
a GLU Callback function for Tesselation is 5 !

So, the arguments voidArrayLen[1-5] refines the expected
size of the arrays, 
which are passed into and from the java callback funtion.

	OpenGL-Machine <-> GL4Java-Callback-Handler <-> Java-Callback-Method

E.g. (tessdemo.java):
         glu.gluTessCallback ( tobj, GLU_TESS_COMBINE, this,
                                "combine_callback", "([D[D[F[F)V",
                                2, 0, 0, 2, 0);

        public void combine_callback( double coords[/*3*/],
                               double vertex_data[/*4xn(=0)*/],
                               float weight[/*4*/], float[/*m(=2)*/] data )
        {
           data[0] = (float) coords[0];
           data[1] = (float) coords[1];
        }

You can see, we do use the arrays "data" and "coords" with a size of 2 !
You are not allowed to use nonsense sizes, because this can hurt your
application with a segementation fault !
(Well the GL4Java Callback functions checks
 the array sizes to OpenGL's maximum, .. but be kind of ..)

The OpenGL machine calls GL4Java's callback function,
which dispatches the call (incl. data) to your java callback function !

Sven Goethel
http://www.jausoft.com
8th February 2001