Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 03-16-2020, 09:26 PM   #1
Observation
Orbinaut
Default 2D panel drawing

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:
PHP Code:
panel_surface oapiCreateSurfaceEx(panel_surfaceWidthpanel_surfaceHeight
        
OAPISURFACE_SKETCHPAD OAPISURFACE_UNCOMPRESS 
        
OAPISURFACE_TEXTURE OAPISURFACE_RENDERTARGET); 
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:
PHP Code:
panel_vessel->SetPanelBackground(hPanel, &panel_surface1panel_mesh
        
PANEL_WIDTHPANEL_HEIGHT0,
        
PANEL_ATTACH_BOTTOM PANEL_MOVEOUT_BOTTOM); 
with PANEL_WIDTH and PANEL_HEIGHT being the logical mesh boundaries.

And finally, my area registration is done with the VESSEL4 class interface:
PHP Code:
panel_vessel->RegisterPanelArea(hPanelPANEL_LEGS.idPANEL_LEGS.tgt
        
0PANEL_LEGS.propTgt(panel_surfaceWidthpanel_surfaceHeight), 
        
PANEL_REDRAW_ALWAYS PANEL_REDRAW_SKETCHPAD
        
PANEL_MOUSE_IGNOREPANEL_MAP_NONE); 
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 ?
Observation is offline   Reply With Quote
Old 03-16-2020, 09:43 PM   #2
Notebook
Donator
 
Notebook's Avatar


Default

Have you seen this:
https://www.orbiter-forum.com/blog.php?b=574

Its from 2009 and relates to Orbiter 2010, but may help?

N.
Notebook is offline   Reply With Quote
Thanked by:
Old 03-18-2020, 11:24 AM   #3
Observation
Orbinaut
Default

I did not in fact. Thank you for it.
I'm specifically having trouble with textures of different (and variable) size. I'll give it a try with mesh modification, see how that goes.
To my understanding, redraw surfaces are blitted directly on the surface provided to RegisterPanelArea. Is that right? Also, is the panel automatically redrawn at each frame or is there a specific function to call for this ?
Observation is offline   Reply With Quote
Old 03-18-2020, 11:49 AM   #4
Notebook
Donator
 
Notebook's Avatar


Default

I'm afraid I can't help you with those questions, hopefully folk here can.

I followed along with that tutorial at the time, but I never really understood the concepts.
Went back to making bases!
Notebook is offline   Reply With Quote
Old 03-18-2020, 02:08 PM   #5
Observation
Orbinaut
Default

Haha fair enough.
So I tried implementing those animations through mesh modifications, but I couldn't find a method to redraw the panel (or only a specific mesh group), so my screen is static. Unfortunately, Martin's masterclass ended right when he was going to explain that. But he was talking about this, so it must be possible somehow.
Observation is offline   Reply With Quote
Old 03-18-2020, 04:06 PM   #6
Notebook
Donator
 
Notebook's Avatar


Default

Sometime ago I was working on a making an engine test-stand and control room for an add-on.
Got somewhere with the graphics.
https://s89.photobucket.com/user/Not...97c0a.png.html

https://s89.photobucket.com/user/Not...cced3.png.html

https://s89.photobucket.com/user/Not...l?sort=3&o=158

All got a bit too complex for me, but if you make progress I'd be interested.

N.
Notebook is offline   Reply With Quote
Thanked by:
Old 03-21-2020, 08:15 AM   #7
asbjos
tuanibrO
 
asbjos's Avatar
Default

Quote:
Originally Posted by Observation View Post
 Haha fair enough.
So I tried implementing those animations through mesh modifications, but I couldn't find a method to redraw the panel (or only a specific mesh group), so my screen is static. Unfortunately, Martin's masterclass ended right when he was going to explain that. But he was talking about this, so it must be possible somehow.
I had the same frustration myself. So I can't see to make an animated panel either.

You could try looking into the DG/ShuttleA source code. I tried it myself, but all the hundreds of different functions and classes made it too cluttered for me. Maybe you will understand it better.
asbjos is offline   Reply With Quote
Thanked by:
Old 03-23-2020, 05:40 PM   #8
Observation
Orbinaut
Default

So I had a look I had a look into the DG code and it turns out that it was very similar to what I had written. Just modify the panel mesh with either oapiMeshGroup() or oapiEditMeshGroup() (I didn't actually understand where the difference is, apparently the latter is better), and the rest is magic. Turns out I had some other errors in my code that made it skip the animation .
Now I have a working landing legs animation!!

But I would keep on a side note that VESSEL4::RegisterPanelArea() makes Orbiter pass a SURFHANDLE the size of pos, not texpos to clbkPanelRedrawEvent...
Observation is offline   Reply With Quote
Thanked by:
Old 03-23-2020, 07:43 PM   #9
llarian
Orbinaut
 
llarian's Avatar
Default

When you guys sort it all out, how about posting a tutorial on the subject?
llarian is offline   Reply With Quote
Thanked by:
Old 03-27-2020, 10:14 AM   #10
Observation
Orbinaut
Default

Quote:
Originally Posted by llarian View Post
 When you guys sort it all out, how about posting a tutorial on the subject?
Sure! It might be a while until I get to that point though.

As I understand it, the panel is rerendered at each frame anyways. So I think that the mesh modification method is actually faster than the clbkPanelRedrawEvent method: no need to have uncompressed surfaces, no blitting, and I'm also wondering how Orbiter handled the case of a panel area being on two mesh groups in past implementations (VESSEL2)(edit: nevermind, VESSEL2::RegisterPanelArea() doesn't exist anyway). Martin gives it the disadvantage of a complexified mesh. Does that have a significant performance impact?

Regarding performance, I was wondering how much of a performance improvement we can have if we adapt the texture once vs letting the GC do it when rendering. Is that a sensible thing to do, since the GC does it all the time anyways?

Of course, for elements like MFD buttons or the like, for which we have to create the content at run time, we still need uncompressed textures. For drawing unto those, the best thing to use is the Sketchpad, if I'm not mistaken? Then, is there an advantage to use the clbkPanelRedrawEvent function rather than drawing directly onto the surface?

Last edited by Observation; 03-28-2020 at 01:56 PM.
Observation is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 07:10 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.