Message 1 of 2
3D Dialog using OpenGL
Not applicable
06-16-2005
08:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create my own AutoCAD dialog box with interactive 3D graphics and animation. To this end, I wrote a simple ARX program that use OpenGL's GLUT utilities. Everything works beautifully until I close the dialog box. I have tried many things, but so far nothing works. Here is the basic code:
// (arxload "Test.arx")
#include
#include // glut.h
int argc=1, dialog; char *argv[]={""};
void display(void) {char str[]="Press 'Esc' to exit";
glColor3f(1,1,1); glRasterPos2f(0,0);
for(int i=0; i<(int)strlen(str); i++) {
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str);
}
glutSwapBuffers();
}
void keyboard(unsigned char key, int x, int y) {if(key==27) {
glutDestroyWindow(dialog);
glutLeaveMainLoop(); // requires freeglut.h
}}
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt) {
switch (msg) {
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE);
dialog=glutCreateWindow("My Dialog");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop(); // this might be a problem
break;
}
return AcRx::kRetOK;
}
Maybe it has something to do with my acrxEntryPoint. Any suggestions? I think it will be very cool if I can get this to work right.
// (arxload "Test.arx")
#include
#include
int argc=1, dialog; char *argv[]={""};
void display(void) {char str[]="Press 'Esc' to exit";
glColor3f(1,1,1); glRasterPos2f(0,0);
for(int i=0; i<(int)strlen(str); i++) {
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str);
}
glutSwapBuffers();
}
void keyboard(unsigned char key, int x, int y) {if(key==27) {
glutDestroyWindow(dialog);
glutLeaveMainLoop(); // requires freeglut.h
}}
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt) {
switch (msg) {
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE);
dialog=glutCreateWindow("My Dialog");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop(); // this might be a problem
break;
}
return AcRx::kRetOK;
}
Maybe it has something to do with my acrxEntryPoint. Any suggestions? I think it will be very cool if I can get this to work right.