API Question GetSurface, oapiBlt, and clbkDrawHUD?

atomicdryad

Fracking toaster
Addon Developer
Joined
Dec 25, 2010
Messages
46
Reaction score
0
Points
0
Hi, I'm trying to cache an increasingly complex overlay for the hud, as clbkDrawHUD procs ~150 times per second...and there is no need to fetch data, recalculate geometry, parse html, etc, more than 10 times a second. I had hoped to do this by spewing a buffered surface via oapiBlt onto the hud, however, the big white diagonal line I had hoped to produce, does not appear. It seems skp->GetSurface() returns null in clbkDrawHUD.

Am I doing it wrong, or is it just not possible to blit onto the hud? If it's not possible, is anyone aware of another means to this end?

Code:
        oapi::Sketchpad *vskp;
protected:
	int vhudCreated;
	SURFHANDLE vhud;

(snip)
bool ORION::clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp) {
	if(vhudCreated!=1) {
		dprint("got %i x %i",hps->W,hps->H);
		vhud=oapiCreateSurface (hps->W,hps->H);
		vhudCreated=1;
		dprint("vud==NULL? %i",(vhud==NULL?1:0));
		oapiSetSurfaceColourKey(vhud,0x010203);
		vskp=oapiGetSketchpad(vhud);
		dprint("vskp==NULL? %i",(vskp==NULL?1:0));

	}
(snip)
	if(vhudCreated==1) {
		oapiColourFill (vhud,0x010203,0,0,200,200);
		oapi::Pen * wut=oapiCreatePen(1,3,0xFEFEFE);
		vskp->SetPen(wut);
		vskp->Line(10,10,500,500);
		oapiReleasePen(wut);
                SURFHANDLE wtf=skp->GetSurface();
                dprint("hudsurface==NULL? %i",(wtf==NULL?1:0));
		oapiBlt(vhud,skp->GetSurface(),1,1,1,1,hps->W-20,hps->H-20);
	}
Code:
orion -- 0.0100000000 -- 18 31 14 0109 -- got 1274 x 994
orion -- 0.0100000000 -- 18 31 14 0125 -- vud==NULL? 0
orion -- 0.0100000000 -- 18 31 14 0125 -- vskp==NULL? 0
orion -- 0.0100000000 -- 18 31 14 0203 -- hudsurface==NULL? 1
orion -- 0.0200000000 -- 18 31 14 0234 -- hudsurface==NULL? 1
 
It seems skp->GetSurface() returns null in clbkDrawHUD.
In the Orbiter a null surface usually means that the surface is a backbuffer.

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.
 
In the Orbiter a null surface usually means that the surface is a backbuffer.

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.

Well, frack, I thought that was in reference to the api functions, not builtins like the hud. Is there a feasable way to blit the screen in a hud-like fashion or cache sketchpad output? Other than making a messy datastructure for the DrawText strings, etc.

I suppose doing it in clbk(Pre|Post)Step would be ineffective/not worth it/asking for trouble?
 
Have you tried VESSEL3::clbkRenderHUD() ?
 
Back
Top