-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTRAIN_00098.eml
283 lines (209 loc) · 6.44 KB
/
TRAIN_00098.eml
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
NoneNoneNative window not shown in JNIHi,
I've written a JNI OpenGL program, but the native OpenGL window isn't
being shown. I am new to cocoa and Apple windowing development and
don't understand why the window isn't shown even though the print
statements in the OpenGL drawing code are all executed. Below is a
section of code in C and java that should create and display the
window then draw a simple OpenGL object.
David
// object-C code
int InitWindowMac(JNIEnv * env, jobject panel)
{
std::cout << "Enteringing InitWindowMac" << std::endl;
jboolean result = JNI_FALSE;
jint lock = 0;
std::cout << "Before result = JAWT_GetAWT(env, &awt);" << std::endl;
// get the AWT
awt.version = JAWT_VERSION_1_4;
result = JAWT_GetAWT(env, &awt);
if(result != JNI_FALSE)
std::cout << "JNI_FALSE" << std::endl;
std::cout << "After result = JAWT_GetAWT(env, &awt);" << std::endl;
if( env->ExceptionOccurred() )
{
env->ExceptionDescribe();
}
assert(result != JNI_FALSE);
std::cout << "After JAWT_GetAWT assert" << std::endl;
ds = awt.GetDrawingSurface(env, panel);
std::cout << "After ds = awt.GetDrawingSurface(env, panel);" << std::endl;
if( env->ExceptionOccurred() )
{
env->ExceptionDescribe();
}
assert(ds != NULL);
std::cout << "After awt.GetDrawingSurface(env, panel) assert" << std::endl;
lock = ds->Lock(ds);
if( env->ExceptionOccurred() )
{
env->ExceptionDescribe();
}
assert( (lock & JAWT_LOCK_ERROR) == 0 );
std::cout << "After awt.GetDrawingSurface(env, panel) assert" << std::endl;
dsi = ds->GetDrawingSurfaceInfo(ds);
if(dsi)
{
dsi_mac = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo;
if( env->ExceptionOccurred() )
{
env->ExceptionDescribe();
}
}
else
{
std::cout << "dsi is null exiting" << std::endl;
return 0;
}
std::cout << "Before NSView *view = dsi_mac->cocoaViewRef;" << std::endl;
// get the corresponding peer from the calling panel
NSView *view = dsi_mac->cocoaViewRef;
std::cout << "Before NSView NSWindow *window = [view Window];" << std::endl;
if(view)
std::cout << "view !=null" << std::endl;
else
{
std::cout << "view is null exiting" << std::endl;
return 0;
}
// get the coregraphics from the parent window
NSWindow *window = [view window];
std::cout << "Before NSOpenGLPixelFormatAttribute attrs[]" << std::endl;
NSOpenGLPixelFormatAttribute attrs[] = {
NSOpenGLPFAScreenMask,
CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
NSOpenGLPFAColorSize, 24,
NSOpenGLPFADepthSize, 16,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
0
};
NSOpenGLPixelFormat *pixelFormat;
std::cout << "Before pixelFormat = [[NSOpenGLPixelFormat alloc]
initWithAttributes:attrs];" << std::endl;
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
cp = new GraphicsContextProperties();
std::cout << "after cp = new GraphicsContextProperties();" << std::endl;
cp->context = NULL;
cp->str = "";
context = [NSOpenGLContext alloc];
if ( context )
{
std::cout << "context != null" << std::endl;
// Set the current OpenGL context
[context makeCurrentContext];
std::cout << "after [context makeCurrentContext];" << std::endl;
}
else
{
std::cout << "context == null exiting" << std::endl;
exit(0);
}
cp->context = context;
// match java
NSRect windowRect = [window frame];
CGAffineTransform xform = CGAffineTransformMake(1, 0, 0, -1,
dsi->bounds.x, windowRect.size.height-dsi->bounds.y);
CGContextConcatCTM( (CGContext*)context, xform );
if(cp)
BuildLinkList(env, panel, cp);
else
{
std::cout << "cp == null exiting" << std::endl;
exit(0);
}
return 1;
}
// get native window that corresponds to the current java window
JNIEXPORT jboolean JNICALL Java_AvistoGL_setForDrawing(JNIEnv * env,
jobject panel)
{
jclass cls = env->GetObjectClass(panel);
jmethodID method = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
jstring name = (jstring) env->CallObjectMethod(panel,method);
const char * chr = env->GetStringUTFChars(name, 0);
std::string str = chr;
cp = contextList->retrieve_item(str);
if( !cp )
{
std::cout << "graphics context is not in the graphics context
list"<< std::endl;
return false;
}
int ret = GetCurrentContext();
return ret;
}
// java code
public void gl_draw()
{
// ensure that the OpenGL is correctly initialized
if(isInitalized == false)
{
try
{
makeOpenGLWindow(1);
}
catch(Exception e)
{
e.printStackTrace();
return;
}
gl_init();
isInitalized = true;
}
// find the correct panel to draw the OpenGL into.
setForDrawing();
System.out.println("gl_draw()");
if(!picking)
{
reSizeGLScene( getWidth(), getHeight() );
System.out.println("!picking");
}
//draw
glClearColor(backgroundColour[0], backgroundColour[1],
backgroundColour[2], backgroundColour[3]);
System.out.println("After glClearColor");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
System.out.println("After glClear");
glMatrixMode(GL_MODELVIEW);
System.out.println("After glMatrixMode");
glLoadIdentity();
System.out.println("After glLoadIdentity");
gluLookAt(eye_x, eye_y, eye_z, lookatX, lookatY, lookatZ, upX, upY, upZ);
System.out.println("After gluLookAt");
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
System.out.println("After glDisable");
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glTranslatef(0.0f, 0.0f, 5.0f);
System.out.println("After glTranslate");
// 3rd blue
glColor3f(0.0f, 0.0f, 1.0f);
glPushName(21);
System.out.println("After glPushName");
glPushMatrix();
glTranslatef(1.3f, 0f, 10.0f);
System.out.println("After glTranslate");
glBegin(GL_TRIANGLES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(2.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 2.0f, 0.0f);
glEnd();
glPopMatrix();
glPopName();
System.out.println("After blue");
glDisable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
System.out.println("Before glFlush()");
glFlush();
System.out.println("After glFlush()");
swapBuffers();
System.out.println("After swapBuffers()");
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/mlsubscriber.tech%40csmining.org
This email sent to [email protected]