I'm displaying a 2D representation of a vessel's mesh inside an MFD:
Obviously saving all the lines into an array and drawing them with oapi::Sketchpad's Line function is proving quite costly.
Reducing the number of sampled vertices will improve performance, but not enough. I think the best way is to draw the mesh onto some surface in memory, and blit this onto the MFD at each update.
Creating a SURFHANDLE and drawing on it with oapi::Sketchpad has (seemingly) worked fine. However, I'm having a problem blitting this onto the MFD. In MFD2::Update, I am passed an oapi::Sketchpad* skp, which has a function GetSurface() - this should give me the MFD's display surface. The problem is using oapiBlt to blit the mesh onto the display surface... nothing gets displayed.
I found a note in the API docs, and a mention of it in this thread:
So it seems impossible from within the Update function.
It must still be possible without using GDI, since Martins replied to a very similar question here:
So my question is, how do I get the MFD's display surface some other way? Am I missing some function in the API?
Obviously saving all the lines into an array and drawing them with oapi::Sketchpad's Line function is proving quite costly.
Reducing the number of sampled vertices will improve performance, but not enough. I think the best way is to draw the mesh onto some surface in memory, and blit this onto the MFD at each update.
Creating a SURFHANDLE and drawing on it with oapi::Sketchpad has (seemingly) worked fine. However, I'm having a problem blitting this onto the MFD. In MFD2::Update, I am passed an oapi::Sketchpad* skp, which has a function GetSurface() - this should give me the MFD's display surface. The problem is using oapiBlt to blit the mesh onto the display surface... nothing gets displayed.
I found a note in the API docs, and a mention of it in this thread:
jarmonik said:There is a note in the API documentation of oapiBlt():
"This function must not be used while a device context is acquired for the target surface (i.e. between oapiGetDC and oapiReleaseDC calls)."
This means no oapiBlt calls in a callbacks those are using a sketchpad. In elsewhere a NULL should be a valid handle to blit in the backbuffer.
So it seems impossible from within the Update function.
It must still be possible without using GDI, since Martins replied to a very similar question here:
Martins said:Assuming your bmp has been stored as a resource in your module:
- use the WindowsAPI LoadImage function to load the bitmap from the module. This will give you a HBITMAP handle.
- use oapiCreateSurface(HBITMAP) to create a surface from the bitmap
- use oapiBlt to copy the surface into the MFD's display surface
So my question is, how do I get the MFD's display surface some other way? Am I missing some function in the API?
Last edited: