# C++ QuestionDrawing MFD button labels in a 3D cockpit

#### Mr Martian

Donator
Hi All,

Firstly, I hope you have all been safe and well during these times, I've busy and away from the Orbiter community for a long while now.

I am working on an new project, and am trying to figure out a problem I have always struggled with; drawing the labels on MFD buttons in a VC. I am currently just working on a very simple ShuttlePB testbed vessel (to overcome this) so what I have in clbkLoadVC is minimal, and adapted from the ShuttleA source code:

 bool ShuttlePB::clbkLoadVC (int id) { static VCMFDSPEC mfds_left = {1, 1}; SetCameraDefaultDirection (_V(0,0,1)); // forward switch (id) { case 0: // pilot SetCameraOffset (_V(0,0.3638965,1.717594)); SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); oapiVCRegisterMFD (MFD_LEFT, &mfds_left); SURFHANDLE tex1 = oapiGetTextureHandle (mh_vc,1); //engine thrust tex // MFD1 buttons tex1 = oapiGetTextureHandle (mh_vc,1); //mfd buttons tex oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS, _V(-0.2762892, -8.237985E-02, -2.788238E-02+2.7), _V(-0.3193802, -8.237985E-02, -2.788238E-02+2.7), _V(-0.2762892, -0.122936, -2.788238E-02+2.7), _V(-0.3193802, -0.122936, -2.788238E-02+2.7)); break; } return true; } 

Again, it is extremely simple, as I just want to overcome and understand this issue (anyone who played with my earlier ISV Pegasus addon may remember the lack of MFD button labels).

I thought it may have something to do with flagging the meshgroup as D (dynamic), but alas this seems to make no difference.

If anyone could offer any advice I would greatly appreciate it.

MrMartian

#### gattispilot

Hi All,

Firstly, I hope you have all been safe and well during these times, I've busy and away from the Orbiter community for a long while now.

I am working on an new project, and am trying to figure out a problem I have always struggled with; drawing the labels on MFD buttons in a VC. I am currently just working on a very simple ShuttlePB testbed vessel (to overcome this) so what I have in clbkLoadVC is minimal, and adapted from the ShuttleA source code:

 bool ShuttlePB::clbkLoadVC (int id) { static VCMFDSPEC mfds_left = {1, 1}; SetCameraDefaultDirection (_V(0,0,1)); // forward switch (id) { case 0: // pilot SetCameraOffset (_V(0,0.3638965,1.717594)); SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); oapiVCRegisterMFD (MFD_LEFT, &mfds_left); SURFHANDLE tex1 = oapiGetTextureHandle (mh_vc,1); //engine thrust tex // MFD1 buttons tex1 = oapiGetTextureHandle (mh_vc,1); //mfd buttons tex oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS, _V(-0.2762892, -8.237985E-02, -2.788238E-02+2.7), _V(-0.3193802, -8.237985E-02, -2.788238E-02+2.7), _V(-0.2762892, -0.122936, -2.788238E-02+2.7), _V(-0.3193802, -0.122936, -2.788238E-02+2.7)); break; } return true; } 

Again, it is extremely simple, as I just want to overcome and understand this issue (anyone who played with my earlier ISV Pegasus addon may remember the lack of MFD button labels).

I thought it may have something to do with flagging the meshgroup as D (dynamic), but alas this seems to make no difference.

If anyone could offer any advice I would greatly appreciate it.

MrMartian
Hi All,

Firstly, I hope you have all been safe and well during these times, I've busy and away from the Orbiter community for a long while now.

I am working on an new project, and am trying to figure out a problem I have always struggled with; drawing the labels on MFD buttons in a VC. I am currently just working on a very simple ShuttlePB testbed vessel (to overcome this) so what I have in clbkLoadVC is minimal, and adapted from the ShuttleA source code:

 bool ShuttlePB::clbkLoadVC (int id) { static VCMFDSPEC mfds_left = {1, 1}; SetCameraDefaultDirection (_V(0,0,1)); // forward switch (id) { case 0: // pilot SetCameraOffset (_V(0,0.3638965,1.717594)); SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0)); oapiVCRegisterMFD (MFD_LEFT, &mfds_left); SURFHANDLE tex1 = oapiGetTextureHandle (mh_vc,1); //engine thrust tex // MFD1 buttons tex1 = oapiGetTextureHandle (mh_vc,1); //mfd buttons tex oapiVCRegisterArea (AID_MFD1_LBUTTONS, _R( 8 ,9, 32,218), PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER,PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_LBUTTONS, _V(-0.2762892, -8.237985E-02, -2.788238E-02+2.7), _V(-0.3193802, -8.237985E-02, -2.788238E-02+2.7), _V(-0.2762892, -0.122936, -2.788238E-02+2.7), _V(-0.3193802, -0.122936, -2.788238E-02+2.7)); break; } return true; } 

Again, it is extremely simple, as I just want to overcome and understand this issue (anyone who played with my earlier ISV Pegasus addon may remember the lack of MFD button labels).

I thought it may have something to do with flagging the meshgroup as D (dynamic), but alas this seems to make no difference.

If anyone could offer any advice I would greatly appreciate it.

MrMartian
So what happens? I have done them. BUt willing to help

#### Mr Martian

Donator
So what happens? I have done them. BUt willing to help

So just nothing is displayed, the buttons work, but there are no visible labels.

The above image shows what I have. I just placed a group over one of the buttons (circled in red). This group I have set the geometry for the entire left button array to fit into this small box (silly I know, but just wanted to see if any buttons appear). It is a square shape with a texture that fits perfectly into said shape, if this makes sense. I would have expected to see very small labels in this box, but instead nothing. Do you think it may have something to do with my texture positioning?

Thank you again.

#### Notebook

News Reporter
Donator
Not sure if this will help, do you know of this?

Its quite old, so I'm not sure if its still relevant.

#### Mr Martian

Donator
Hi both,

Thank you for your replies. Notebook thank you for the link that was worth a read. Realised I never loaded any fonts... Feel a bit stupid

I have button text working now, but one issue I can't seem to work around, is whenever I check any of the left mfd buttons, the labels for the right buttons dissapear, and don't reappear until I click on some of the right buttons. Anyone have any ideas as to what may be causing this? I thought it may have something to do with clbkVCRedrawEvent, but I'm really scratching my head here.

In clbkLoadVC it doesn't matter if I register the area for the left buttons or right buttons first, it will always be the right buttons that present this issue, left buttons work perfectly...

#### Mr Martian

Donator
Actually, I think I may have sorted it.

In clbkLoadVC, in the line where the area to print buttons on is registered, I have changed the line (below) to PANEL_REDRAW_ALWAYS. this line was just taken from Martins' ShuttleA source code, and was previously PANEL_REDRAW_USER.

 oapiVCRegisterArea (AID_MFD1_RBUTTONS, _R( 30 ,100, 512,512), PANEL_REDRAW_MOUSE|[COLOR=rgb(250, 197, 28)]PANEL_REDRAW_ALWAYS[/COLOR],PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1); 

This works for now, and I don't see any issue that may arise from this, however if anyone knows a reason why it should be PANEL_REDRAW_USER I would be interested to understand this.

Thank you all!

MrMartian

Replies
0
Views
702
Replies
1
Views
2K
Advanced Question Drawing on a texture in VC
Replies
155
Views
33K
Replies
5
Views
2K
Replies
11
Views
2K