New Release D3D9Client Development

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks.
here you go:
000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels D3D9: ERROR: D3D9ClientSurface: GetDC() Failed D3D9: ERROR: Surface name is clbkCreateSurfaceEx Handle=0x240824B8 (256,256) D3D9: ERROR: Surface Has a Surface Interface D3D9: ERROR: Surface Is Lockable D3D9: ERROR: Surface is in a DefaultPool D3D9: ERROR: Surface has RENDERTARGET usage D3D9: ERROR: Surface Format is 22 D3D9: ERROR: ActiveFlags( OAPISURFACE_RENDERTARGET ) D3D9: ERROR: Surface 0x16D13E70 wasn't in the catalog
 

Attachments

  • d3d9log.zip
    93.6 KB · Views: 1

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I went back to the HDC code. Except for one function. After severeal exits and enters I final got the error:
D3D9: ERROR: D3D9ClientSurface: GetDC() Failed
D3D9: ERROR: Surface name is clbkCreateSurfaceEx Handle=0x244A4600 (512,512)
D3D9: ERROR: Surface Has a Surface Interface
D3D9: ERROR: Surface Is Lockable
D3D9: ERROR: Surface is in a DefaultPool
D3D9: ERROR: Surface has RENDERTARGET usage
D3D9: ERROR: Surface Format is 22
D3D9: ERROR: ActiveFlags( OAPISURFACE_RENDERTARGET )


Now that I went back to HDC no assertion error. Still get the call stack.
 

Attachments

  • d3d9log1.zip
    124.6 KB · Views: 1
Last edited:

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
I have looked the log and browsed the source code and I can't find any reason why the GetDC() fails. The surface could be internally locked by the DirectX which might cause external lock request to fail. I don't really know. The HDC is old school so far back that it won't work well in parallel with modern GPU pipelines. Mostly due to multithreading and parallel processing issues. So, mixing HDC with DirectX based drawing calls is a bad idea.

If the next generation graphics client is Vulkan based then HDC won't work for anything else except for MFDs and a like. DirectX 11/12 might allow to continue HDC use but it's highly questionable how well it would work.

It's recommended to move to a Sketchpad from the HDC.

Have you been able to identify from where is the call to GetDC() made ? Is it from within your work or some add-on ? If it's from your own work then translating the part to use sketchpad would likely solve the problem.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks. I will convert my HDC to sketchpad. Is there some where info about sketchpad commands? I know when I look at the code and hover it gives some info.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
So I redid the all the hdc redraw thing. But keep getting a CTD. This needs to be redone. But not sure what it should look like?
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd) { oapi::Font* font = oapiCreateFont(-11, true, "Arial"); //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); skp->SetFont(font); skp->SetTextColor(0x0000FF); skp->SetTextAlign(oapi::Sketchpad::CENTER); if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0, 0, 255, 13 }; FillRect(skp, &r, (HBRUSH)GetStockObject(BLACK_BRUSH)); } else { // MFD powered on HFONT pFont = (HFONT)SelectObject(skp); const char* label; int x = 24; for (int bt = 0; bt < 5; bt++) { if (label = oapiMFDButtonLabel(mfd, bt)) { skp->Text( x, 1, label, strlen(label)); x += 42; } else break; } skp->Text(234, 1, "PG", 2); SelectObject(skp, pFont); } oapiReleaseDC(surf, skp); /* HDC hDC = oapiGetDC(surf); // D. Beachy: BUGFIX: if MFD powered off, cover separator lines and do not paint buttons if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0, 0, 255, 13 }; FillRect(hDC, &r, (HBRUSH)GetStockObject(BLACK_BRUSH)); } else { // MFD powered on HFONT pFont = (HFONT)SelectObject(hDC, g_Param.font[0]); SetTextColor(hDC, RGB(0, 255, 216)); SetTextAlign(hDC, TA_CENTER); SetBkMode(hDC, TRANSPARENT); const char *label; int x = 24; for (int bt = 0; bt < 5; bt++) { if (label = oapiMFDButtonLabel(mfd, bt)) { TextOut(hDC, x, 1, label, strlen(label)); x += 42; } else break; } TextOut(hDC, 234, 1, "PG", 2); SelectObject(hDC, pFont); } oapiReleaseDC(surf, hDC); */ //oapi::Font* font = oapiCreateFont(40, true, "*Seven Segment"); //oapi::Sketchpad* skp = oapiGetSketchpad(surf); //skp->SetFont(font); //skp->SetTextColor(0x0000FF); //skp->SetTextAlign(oapi::Sketchpad::LEFT); }

From Atlantis :
void Atlantis::RedrawPanel_MFDButton (SURFHANDLE surf, int mfd) { HDC hDC = oapiGetDC (surf); // D. Beachy: BUGFIX: if MFD powered off, cover separator lines and do not paint buttons if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0,0,255,13 }; FillRect(hDC, &r, (HBRUSH)GetStockObject(BLACK_BRUSH)); } else { // MFD powered on HFONT pFont = (HFONT)SelectObject (hDC, g_Param.font[0]); SetTextColor (hDC, RGB(0,255,216)); SetTextAlign (hDC, TA_CENTER); SetBkMode (hDC, TRANSPARENT); const char *label; int x = 24; for (int bt = 0; bt < 5; bt++) { if (label = oapiMFDButtonLabel (mfd, bt)) { TextOut (hDC, x, 1, label, strlen(label)); x += 42; } else break; } TextOut (hDC, 234, 1, "PG", 2); SelectObject (hDC, pFont); } oapiReleaseDC (surf, hDC); }
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
This seems to work in normal graphics. In d3d9 though it locks up.
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd) { oapi::Font* font = oapiCreateFont(-11, true, "Arial"); //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); //skp->SetTextColor(BBGGRR) skp->SetFont(font); skp->SetTextColor(0x00FF00); skp->SetTextAlign(oapi::Sketchpad::CENTER); if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0, 0, 255, 13 }; skp->Rectangle(0, 0, 255, 13); } else { // MFD powered on const char* label; int x = 24; for (int bt = 0; bt < 5; bt++) { if (label = oapiMFDButtonLabel(mfd, bt)) { skp->Text( x, 1, label, strlen(label)); x += 42; } else break; } skp->Text(234, 1, "PG", 2); } oapiReleaseSketchpad(skp); }

D3D9: ERROR: D3D9ClientSurface: GetDC() Failed D3D9: ERROR: Surface name is clbkCreateSurface Handle=0xF58D8E0 (256,36) D3D9: ERROR: Surface Has a Texture Interface D3D9: ERROR: Surface Has a Surface Interface D3D9: ERROR: Surface is in a DefaultPool D3D9: ERROR: Surface has DYNAMIC usage D3D9: ERROR: Surface Format is 22 D3D9: ERROR: Surface Has 1 MipMaps D3D9: ERROR: ActiveFlags( )

oapiGetDC is not in any noncommented code

when I exit the start screen looks like this:

And I get this in the log:

000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels 000023.457: D3D9: [Session Closed. Scene deleted.] 000023.457: D3D9: [Destroy Render Window Called] D3D9: ERROR: [Failed to Reset DirectX Device] (Likely blocked by undeleted resources) 000023.457: **** Closing simulation session
 

Attachments

  • d3d9log2.zip
    19.2 KB · Views: 1
  • d3d9screen.jpg
    d3d9screen.jpg
    55.8 KB · Views: 3

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I removed all the redraw except the mfd. No issues. the only thing in the log is:
000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels 000061.245: D3D9: [Session Closed. Scene deleted.] 000061.245: D3D9: [Destroy Render Window Called] D3D9: ERROR: [Failed to Reset DirectX Device] (Likely blocked by undeleted resources) 000061.245: **** Closing simulation session
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd) { oapi::Font* font = oapiCreateFont(-11, true, "Arial"); //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); //skp->SetTextColor(BBGGRR) skp->SetFont(font); skp->SetTextColor(0x00FF00); skp->SetTextAlign(oapi::Sketchpad::CENTER); if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0, 0, 255, 13 }; skp->Rectangle(0, 0, 255, 13); } else { // MFD powered on const char* label; int x = 24; for (int bt = 0; bt < 5; bt++) { if (label = oapiMFDButtonLabel(mfd, bt)) { skp->Text(x, 1, label, strlen(label)); x += 42; } else break; } skp->Text(234, 1, "PG", 2); } oapiReleaseSketchpad(skp); }
 
Last edited:

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
C++:
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd)
{
    oapi::Font* font = oapiCreateFont(-11, true, "Arial");
    //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
    oapi::Sketchpad* skp = oapiGetSketchpad(surf);
    //skp->SetTextColor(BBGGRR)
    skp->SetFont(font);
    skp->SetTextColor(0x00FF00);
    skp->SetTextAlign(oapi::Sketchpad::CENTER);
    
    if (oapiGetMFDMode(mfd) == MFD_NONE) {
        RECT r = { 0, 0, 255, 13 };
        skp->Rectangle(0, 0, 255, 13);
    }
    else { // MFD powered on
        const char* label;
        int x = 24;
        for (int bt = 0; bt < 5; bt++) {
            if (label = oapiMFDButtonLabel(mfd, bt)) {
                skp->Text( x, 1, label, strlen(label));
                x += 42;
            }
            else break;
        }
        skp->Text(234, 1, "PG", 2);
    }
    oapiReleaseSketchpad(skp);
}

I see no reason why this code should lockup in D3D9. But there is a memory leak due to oapiCreateFont(). Fonts should be created during vessel initialization not in a "Draw" routines.

Code:
D3D9: ERROR: D3D9ClientSurface: GetDC() Failed
D3D9: ERROR: Surface name is clbkCreateSurface Handle=0xF58D8E0 (256,36)
D3D9: ERROR: Surface Has a Texture Interface
D3D9: ERROR: Surface Has a Surface Interface
D3D9: ERROR: Surface is in a DefaultPool
D3D9: ERROR: Surface has DYNAMIC usage
D3D9: ERROR: Surface Format is 22
D3D9: ERROR: Surface Has 1 MipMaps
D3D9: ERROR: ActiveFlags( )

Once again there appears to be no visible reason for the failure. It should work under the conditions listed in the error report. Do you have any co-developers those could test the code on a different computer.

Do you have a binary package available that I could run on my computer to see what happens ? Or possibly a source code ?
How hard it is to produce the errors do they occur every time.

D3D9: ERROR: [Failed to Reset DirectX Device] (Likely blocked by undeleted resources)
This is nothing to worry about.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Now how to do this is sketchpad? this is what I have.
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd) { oapi::Font* font = oapiCreateFont(-11, true, "Arial"); //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); //skp->SetTextColor(BBGGRR) skp->SetFont(font); skp->SetTextColor(0x00FF00); skp->SetTextAlign(oapi::Sketchpad::CENTER); if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0, 0, 255, 13 }; skp->Rectangle(0, 0, 255, 13); } else { // MFD powered on
BUt this is from Atlantis.
void Atlantis::RedrawPanel_MFDButton (SURFHANDLE surf, int mfd) { HDC hDC = oapiGetDC (surf); // D. Beachy: BUGFIX: if MFD powered off, cover separator lines and do not paint buttons if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0,0,255,13 }; FillRect(hDC, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));

How to fill the rectangle with a black box?
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
There is a documentation for Sketchpad in OrbiterSDK/doc/API_Reference.chm

so, somewhere in vessel initialization:
gBlackBrush = oapiCreateBrush(0x000000);

and in a drawing routine:
C++:
skp->SetBrush(gBlackBrush);      // Enable shape filling
auto Old = skp->SetPen(NULL);     // Disable outline
skp->Rectangle(0, 0, 255, 13);
skp->SetBrush(NULL);             // Disable shape filling
skp->SetPen(Old);                 // Restore previous pen

If the FillRect is common then you could create a sub rotine
C++:
inline void FillRect(RECT *r, Brush *pBrush)
{
skp->SetBrush(pBrush);      // Enable shape filling
auto Old = skp->SetPen(NULL);     // Disable outline
skp->Rectangle(r->left,....);
skp->SetBrush(NULL);             // Disable shape filling
skp->SetPen(Old);                 // Restore previous pen
}
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks. This is only in one area. The one issue is the
gBlackBrush = oapiCreateBrush(0x000000);
does "gBlackBrush" need to be defined?
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I started back adding in my panel redraw.
void Atlantis::RedrawPanel_EVENTstatus(SURFHANDLE surf, int part) { char cbuf[20]; oapi::Font* font = oapiCreateFont(70, true, "Arial"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); skp->SetFont(font); skp->SetTextColor(0x000000); skp->SetTextAlign(oapi::Sketchpad::LEFT); sprintf(cbuf, "%d", Minutes4set); skp->Text(5, 85, cbuf, strlen(cbuf)); sprintf(cbuf, "%d", Minutes3set); skp->Text(70, 85, cbuf, strlen(cbuf)); sprintf(cbuf, "%d", Minutes2set); skp->Text(145, 85, cbuf, strlen(cbuf)); sprintf(cbuf, "%d", Minutes1set); skp->Text(220, 85, cbuf, strlen(cbuf)); oapiReleaseSketchpad(skp); }

it locks up. in the log is: 000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels 000019.844: D3D9: [Session Closed. Scene deleted.] 000019.844: D3D9: [Destroy Render Window Called] D3D9: ERROR: [Failed to Reset DirectX Device] (Likely blocked by undeleted resources) 000019.844: **** Closing simulation session D3D9: ERROR: 25997 un-released fonts!
 

JDat

Active member
Joined
Sep 6, 2010
Messages
105
Reaction score
74
Points
43
gattispilot!
Maybe offtopic, but remember what jarmonic said few posts ago:
But there is a memory leak due to oapiCreateFont(). Fonts should be created during vessel initialization not in a "Draw" routines.

Problem is here:
Code:
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd)
{
    oapi::Font* font = oapiCreateFont(-11, true, "Arial");
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks. So what should I do?

I did this all the create font are here:
Atlantis::Atlantis (OBJHANDLE hObj, int fmodel) : VESSEL4 (hObj, fmodel) {.... oapi::Font* font1 = oapiCreateFont(50, true, "*Seven Segment"); oapi::Font* font2 = oapiCreateFont(40, true, "*Seven Segment"); oapi::Font* font3 = oapiCreateFont(-11, true, "Arial");

then in the redraw:
void Atlantis::RedrawPanel_PANELRCSstatus(SURFHANDLE surf, int part) { char cbuf[20]; // oapi::Font* font1 = oapiCreateFont(50, true, "*Seven Segment"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); skp->SetFont(font1); skp->SetTextColor(0x0000FF); skp->SetTextAlign(oapi::Sketchpad::LEFT); sprintf(cbuf, "%2.0f", RCSQTY); skp->Text(0, 100, cbuf, strlen(cbuf)); skp->Text(210, 100, cbuf, strlen(cbuf)); skp->Text(105, 100, cbuf, strlen(cbuf)); oapiReleaseSketchpad(skp); }
but now font1 is undefined
 
Last edited:

JDat

Active member
Joined
Sep 6, 2010
Messages
105
Reaction score
74
Points
43
I have experience only with arduino C/C++ code, so, don't take my comment to serious, but what about changing this:
Code:
skp->SetFont(font1);
to this:
Code:
skp->SetFont(Atlantis::font1);

Looks like font1 is local for one function. You need to make it "more global" and visible for other functions.
Maybe you even need to put font1 in in Atlantis.h file class declaration private section. Hope you got an idea.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks. But I guess I don't get what to define Font1,.... in the H.
I have looked at some code for examples. like the DG and ShuttleA
 

JDat

Active member
Joined
Sep 6, 2010
Messages
105
Reaction score
74
Points
43
I am looking in DeltaGlider.cpp source code. It comes with stock Orbiter 2016.
Font creation happen in PaintMarkings function
PaintMarkings fuction is called from void DeltaGlider::clbkPostCreation ()

But... front is released in the same PaintMarkings function. :(

What about delralring forn in Atrlantis.h file private section in following way:
Code:
private:
    oapi::Font *font;

Then use font where you need in following way:

Code:
Atlantis::Atlantis (OBJHANDLE hObj, int fmodel) {
Atlantis::font1 = oapiCreateFont(50, true, "*Seven Segment");
}

void Atlantis::RedrawPanel_PANELRCSstatus(SURFHANDLE surf, int part) {
skp->SetFont(Atlantis::font1);
}

Do not forget to release font resource when deinitialisin Atlantis:
Code:
Atlantis::Atlantis () {
oapiReleaseFont (Atlantis::font1);
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks.
on in the h:
private: oapi::Font* font, font1, font2, font3;

on the CPP
// -------------------------------------------------------------- // Constructor // -------------------------------------------------------------- Atlantis::Atlantis (OBJHANDLE hObj, int fmodel) : VESSEL4 (hObj, fmodel) { #ifdef _DEBUG // D. Beachy: for BoundsChecker debugging GrowStack(); #endif Atlantis::font1 = oapiCreateFont(50, true, "*Seven Segment"); int i; plop = new PayloadBayOp (this); ...}

but it has issues:
Severity Code Description Project Path File Line Suppression State
Error C2679 binary '=': no operator found which takes a right-hand operand of type 'oapi::Font *' (or there is no acceptable conversion) SPACESHUTTLE2016EARLYMET D:\Orbiter2016\Orbitersdk\samples\SPACESHUTTLE2016E4evaearlyvccammoveEVAnewmfd MET D:\Orbiter2016\Orbitersdk\samples\SPACESHUTTLE2016E4evaearlyvccammoveEVAnewmfd MET\Atlantis.cpp 319
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
cpp
void Atlantis::Createfonts() { oapi::Font* font1 = oapiCreateFont(50, true, "*Seven Segment"); oapi::Font* font2 = oapiCreateFont(40, true, "*Seven Segment"); oapi::Font* font3 = oapiCreateFont(-11, true, "Arial"); }
h:
private: oapi::Font* font, font1, font2, font3; void Createfonts();

But when i go to the drawing part I get errors
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd) { // oapi::Font* font3 = oapiCreateFont(-11, true, "Arial"); //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); //skp->SetTextColor(BBGGRR) skp->SetFont(Atlantis::font3); skp->SetTextColor(0x00FF00); skp->SetTextAlign(oapi::Sketchpad::CENTER); if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0, 0, 255, 13 }; //skp->Rectangle(0, 0, 255, 13); //skp->SetBrush(gBlackBrush); // Enable shape filling auto Old = skp->SetPen(NULL); // Disable outline skp->Rectangle(0, 0, 255, 13); skp->SetBrush(NULL); // Disable shape filling skp->SetPen(Old); }
Severity Code Description Project Path File Line Suppression State
Error C2664 'oapi::Font *oapi::Sketchpad::SetFont(oapi::Font *) const': cannot convert argument 1 from 'oapi::Font' to 'oapi::Font *' SPACESHUTTLE2016EARLYMET D:\Orbiter2016\Orbitersdk\samples\SPACESHUTTLE2016E4evaearlyvccammoveEVAnewmfd MET D:\Orbiter2016\Orbitersdk\samples\SPACESHUTTLE2016E4evaearlyvccammoveEVAnewmfd MET\Atlantis.cpp 7705

the other error I get is this:
Severity Code Description Project Path File Line Suppression State
Error C2512 'oapi::Font': no appropriate default constructor available SPACESHUTTLE2016EARLYMET D:\Orbiter2016\Orbitersdk\samples\SPACESHUTTLE2016E4evaearlyvccammoveEVAnewmfd MET D:\Orbiter2016\Orbitersdk\samples\SPACESHUTTLE2016E4evaearlyvccammoveEVAnewmfd MET\Atlantis.cpp 312
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I redid the code and it compiles. but CTD. When running the debug I get a break on the release in the mfd code.
in the h: private: oapi::Font *font, *font1, *font2, *font3;

in the post creation:
void Atlantis::clbkPostCreation () { oapi::Font* font1 = oapiCreateFont(50, true, "*Seven Segment"); oapi::Font* font2 = oapiCreateFont(40, true, "*Seven Segment"); oapi::Font* font3 = oapiCreateFont(-11, true, "Arial");

And the mfd buttons:
void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd) { // oapi::Font* font3 = oapiCreateFont(-11, true, "Arial"); //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); oapi::Sketchpad* skp = oapiGetSketchpad(surf); //skp->SetTextColor(BBGGRR) skp->SetFont(Atlantis::font3); skp->SetTextColor(0x00FF00); skp->SetTextAlign(oapi::Sketchpad::CENTER); if (oapiGetMFDMode(mfd) == MFD_NONE) { RECT r = { 0, 0, 255, 13 }; //skp->Rectangle(0, 0, 255, 13); //skp->SetBrush(gBlackBrush); // Enable shape filling auto Old = skp->SetPen(NULL); // Disable outline skp->Rectangle(0, 0, 255, 13); skp->SetBrush(NULL); // Disable shape filling skp->SetPen(Old); } else { // MFD powered on const char* label; int x = 24; for (int bt = 0; bt < 5; bt++) { if (label = oapiMFDButtonLabel(mfd, bt)) { skp->Text(x, 1, label, strlen(label)); x += 42; } else break; } skp->Text(234, 1, "PG", 2); } oapiReleaseFont(Atlantis::font3); oapiReleaseSketchpad(skp); }
 

Attachments

  • debugerrors.jpg
    debugerrors.jpg
    63.8 KB · Views: 5
Top