API Question trouble getting panel background to work when not creating it from file

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
11,320
Reaction score
2,791
Points
203
Location
between the planets
I'm at a point with my GUI framework that there's really no need for me to have a panel background texture in a file anymore (it's literally just a background color, which I'd rather declare dynamically and save some disk space while doing it).

However, I'm hitting a snag. While so far I had no problems with surfaces created on the fly with oapiCreateSurfaceEx, I do seem to run into a problem when I want that particular surface to be my panel background.

Earlier, the texture was simply loaded from file:

Code:
engPanelBG = oapiLoadTexture("mydir\\panel.dds");

Which worked fine, and still does.

However, when I replace that line with this:

Code:
engPanelBG = oapiCreateSurfaceEx(1680, 1050, OAPISURFACE_TEXTURE);
 oapiColourFill(engPanelBG, oapiGetColour(8, 8, 24), 0, 0, 1680, 1050);

Not only does my panel turn out pure white all of a sudden, it also doesn't render anything copied to it anymore.

I must conclude that oapiLoadTexture creates the surface in some other maner... I have tried different combinations of surface attribute flags, but nothing seems to do the trick. Has anybody ever tried this sucessfuly?
 
Last edited:
Try using flags:
OAPISURFACE_TEXTURE | OAPISURFACE_RENDERTARGET

does it help ?
 
This is starting to smell like a bug, unless my bitwise operations are way rustier than I thought.

If I use oapiCreateTextureSurface, it works. The documentation for oapiTextureSurface lists a specific combination of attributes the surface is created with:
The surface is created with the OAPISURFACE_TEXTURE, OAPISURFACE_RENDERTARGET, OAPISURFACE_GDI and OAPISURFACE_SKETCHPAD attributes

However, if I create a surface with oapiCreateSurfaceEx like this:

Code:
engPanelBG = oapiCreateSurfaceEx(1680, 1050, OAPISURFACE_TEXTURE | OAPISURFACE_RENDERTARGET | OAPISURFACE_GDI | OAPISURFACE_SKETCHPAD);

It still won't work. The only two explanations coming to mind is that my understanding of bitwise OR is flawed and I need to bunch the flags together differently (although I am using bitwise OR in other places where it does perform as I expect it to), or there's a bug that makes a surface created with oapiCreateSurfaceEx somehow unsuited to be used as a texture for a panel.

I am working in Orbiter Beta I might add. I haven't checked if the problem persists in 2010 P1.
 
Last edited:
Is that with inline engine or with D3D9 Client ? Are they both giving the same results ?
EDIT: Flags are combined correctly with |
EDIT2: oapiCreateSurfaceEx does not exists in 2010-P1
 
Inline, haven't tried D3D9 yet.
Doesn't matter much, might help to identify if the problem is on Orbiter's side. If you want your creation to work with 2010-P1 then oapiCreateTextureSurface is likely the way to go.
 
Back
Top