Problem Why is this image loader not working?

thepenguin

Flying Penguin
Addon Developer
Joined
Jul 27, 2013
Messages
220
Reaction score
1
Points
16
Location
Earth-Moon Lagrange Point (L4)
Code:
void MyVessel::DefineMainPanel(PANELHANDLE hPanel) {
	static DWORD panelW = 800;
	static DWORD panelH =  400;
	float fpanelW       = (float)panelW;
	float fpanelH       = (float)panelH;
	static DWORD texW   =  128;
	static DWORD texH   =  128;
	float boundW        = (float)panelW/texW;
	float boundH        = (float)1.0-panelH/texH;

	static NTVERTEX VTX[4] = {
		{      0,       0, 0,  0,0,0,  0.0f  , boundH},
		{      0, fpanelH, 0,  0,0,0,  0.0f  , 1.0f  },
		{fpanelW, fpanelH, 0,  0,0,0,  boundW, 1.0f  },
		{fpanelW,       0, 0,  0,0,0,  boundW, boundH}
	};

	static WORD IDX[6] = {0,2,1,2,0,3};
	if (hPanelMesh) oapiDeleteMesh (hPanelMesh);
	hPanelMesh = oapiCreateMesh (0,0);
	MESHGROUP grp = {VTX, IDX, 4, 6, 0, 0, 0, 0, 0};
	oapiAddMeshGroup (hPanelMesh, &grp);

//HERE BE DRAGONS:

	LPCTSTR Z_path = "test.bmp";
	//BITMAP Bitmp;
	SURFHANDLE loadedBMP = oapiCreateSurface(
		(HBITMAP) LoadImage (0, Z_path, IMAGE_BITMAP, 200, 100, LR_LOADFROMFILE | LR_CREATEDIBSECTION)
		, false);
	oapiBlt(panel2dtex, loadedBMP, 400, 100, 0, 0, 200, 100);
	SetPanelBackground (hPanel, &panel2dtex, 1, hPanelMesh, panelW, panelH, 0, PANEL_ATTACH_BOTTOM | PANEL_MOVEOUT_BOTTOM);
	
	static NTVERTEX VTX_MFD[4] = {
		{ 50, 50,0, 0,0,0, 0,0},
		{350, 50,0, 0,0,0, 1,0},
		{ 50,350,0, 0,0,0, 0,1},
		{350,350,0, 0,0,0, 1,1}
	};
	static WORD IDX_MFD[6] = {0,1,2,3,2,1};
	MESHGROUP grp_mfd = {VTX_MFD, IDX_MFD, 4, 6, 0, 0, 0, 0, 0};
	oapiAddMeshGroup (hPanelMesh, &grp_mfd);
	RegisterPanelMFDGeometry (hPanel, MFD_LEFT, 0, 1);
}

So, I have created this in an attempt to make some headway on the panels for a ship. The MFD shows up, but the image file "test.bmp" is not loaded onto the panels. Anyone have an idea why?
 
Top