API Question Help with VC displays

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
Hi all,

I'm trying to get some displays around my VC working but without much luck. Nothing special, I just want some text to appear on them (such as Ummu situation, cargo situation etc.). I read many threads around the forum, and got some small results, but still far far away from what it should be...

So basically I'm rendering a custom display on a dedicated mesh, made by two triangles, with the proper uv coordinates and the texture (256x256 24 bit) with the flag D in the mesh file...

then, collecting what I saw around I did this:

declared as public

Code:
SURFHANDLE screen,testsc;

then in clbkSetClassCaps I initialized the sketchpad item with the test text:
Code:
 testsc=oapiCreateTextureSurface(256,256);
	oapi::Sketchpad *skp = oapiGetSketchpad (testsc);
	skp->SetOrigin(0,0);
	skp->SetBackgroundColor(0x00FFFF);
	skp->SetTextColor(0xFFFFFF);
    skp->Text(10,10,"CIAO",4);
	oapiReleaseSketchpad(skp);

then il clbkloadVC
Code:
screen=oapiGetTextureHandle(msh_h[5],1);
oapiVCRegisterArea(TESTDISP,_R(0, 256,256,0),PANEL_REDRAW_ALWAYS,PANEL_MOUSE_IGNORE,PANEL_MAP_NONE,screen);

and in clbkVCRedrawEvent

Code:
if(id==TESTDISP)
	{

		oapiBlt(screen, testsc, 0,0,0,0, 256, 256);
		oapiBlt(testsc, surf, 0,0,0,0, 256, 256);
		return true;
	}

the only way to see something is to do the double blt...

anyway I get ths with the inline:
VCscreen.jpg


and a black screen with the D3D9
...

Any help would be MUCH appreciated!

:tiphat:

---------- Post added at 04:25 PM ---------- Previous post was at 11:19 AM ----------

I just found out that I have the same result in D3D9, the surface is only much darker, but it looks exactly the same.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,907
Reaction score
205
Points
138
Location
Cape
the material 0f the group ?
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
Code:
MATERIAL --default--
 .878  .878  .878  1
 .878  .878  .878  1
 .878  .878  .878  1  0
 0  0  0  1

simply this
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
Does your meshgroup have proper material and texture have dynamic flag? Is texture uncompressed??

OrbiterSDK/Doc/ApiGuide.pdf (page31)
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
Does your meshgroup have proper material and texture have dynamic flag? Is texture uncompressed??

OrbiterSDK/Doc/ApiGuide.pdf (page31)

yep :salute:
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
It's a longshot.

I'm not sure about software you're using for modelling but I noticed that I have to use textured material in 3ds max and then alter material manually. If I use just normal (untextured) material, meshgroup loses UVW mapping on export to msh.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
I did alter it manually to correct UVW coordinates,

here is the file mesh (I'm trying with just a square mesh to understand how to do it)

Code:
MSHX1
GROUPS  1
MATERIAL 1
TEXTURE 1  
GEOM 4 2 ;Group 0  --default--
-.5 -.5  0 0  0 -1  0  1
 .5 -.5  0 0  0 -1  1  1
-.5  .5  0 0  0 -1  0  0
 .5  .5  0 0  0 -1  1  0
 0  3  1
 0  2  3
MATERIALS 1
--default--
MATERIAL --default--
 .878  .878  .878  1
 .878  .878  .878  1
 .878  .878  .878  1  0
 0  0  0  1
TEXTURES 1
white1.dds D

and why do I have to do 2 oapiblt to see something? I don't understand much of graphics rendering yet, sorry :(
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,615
Reaction score
2,335
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
I did alter it manually to correct UVW coordinates,

here is the file mesh (I'm trying with just a square mesh to understand how to do it)

Also remove the TEXTURE line in front of the mesh. You need no texture. Textures are bad for the VC MFDs.
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
Also remove the TEXTURE line in front of the mesh. You need no texture. Textures are bad for the VC MFDs.

It's not MFD. you need MFD flag (IIRC it was 7 or 3) on MFD groups but other dynamic displays can use texture

From my AV-88 wip VC mesh
Code:
LABEL Center-display
MATERIAL 22
TEXTURE 1
GEOM 124 92 ; Center-display
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
i'm a bit lost on the theory here.

when I do:
Code:
 SURFHANDLE screen=oapiGetTextureHandle(msh_h[5],1);
   oapiVCRegisterArea(TESTDISP,_R(0, 256,256,0),PANEL_REDRAW_ALWAYS,PANEL_MOUSE_IGNORE,PANEL_MAP_NONE,screen);

I think i'm getting the surface of the texture that is drawn on the group.

then I'm creating a new surface on which I draw on with sketchpad, and finally i blit the two to have the sketchpad text drawn on the texture surface.

If I remove the texture, how can i get the surface to exchange later on with the sketchpad one?
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
You're designating the surface that will be updated but that texture still needs to be applied to the meshgroup. Have you overloaded "clbkVisualCreated" yet?

This is an example from my Apollo VC.

Code:
// --------------------------------------------------------------
// Create visual representation
// --------------------------------------------------------------
void AAPO_LM::clbkVisualCreated (VISHANDLE vis, int refcount)
{
	if (refcount > 1) return; // we don't support more than one visual per object

	Visual = vis;

	// Vessel exterior
	if (surf_Skin != NULL) // Apply custom skin from scenario file if found.
	{
		DEVMESHHANDLE exmesh = GetDevMesh (vis, mesh_AscentStage);
		oapiSetTexture (exmesh, 1, surf_Skin);	
	}

[COLOR="Red"]	// Cockpit
	DEVMESHHANDLE cockpit = GetDevMesh (vis, vc->mesh);
	oapiSetTexture (cockpit, 7, vc->surf_mfdbuttons);  // add dynamic MFD buttun labels 	
	oapiSetTexture (cockpit, 12, vc->surf_digital);	// Add digital displays
[/COLOR]
} // End "clbkVisualCreated (VISHANDLE vis, int refcount)"

note that the surfaces and VC mesh are all class variables of my cockpit handler class hense the "vc->____". You shouldn't actually need that bit unless you're doing something similar. surf_digital, and surf_mfdbuttons are the textures that get manipulated by the Redraw events.
 
Last edited:

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
That could be the point!

I was not understanding how could I link the texture to the group! now I get it!

I'll give it a try tonight!
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
Glad i could help (possbily), don't forget to de-allocate everything in "clbkVisualDestroyed" either.

Only you can prevent memory leaks ;)
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
I don't know if the previous suggestions have solved your problem, but here is another point:

Your drawing surface (the surface you attach the Sketchpad object to) should probably not be a texture surface. DirectX performs various optimisations and compressions on textures that can cause problems with GDI drawing. In particular, a texture may only live in video memory, where GDI can't access it. The surface data must be copied to host memory and back every time you query a GDI context from it. In newer DX versions, GDI might not work at all on textures.

So you should create a memory surface (using oapiCreateSurface) as a canvas for your Sketchpad object, and when done drawing, use oapiBlt to copy from the memory surface to the actual texture surface that is being referenced by the mesh.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
:woohoo:

CP.jpg


Thanks to you all guys, I have something finally!!!

I was doing it not so wrong but I was missing the visual created part and another important thing: reading the post of martin got me the idea that maybe I was not filling the memory of the surface to be blitted completely, so I added a rectangle in sketchpad as big as the surface to be the background, and it worked! looks like the last row and column of pixels are still a bit to work on, but this is a great result for me!!

ThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyouThankyou

:hailprobe:

---------- Post added at 09:05 AM ---------- Previous post was at 07:10 AM ----------

and this is the result of your amazing help guys! Thank you again :cheers:

CP1.jpg

CP2.jpg

CP3.jpg
 
Top