Creating OpenGL Window from Orbiter Add-On

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,669
Reaction score
798
Points
128
Is there any special flags required in order to create a working window for Orbiter add-on. I know there is a special OAPI call to create a dialog but that probably won't work because I need to open an OpenGL rendering context.


staticchar *WNDC_NAME={"IFPlanner\0"};

memset(&wndc, 0, sizeof(wndc));

wndc.lpszClassName = WNDC_NAME;
wndc.style = CS_VREDRAW|CS_HREDRAW|CS_OWNDC;
wndc.lpfnWndProc = WndProc;
wndc.hInstance = hModIns;
wndc.hIcon = NULL;
wndc.hCursor = NULL;
wndc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);


RegisterClass(&wndc);

hWnd = CreateWindow(WNDC_NAME, "Interplanetary Flight Planner\0",
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, WindowWidth, WindowHeight, hParentWnd, hMnu, hModIns, NULL);

//
// Create Pixel Format
//
PIXELFORMATDESCRIPTOR pfd;

memset(&pfd, 0, sizeof(pfd));

pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_ACCELERATED|PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 0;
pfd.cDepthBits = 32;
pfd.cStencilBits = 16;
pfd.cAlphaBits = 8;
 
Last edited:

reverend

Addon Developer
Addon Developer
Beta Tester
Joined
Apr 14, 2008
Messages
221
Reaction score
2
Points
18
I've been doing work with this making my external/remote MFD application.

I believe ExtMFD.cpp and MFDWindow.cpp could help you to get a window initialized. They're in the SDK Samples under ExtMFD.

Sorry that I don't have a more specific answer to your question.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,669
Reaction score
798
Points
128
I've been doing work with this making my external/remote MFD application.

I believe ExtMFD.cpp and MFDWindow.cpp could help you to get a window initialized. They're in the SDK Samples under ExtMFD.

Thanks about this. But there is an other problem. I have upgraded into VC2005 and I can't find a way to create a proper Dialog resource. There is a GUI designer with VC2005 but all this is complitely different. Also there seems to be very lot of System::Windows::Form::Crazy::Stuff something that I have never seen before and I don't have much intrest to start studying it right now. I wonder is this all compatible with OrbiterAPI ?

I have a quite lot of experience from Linux Qt programming but this isn't anything like it either.

But anyway I managed to get the window working in Windowed mode by attaching both oapiDefDialogProc and DefWindowProc in WindowProc. But there are still some problems in full screen mode. My window seems to works as long as there are other dialogs, launched by Orbiter, on a screen. It seems that Orbiter will change the screen update "mechanism" depending wheter there are dialogs on a screen or not. So the problem, probably, is that Orbiter just doesn't know about the Window. Maybe there should be oapiRegisterWindow() or something...
 
Last edited:
Top