Observation
New member
- Joined
- Jun 13, 2019
- Messages
- 26
- Reaction score
- 5
- Points
- 3
Hi,
I'm running into some trouble redrawing 2D panels.
I tried to create a custom texture adapted to the viewport (1 surface pixel = 1 screen pixel).
The surface is created like this:
with panel_surfaceWidth and panel_surfaceHeight being the texture width and height.
I'm already unsure if those flags are correct. Is OAPISURFACE_TEXTURE necessary for 2D panels? What does OAPISURFACE_RENDERTARGET actually do?
My background texture is set like this:
with PANEL_WIDTH and PANEL_HEIGHT being the logical mesh boundaries.
And finally, my area registration is done with the VESSEL4 class interface:
where .tgt is my logical target rectangle and propTgt() returns the target rectangle in texture coordinates.
It seems to turn out that the surface passed to clbkPanelRedrawEvent() corresponds to the pos parameter of RegisterPanelArea, not texpos. That means the texture is not the right size and isn't blitted in the right place.
So I tried to replace PANEL_MAP_NONE with PANEL_MAP_DIRECT. Unfortunately, the surface recieved by clbkPanelRedrawEvent() is NULL, and Orbiter crashes when leaving the 2D panel view or exiting (before my cleanup functions are called).
Then I tried to ignore the surf parameter that is recieved and just blit everything directly onto my surface I keep as a class attribute. But maybe that's not quite the right way to do it, considering I still have to deal either with a crash at the end or an unwanted black rectangle in the middle of my panel.
Does someone have any insight into this ?
I'm running into some trouble redrawing 2D panels.
I tried to create a custom texture adapted to the viewport (1 surface pixel = 1 screen pixel).
The surface is created like this:
PHP:
panel_surface = oapiCreateSurfaceEx(panel_surfaceWidth, panel_surfaceHeight,
OAPISURFACE_SKETCHPAD | OAPISURFACE_UNCOMPRESS |
OAPISURFACE_TEXTURE | OAPISURFACE_RENDERTARGET);
I'm already unsure if those flags are correct. Is OAPISURFACE_TEXTURE necessary for 2D panels? What does OAPISURFACE_RENDERTARGET actually do?
My background texture is set like this:
PHP:
panel_vessel->SetPanelBackground(hPanel, &panel_surface, 1, panel_mesh,
PANEL_WIDTH, PANEL_HEIGHT, 0,
PANEL_ATTACH_BOTTOM | PANEL_MOVEOUT_BOTTOM);
And finally, my area registration is done with the VESSEL4 class interface:
PHP:
panel_vessel->RegisterPanelArea(hPanel, PANEL_LEGS.id, PANEL_LEGS.tgt,
0, PANEL_LEGS.propTgt(panel_surfaceWidth, panel_surfaceHeight),
PANEL_REDRAW_ALWAYS | PANEL_REDRAW_SKETCHPAD,
PANEL_MOUSE_IGNORE, PANEL_MAP_NONE);
It seems to turn out that the surface passed to clbkPanelRedrawEvent() corresponds to the pos parameter of RegisterPanelArea, not texpos. That means the texture is not the right size and isn't blitted in the right place.
So I tried to replace PANEL_MAP_NONE with PANEL_MAP_DIRECT. Unfortunately, the surface recieved by clbkPanelRedrawEvent() is NULL, and Orbiter crashes when leaving the 2D panel view or exiting (before my cleanup functions are called).
Then I tried to ignore the surf parameter that is recieved and just blit everything directly onto my surface I keep as a class attribute. But maybe that's not quite the right way to do it, considering I still have to deal either with a crash at the end or an unwanted black rectangle in the middle of my panel.
Does someone have any insight into this ?