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

📄 textures_blending.c

📁 用brew开发3D的例程
💻 C
📖 第 1 页 / 共 3 页
字号:
		return;

	TutorI3D_SetTopMenuTextValues(pMe, &xText, &yText, &maxWidth);

	TutorI3D_SetupTutorialWindow(pMe);
			
	rgb = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_API_TEXT);
	
	
	SPRINTF(chBuf, "I3D_SetTexture(tex)" );
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	outputColorText(pMe, szBuf, 15, 3, xText, yText, 
					maxWidth, CLR_API_VAR_TEXT);

	
	// Now draw the tutorial information in the bottom menu. 
	// First set the initial output point for the text and maxWidth. 
	TutorI3D_SetBottomMenuTextValues(pMe,&xText,&yText,&maxWidth);
	
	I3D_GetRenderMode(pMe->m_p3D, &renderType);
	I3D_GetTexture(pMe->m_p3D, &texture);

	IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MENU_TEXT_CLR );
	
			
	if(renderType == AEE3D_RENDER_FLAT_SHADING)
		SPRINTF(chBuf, "FLAT_SHADING");
	else if(renderType == AEE3D_RENDER_FLAT_TEXTURE_FAST_SHADING)
		SPRINTF(chBuf, "FLAT_TEXTURE_FAST_SHADING");
	else if(renderType == AEE3D_RENDER_FLAT_TEXTURE_SHADING)
		SPRINTF(chBuf, "FLAT_TEXTURE_SHADING");
	else if(renderType == AEE3D_RENDER_SMOOTH_SHADING)
		SPRINTF(chBuf, "SMOOTH_SHADING");
	else if(renderType == AEE3D_RENDER_SMOOTH_TEXTURE_FAST_SHADING)
		SPRINTF(chBuf, "SMOOTH_TEXTURE_FAST_SHADING");
	else if(renderType == AEE3D_RENDER_SMOOTH_TEXTURE_SHADING)
		SPRINTF(chBuf, "SMOOTH_TEXTURE_SHADING");
	else 
		SPRINTF(chBuf, "TEXTURE_REPLACE");
	
		
	
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	
	oldFont = IDISPLAY_SetFont(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, pMe->font10);
	oldFontHeight = pMe->charHeight;
	pMe->charHeight = IDISPLAY_GetFontMetrics(pMe->a.m_pIDisplay, AEE_FONT_NORMAL,
											  NULL, NULL); 
	
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
					&textWidth );
	yText += nLine*pMe->charHeight;
	
	
	
	SPRINTF(chBuf, "tex.type=DIFFUSED, tex.sample=NEAREST");
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth+5,
					&textWidth );
	
	yText += nLine*pMe->charHeight;


	SPRINTF(chBuf, "tex.Wrap_s = ");
	GetWrapString(chBuf + STRLEN(chBuf), texture.Wrap_s);
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth+5,
					&textWidth );
	
	yText += nLine*pMe->charHeight;

	SPRINTF(chBuf, "tex.Wrap_t = ");
	GetWrapString(chBuf + STRLEN(chBuf), texture.Wrap_t);
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth+5,
					&textWidth );

	yText += nLine*pMe->charHeight;


	SPRINTF(chBuf, "tex.BorderColorIndex = %d", texture.BorderColorIndex);
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth+5,
					&textWidth );

	yText += nLine*pMe->charHeight;	

	
	STR_TO_WSTR("Press '#' for Help", szBuf, sizeof(szBuf));
	IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf,
					  -1, 0, pMe->menuTopRect.y+pMe->menuTopRect.dy +5, 
					  NULL, IDF_ALIGN_CENTER | IDF_TEXT_TRANSPARENT);
	
	yText += nLine*pMe->charHeight;
	
	if(pMe->showTexture)
	{
		IDISPLAY_EraseRect(pMe->a.m_pIDisplay, &pMe->screenAPI3DRect);

		IDISPLAY_BitBlt(pMe->a.m_pIDisplay, 
						pMe->screenAPI3DRect.x + 5, 
						pMe->screenAPI3DRect.y + 5, 
						pMe->screenAPI3DRect.dx - (pMe->screenAPI3DRect.x+5) - 5,
						pMe->screenAPI3DRect.dy - (pMe->screenAPI3DRect.x+5) - 5, 
						texture.pImage, 
						0,0,
						AEE_RO_COPY);
		
		STR_TO_WSTR("Press '5' to return", szBuf, sizeof(szBuf));
		IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf,
					  -1, 0, pMe->menuTopRect.y+pMe->menuTopRect.dy +5, 
					  NULL, IDF_ALIGN_RIGHT | IDF_TEXT_TRANSPARENT);
	}
	

	if(pMe->showHelp && !pMe->showTexture)
	{
		IDISPLAY_EraseRect(pMe->a.m_pIDisplay, &pMe->screenAPI3DRect);

		nLine = 0;
		xText = pMe->menuTopRect.x + 1;
		yText = pMe->menuTopRect.y + pMe->menuTopRect.dy + 5;

	
		STR_TO_WSTR("1: Wrap_s toggle", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);
		

		STR_TO_WSTR("2: Wrap_t toggle", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

		STR_TO_WSTR("3: Texture image toggle", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

		STR_TO_WSTR("4: Render Mode toggle", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);
		
		STR_TO_WSTR("5: Show/Hide Texture image", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

		STR_TO_WSTR("#: Show/Hide Help", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

	}
	
	IDISPLAY_SetFont(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, oldFont);
	pMe->charHeight = oldFontHeight;
	IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb);

}


/*===========================================================================

  FUNCTION: TexturesBlendingAlphaManipulateBuf
  
	DESCRIPTION
	   This function adds text and 2D graphics to the frame buffer after
	   3D frame render is complete for the alpha blending tutorial.
	  
	PROTOTYPE:
	  void TexturesBlendingAlphaManipulateBuf(TutorI3D* pMe)
		
	PARAMETERS:
	  pMe: [in]: Pointer to TutorI3D sturcture
	  		  
	DEPENDENCIES
	  none
				  
	RETURN VALUE
	  none
					
	SIDE EFFECTS
	  none
===========================================================================*/

void TexturesBlendingAlphaManipulateBuf(TutorI3D* pMe)
{

	AECHAR szBuf[80];
	char chBuf[80];
	RGBVAL rgb=0;
	
	int textWidth;

	int nLine=0;	// # of lines used to output text
	int maxWidth;
	int xText;
	int yText;
	
	if(!pMe)
		return;

	TutorI3D_SetTopMenuTextValues(pMe, &xText, &yText, &maxWidth);
	
	TutorI3D_SetupTutorialWindow(pMe);

	rgb = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_API_TEXT);
	
	SPRINTF(chBuf, "I3D_Enable(Blending)" );
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	outputColorText(pMe, szBuf, 11, 8, xText, yText, 
					maxWidth, CLR_API_VAR_TEXT);


	// Now draw the tutorial information in the bottom menu. 
	// First set the initial output point for the text and maxWidth. 
	TutorI3D_SetBottomMenuTextValues(pMe,&xText,&yText,&maxWidth);
	
	
	IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MENU_TEXT_CLR );
	
	if(pMe->alphaEnabled)
		SPRINTF(chBuf, "Alpha Blending: ENABLED");
	else
		SPRINTF(chBuf, "Alpha Blending: DISABLED");

	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
					&textWidth );
	
	yText += nLine*pMe->charHeight;

	SPRINTF(chBuf, "alpha = %d", pMe->alphaValue);
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
					&textWidth );
	
	yText += nLine*pMe->charHeight;
	
		
	STR_TO_WSTR("Press '#' for Help", szBuf, sizeof(szBuf));
	IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf,
					  -1, 0, 0, NULL, IDF_ALIGN_CENTER | IDF_ALIGN_BOTTOM | 
					  IDF_TEXT_TRANSPARENT);
	
	
	if(pMe->showHelp)
	{
		IDISPLAY_EraseRect(pMe->a.m_pIDisplay, &pMe->screenAPI3DRect);

		nLine = 0;
		xText = pMe->menuTopRect.x + 1;
		yText = pMe->menuTopRect.y + pMe->menuTopRect.dy + 5;

		STR_TO_WSTR("Up: increase", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText+nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

		STR_TO_WSTR("Down: decrease", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText+nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

		STR_TO_WSTR("1: enable/disable blending", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText+nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);
	
			
		STR_TO_WSTR("#: show/hide help", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

	}
	
	
	IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb);

}


/*===========================================================================

  FUNCTION: TexturesBlendingPerspectiveManipulateBuf
  
	DESCRIPTION
	   This function adds text and 2D graphics to the frame buffer after
	   3D frame render is complete for the perspective correction tutorial.
	  
	PROTOTYPE:
	  void TexturesBlendingPerspectiveManipulateBuf(TutorI3D* pMe)
		
	PARAMETERS:
	  pMe: [in]: Pointer to TutorI3D sturcture
	  		  
	DEPENDENCIES
	  none
				  
	RETURN VALUE
	  none
					
	SIDE EFFECTS
	  none
===========================================================================*/

void TexturesBlendingPerspectiveManipulateBuf(TutorI3D* pMe)
{

	AECHAR szBuf[80];
	char chBuf[80];
			
	RGBVAL rgb=0;
	
	int textWidth;

	int nLine=0;	// # of lines used to output text
	int maxWidth;
	int xText;
	int yText;
	
	if(!pMe)
		return;

	TutorI3D_SetTopMenuTextValues(pMe, &xText, &yText, &maxWidth);
	
	TutorI3D_SetupTutorialWindow(pMe);

	rgb = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_API_TEXT);
	
	SPRINTF(chBuf, "I3D_Enable(Perspective_Correction)" );
	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	outputColorText(pMe, szBuf, 11, 22, xText, yText, 
					maxWidth, CLR_API_VAR_TEXT);
	
	
	// Now draw the tutorial information in the bottom menu. 
	// First set the initial output point for the text and maxWidth. 
	TutorI3D_SetBottomMenuTextValues(pMe,&xText,&yText,&maxWidth);
		
	
	IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MENU_TEXT_CLR );
	
	
	if(pMe->perspectiveCorrEnabled)
		SPRINTF(chBuf, "Perspective Correction: ENABLED");
	else
		SPRINTF(chBuf, "Perspective Correction: DISABLED");

	STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
	nLine = outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
					&textWidth );
	
	yText += nLine*pMe->charHeight;
	
		
	STR_TO_WSTR("Press '#' for Help", szBuf, sizeof(szBuf));
	IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf,
					  -1, 0, 0, NULL, IDF_ALIGN_CENTER | IDF_ALIGN_BOTTOM | 
					  IDF_TEXT_TRANSPARENT);
	
	
	if(pMe->showHelp)
	{
		IDISPLAY_EraseRect(pMe->a.m_pIDisplay, &pMe->screenAPI3DRect);

		nLine = 0;
		xText = pMe->menuTopRect.x + 1;
		yText = pMe->menuTopRect.y + pMe->menuTopRect.dy + 5;

		STR_TO_WSTR("1: enable/disable pers. correction", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText+nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);
	
			
		STR_TO_WSTR("#: show/hide help", szBuf, sizeof(szBuf));
		nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
						yText + nLine*pMe->charHeight, 
						-1, pMe->di.cxScreen -5, &textWidth);

	}
	
	
	IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb);

}


/*===========================================================================

  FUNCTION: GetWrapString
  
	DESCRIPTION
	   This function retrieves the text string associated with the 
	   wrapType, and puts it into chBuf. 
	  
	PROTOTYPE:
	  static void GetWrapString(char* chBuf, AEE3DTextureWrapType wrapType)
		
	PARAMETERS:
	  chBuf: [in]: character array where to put string. should be at least 40
				   chars long
	  wrapType [in]: the wrap type for which to retrieve the string
	  		  
	DEPENDENCIES
	  none
				  
	RETURN VALUE
	  none
					
	SIDE EFFECTS
	  none
===========================================================================*/

static void GetWrapString(char* chBuf, AEE3DTextureWrapType wrapType)
{
	if(!chBuf) return;

	if(wrapType == AEE3D_TEXTURE_WRAP_REPEAT)
	{
		STRCPY(chBuf,"WRAP_REPEAT");		
			
	}
	else if(wrapType == AEE3D_TEXTURE_WRAP_MIRROR)
	{
		STRCPY(chBuf,"WRAP_MIRROR");
			
	}
	else if(wrapType == AEE3D_TEXTURE_WRAP_CLAMP)
	{
		STRCPY(chBuf,"WRAP_CLAMP");
			
	}
	else if(wrapType == AEE3D_TEXTURE_WRAP_BORDER)
	{
		STRCPY(chBuf,"WRAP_BORDER");
			
	}
	

}


/*===========================================================================

  FUNCTION: GetNextTextureID
  
	DESCRIPTION
	   This function returns the resource ID of the next texture based on 
	   texIn. 
	  
	PROTOTYPE:
	  static int16 GetNextTextureID(int16 texIn)
		
	PARAMETERS:
	  texIn: [in]: Resource ID of the current texture. 
	  
	DEPENDENCIES
	  none
				  
	RETURN VALUE
	  Resource ID of the next texture. 
					
	SIDE EFFECTS
	  none
===========================================================================*/
static int16 GetNextTextureID(int16 texIn)
{

	int16 textureID;

	if(texIn == IDB_TEXTURE_WOOD)
		textureID = IDB_TEXTURE_MUSIC;
	else if(texIn == IDB_TEXTURE_MUSIC)
		textureID = IDB_TEXTURE_WATER;
	else if(texIn == IDB_TEXTURE_WATER)
		textureID = IDB_TEXTURE_ROCK;
	else if(texIn == IDB_TEXTURE_ROCK)
		textureID = IDB_TEXTURE_METAL;
	else if(texIn == IDB_TEXTURE_METAL)
		textureID = IDB_TEXTURE_METAL1;
	else if(texIn == IDB_TEXTURE_METAL1)
		textureID = IDB_TEXTURE_MARBLE;
	else if(texIn == IDB_TEXTURE_MARBLE)
		textureID = IDB_TEXTURE_LEATHER;
	else if(texIn == IDB_TEXTURE_LEATHER)
		textureID = IDB_TEXTURE_BRICK;
	else if(texIn == IDB_TEXTURE_BRICK)
		textureID = IDB_TEXTURE_RED;
	else if(texIn == IDB_TEXTURE_RED)
		textureID = IDB_TEXTURE_WOOD;
	else 
		textureID = IDB_TEXTURE_WOOD;
	
	return textureID;

}

⌨️ 快捷键说明

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