⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gl_brew.c

📁 j2me手机游戏 zhu3cheng2xu4zhu3主程序
💻 C
字号:
#include	"platform.h"
#include	"GL.H"
#include	"life_retro.h"
#include	"proto.h"

int gl_getImgHeight( IBitmap * img )
{	
	AEEBitmapInfo	info;
	if(!img) {
		return 0;
	}
	IBITMAP_GetInfo( img, &info, sizeof(AEEBitmapInfo));
	return info.cy;
}

int gl_getImgWidth( IBitmap * img )
{
	AEEBitmapInfo	info;
	if(!img)
	{
		return 0;
	}
	IBITMAP_GetInfo( img, &info, sizeof(AEEBitmapInfo));
	return info.cx;
}

void gl_drawImage(APP_T_PAPP, GL_IMAGE image, int x, int y)
{
	if(image != NULL)
	{
		AEEBitmapInfo  bi;
		IBITMAP_GetInfo( image, &bi, sizeof(bi));
		IDISPLAY_BitBlt( PAPP_(a).m_pIDisplay, x, y, bi.cx, bi.cy, image, 0, 0, AEE_RO_TRANSPARENT);
	}
}

///add here

void gl_drawImage2(app_t* pApp, GL_IMAGE dstImg, GL_IMAGE srcImg, int x, int y)
{
	app_t* l;
	l = pApp;
	if( dstImg != NULL && srcImg != NULL)
	{
		AEEBitmapInfo  bi;
		IBITMAP_GetInfo( srcImg, &bi, sizeof(bi));
		IBITMAP_BltIn( dstImg, x, y, bi.cx, bi.cy, srcImg, 0, 0, AEE_RO_COPY );
	}
}

void gl_drawImagePart( APP_T_PAPP, GL_IMAGE image, int x, int y, int tx, int ty, int tw, int th )
{
	IDISPLAY_BitBlt( 
		             PAPP_(a).m_pIDisplay,  x,y, tw, th,  image, tx, ty,  AEE_RO_COPY  );
}

void gl_drawImagePart2( APP_T_PAPP, GL_IMAGE dstImg, GL_IMAGE srcImg, int x, int y, int tx, int ty, int tw, int th )
{
	app_t* l;
	l = pApp;
	if( dstImg != NULL && srcImg != NULL)
	{
		IBITMAP_BltIn( dstImg, x, y, tw, th, srcImg, tx, ty, AEE_RO_COPY );
	}
}

int get_strWidth( APP_T_PAPP, AECHAR * text )
{
	if( !text )
	{
		return	0;
	}
	return	IDISPLAY_MeasureText( PAPP_(a).m_pIDisplay, (AEEFont)PAPP_(fontType), text );
}

void gl_drawString(APP_T_PAPP,GL_STRING str,int x,int y)
{
	IDISPLAY_DrawText(
		               PAPP_(a).m_pIDisplay, 
					   (AEEFont)PAPP_(fontType), 
					   str, 
					   -1,
	                   x,
					   y,
					   NULL, IDF_ALIGN_NONE | IDF_TEXT_TRANSPARENT
					 );
	return ;
}

void gl_fillRect(APP_T_PAPP, int x, int y, int w, int h)
{
	AEERect Rect;
	Rect.x = (uint16)x;
	Rect.y = (uint16)y;
	Rect.dx = (uint16)w;
	Rect.dy = (uint16)h;
	IDISPLAY_FillRect(PAPP_(a).m_pIDisplay, &Rect, PAPP_(setColor));
}

void gl_drawRect(APP_T_PAPP, int x, int y, int w, int h)
{
	AEERect Rect;
	Rect.x = (uint16)x;
	Rect.y = (uint16)y;
	Rect.dx = (uint16)w;
	Rect.dy = (uint16)h;
	IDISPLAY_DrawRect(PAPP_(a).m_pIDisplay, &Rect, PAPP_(setColor),0,IDF_RECT_FRAME);
}

GL_BOOL	gl_loadImage(APP_T_PAPP, int n)
{
	setImageID(PAPP,n,MAKE_RGB(255,0,255));
	return true;
}

void setImageID(app_t* pApp, int imgID, RGBVAL rgb)
{
	if(pApp->bmpImage[imgID] == NULL)
	{
		IImage *pimg;
		pimg = ISHELL_LoadResImage( pApp->a.m_pIShell, RES_FILE, (short)(imgID + IMG_IDB) );
		pApp->bmpImage[imgID] = CopyImage( pApp, pimg, true, rgb);
// 2004/07/23 Y.YOSHIDA CopyImageの中でReleaseするので削除	
//		IIMAGE_Release( pimg );	
	}
}

GL_BOOL	gl_disposeImage(APP_T_PAPP, int n)
{
	disposeImageID(PAPP,n);
	return true;
}

int gl_strWidth( APP_T_PAPP, GL_STRING text )
{
	if( !text )
	{
		return	0;
	}
	return	IDISPLAY_MeasureText( PAPP_(a).m_pIDisplay, (AEEFont)PAPP_(fontType), text );
}

void CheckMemory( app_t *pApp)
{
	IHeap* pIHeap;
	uint32 num;
	AEEDeviceInfo di;
	pIHeap = NULL;

//	uint32 un32Max = 0;

	if (SUCCESS != ISHELL_CreateInstance(pApp->a.m_pIShell,	AEECLSID_HEAP, (void**)&pIHeap))
	{
		return;
	}
/*
	if( !IHEAP_CheckAvail(pIHeap, MAX_NEED_MALLOC_SIZE) )
	{
		IHEAP_Release(pIHeap);
		return FALSE;
	}
*/
	ISHELL_GetDeviceInfo(pApp->a.m_pIShell, &di);
	num = IHEAP_GetMemStats(pIHeap);
DBGPRINTF("total RAM :%d", di.dwRAM);
DBGPRINTF("Now used RAM is:%d", num);
DBGPRINTF("free RAM:%d", di.dwRAM - num);
/*
	if( (di.dwRAM - un32Max) < (uint32)NeedHeapSize )
	{
		IHEAP_Release(pIHeap);
		return FALSE;
	}
*/
	IHEAP_Release(pIHeap);
	return;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -