New Release D3D9Client Development

Can you put whole code on gihub if your project is open source, or put at least Atlantis.h and Atlantis.cpp on pastebin? I want to see "whole picture".
 
When a pen, brush or font is created as global or class wide there is no need to release it, the client will release it for you. Some cases there are no proper callback for a release to occur. Release will crash if you try to release graphics stuff after the graphics engine it-self been shutdown.

Don't use "Altantis::" when accessing variables.
 
When a pen, brush or font is created as global or class wide there is no need to release it, the client will release it for you. Some cases there are no proper callback for a release to occur. Release will crash if you try to release graphics stuff after the graphics engine it-self been shutdown.

Don't use "Altantis::" when accessing variables.
Confused:( so no need to release? I guess then where to create the font?
 
Hmm. If jamonik said: "no need to release font", then... comment out oapiReleaseFont() from you code.
 
removed the release line. I get a CTD/ when running the debug
bl3Li4S.jpg

skp->Text(x, 1, label, strlen(label));
 
Hmm. Why your RedrawPanel_MFDButton is so different from original Atralntis.cpp RedrawPanel_MFDButton

Code:
// Original Atlantis.cpp

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);
}

See the "TextOut" ? No Sketchpad and other differences...

Maybe you need to go back to original code (not all 10k lines, but some parts) and then implement your addition by small steps. step by step, then test/debug and again and again, until your get your result.
 
I thought the idea was not to have HDC?

So I tried to convert the hdc to sketchpad

I went back to the orginal Atlantis code and no issues. So use HDC or sketchpad or a mixture?
 
If you create fonts, pens and brushes in vessel constructor then it's possible that the graphics engine is not yet "fully" running and the font creation fails. I have never created a vessel for the orbiter, so, my knowledge of internal timings is not the best possible. It would be nice the have a chart showing the timing/calling order of initialization and shutdown callbacks.

Could you try clbkPostCreation() and clbkVisualCreated() for creating Fonts, Pens and Brushes. In a case of the later doing the release stuff in clbkVisualDestroyed() would not hurt.
 
Thanks.
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(Atlantis:: 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); }

and in the
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");

NO errors. but when I run it the font is wrong
 
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");
Here you assign the fonts to a local variables/pointers those doesn't exists beyond the clbkPostCreation();

It's supposed to be like this:

C++:
void Atlantis::clbkPostCreation ()
{
    font1 = oapiCreateFont(50, true, "*Seven Segment");
    font2 = oapiCreateFont(40, true, "*Seven Segment");
    font3 = oapiCreateFont(-11, true, "Arial");
    ...
}

Have you considered buying a book about C++ programming.
 
Thanks.
That worked. I started add them back
Now I get causes it to lock up nothing in the log:
000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels 000032.877: D3D9: [Session Closed. Scene deleted.] 000032.877: D3D9: [Destroy Render Window Called] D3D9: ERROR: [Failed to Reset DirectX Device] (Likely blocked by undeleted resources) 000032.877: **** Closing simulation session
 
Last edited:
Thanks. I think i got her to work no ctd the log entry is this:
000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels 000003.195: D3D9: [Session Closed. Scene deleted.] 000003.195: D3D9: [Destroy Render Window Called] D3D9: ERROR: [Failed to Reset DirectX Device] (Likely blocked by undeleted resources) 000003.195: **** Closing simulation session
 
Hope you are creating oapiCreateFont(50, true, "*Seven Segment"); in void Atlantis::clbkPostCreation ()
 
Thanks. I think i got her to work no ctd the log entry is this:
000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels 000003.195: D3D9: [Session Closed. Scene deleted.] 000003.195: D3D9: [Destroy Render Window Called] D3D9: ERROR: [Failed to Reset DirectX Device] (Likely blocked by undeleted resources) 000003.195: **** Closing simulation session
Like I said before this can be mostly ignored. The client is supposed to release all user resources that the user have forgotten to release. It could be a problem on a client side or maybe some add-on has forgotten to release a HDC
 
yes void Atlantis::clbkPostCreation () { font1 = oapiCreateFont(50, true, "*Seven Segment"); font2 = oapiCreateFont(40, true, "*Seven Segment"); //font3 = oapiCreateFont(-11, true, "Arial"); font3 = oapiCreateFont(70, true, "Arial"); font4 = oapiCreateFont(25, true, "*Seven Segment");
 
D3D9Client 4.23 is out.

There is a new beta uploaded. Since, it's almost a year from a previous "stable" release. Might be good idea to check that no major bugs CTD's exists to prevent running the client. So, that a new "stable" release could be made.
I have added some sanity checks in resource allocation/release to spot possible problems. For add-on developers it's recommended to check the Orbiter.log for errors.

- Terrain "vibration" should be fixed.
 
I have tested 4.23 within my Linux/WINE configuration and it works so far...like the previous version.
However, one question I have in mind since years...
This is Linux/WINE specific, so...I know not the supported OS/env....

This is what happens many times over the last couple of years in Orbiter 2016 using various WINE/D3D9-client and different (native and WINE-built-in) version of DirectX:

-starting Orbiter with D3D9Client = Orbiterng seg-fault right before see the rendered scenario, loadingscreen was fine
-happens mostly with newer Add-Ons like the SpaceX or Delta-rockets addons
-workaround (not allways helpfull, but much more stable loading): chnaging the SCN-file to have a camera-focus to empty space.
-if then the SCN loads fine, I (mostly) switch back to vessel-view, and have a lower chance to run in a CTD.

So my question/idea:

Could there be a race-condition during initial SCN-rendering, like i.e. in WINE where we have to deal with delayed caused by "translated" SYS-CALLS.
If this might be the cause of the issues, maybe a D3D9-client "start-render-delay-in-ms" could be a cheap dirty workaround for such emulated environments ?

Maybe I am complete wrong, but there is nothing in the logs, just "loaded fine" and CTD.
I have seen this issue now on three different machines over the last years, both INTEL and AMD CPU's....and AMD and NVIDIA graphics cards.
The fact, that this problem might be easier to repro using recent addons, might be related that newer addons are using more recent texture and mesh features ?
 
D3D9Client 4.23 is out.

There is a new beta uploaded. Since, it's almost a year from a previous "stable" release. Might be good idea to check that no major bugs CTD's exists to prevent running the client. So, that a new "stable" release could be made.
I have added some sanity checks in resource allocation/release to spot possible problems. For add-on developers it's recommended to check the Orbiter.log for errors.

- Terrain "vibration" should be fixed.
I'm getting this in both logs at exit: [ERROR] Release(0xCF71440) Ref. count not zero
No CTDs, but also no clue (can't find that address elsewhere in the logs).
 
Back
Top