2D图象与菜单

西昌.何雨锋   

 

2D图象与菜单

[primitive  原始的] [Vertices 顶点] [clamp 夹子] [Quad 方嵌]

1、2DScreenImmediate是少数几个既不归scene管辖,也不用从scene中建立的类,用来在屏幕上画线、画图等2D的东西,而不管背景是否是3D的。
而2DScreenText则是用来在屏幕上写字的一个类。

2、imt建立与使用:
                  CTVScreen2DImmediate* imt1;
       imt1=new CTVScreen2DImmediate();      //建立
                背景的使用:
 imt1->Settings_SetAutoDrawBackground(true);
 imt1->Load_Background("..//..//Media//up.jpg",false);
3、text的建立与使用:
                  CTVScreen2DText*  txt1;
                  txt1=new CTVScreen2DText();    //建立

 txt1->NormalFont_Create("font1","Arial",15,false,false,false);    //建立出了一个字体,大小是15,字体为Arial,名叫font1.
                

4、关于在图象运算中经常遇到的RGBA颜色,必须包含头文件HelperFunctions.h,否则无法调用这个函数,而global中完全取消了对这个函数的定义。


5、在循环中将图象或字画或写出来:
                 图象:
                  图象必须先由texturefactory载入,然后由global标识出来,才能使用。
                  imt1->Action_Begin2D();
                  imt1->Draw_Texture(global1->GetTex("down"),150,150,300,300,RGBA(1,1,1,1),RGBA(1,1,1,1),RGBA(1,1,1,1),RGBA(1,1,1,1),0,0,1,1);     
                  //所有从texturefactory中读取的图象都必须以global1->GetTex("图象名")的方式读取出来;
                          ...
                  imt1->Action_End2D();
                 文字:
                  txt1->Action_BeginText(false); 
                  txt1->NormalFont_DrawText("This Game Been CopyRight By 西昌 何雨锋 2007-2008
v0.6",400,740,RGBA(1,1,1,1),"font2");
                          ...
                  txt1->Action_EndText()

3、其他2DScreenImmediate函数:               
                  void Draw_FilledEllipse(float x, float y, float radiusX, float radiusY, int step = 12, int color = -1);
                     //画填充椭圆
 void Draw_Ellipse(float x, float y, float radiusX, float radiusY, int step = 12, int color = -1);
                    //画空椭圆
 void Draw_Circle(float x, float y, float radius, int step = 12, int color = -1);
                    //画圆
 void Draw_Triangle(float x1, float y1, float x2, float y2, float x3, float y3, int color = -1);
                    //画三角
 void Draw_Box(float x1, float y1, float x2, float y2, int color = -1 );
                    //画矩形
 void Draw_Texture(int tex, float x1, float y1, float x2, float y2, int color1 = -1, int color2 = -2, int color3 = -2, int color4 = -2, float tu1 = 0.0f, float tv1 = 0.0f, float tu2 = 1.0f, float tv2 = 1.0f);
                   //将某一图象画上去
 void Draw_Sprite(int tex, float x, float y, int color = -1);
 void Draw_TextureRotated(int tex, float x, float y, float width, float height , float angle, int color1 = -1, int color2 = -2, int color3 = -2, int color4 = -2, float tu1 = 0.0f, float tv1 = 0.0f, float tu2 = 1.0f, float tv2 = 1.0f);
 void Draw_Line(float x, float y, float x1, float y1, int color1 = -1, int color2 = -2 );
 void Draw_Line3D(float x, float y, float z, float x1, float y1, float z1, int color1 = -1, int color2 = -2);
                   //在3D中画线
 void Draw_FilledTriangle(float x1, float y1, float x2, float y2, float x3, float y3, int color1 = -2, int color2 = -2, int color3 = -2);
 void Draw_FilledCircle(float x, float y, float radius, int step = 12, int color = -1);
 void Draw_FilledBox(float x1, float y1, float x2, float y2, int color1 = -1, int color2 = -2, int color3 = -2, int color4 = -2);

 void Draw_CustomWithShader(CTVShader* shader, cCONST_TV_PRIMITIVETYPE primitivetype, cTV_CUSTOM2DVERTEX* pVerticesArray, int numvertices, int tex1 = 0, int tex2 = 0, int tex3 = 0, int tex4 = 0);
 void Draw_Custom(int tex, cCONST_TV_PRIMITIVETYPE primitivetype, cTV_CUSTOM2DVERTEX* pVerticesArray, int numvertices);

 void Draw_Recorded(int lIndex);

 void Load_Background(char* sFilename, bool bTiling = false);
                    //读取背景
 void Draw_Background();
                    //画背景
 void Delete_Background();
                    //删除背景
 // settings.
 void Settings_SetClamping(bool bEnable);
                    //设置夹子
 void Settings_SetAlphaTest(bool bEnable, int alpharef = 128);
 void Settings_SetAlphaBlending(bool bEnable, cCONST_TV_BLENDINGMODE eBlendingmode);
 void Settings_SetAlphaBlendingEx(bool bEnable, cCONST_TV_BLENDEX eSrcBlend, cCONST_TV_BLENDEX eDestBlend);
 void Settings_SetTextureFilter(cCONST_TV_TEXTUREFILTER eTextureFilter);
 void Settings_SetAutoDrawBackground(bool bEnable);
                   //设置自动画背景
 // recording/call list.
 int Action_RecordEnd();
 void Action_RecordStart();

 // normal 2d
 void Action_End2D();
 void Action_Begin2D();

 // projection.
 bool Math_3DPointTo2D(cTV_3DVECTOR* vPoint, float* ret_x, float* ret_y, bool bFrontOnly = false);
                  //运算一个3D点在2D上的坐标
 bool Draw_RollOver(int iTextureOver, int iTextureNormal, float fLeft, float fTop, float fRight, float fBottom);
                 //画卷动物
 bool Draw_RollOverEx(int iTextureOver, int iTextureNormal, float fTextureLeft, float fTextureTop, float fTextureRight, float fTextureBottom, float fMouseLeft, float fMouseTop, float fMouseRight, float fMouseBottom);
 

 void Settings_Set3DLineParameters(bool bUseDepthTesting);
 void Draw_FullscreenQuadWithShader(CTVShader* pShader, float fTULeft, float fTVTop, float fTURight, float fTUBottom, int iOptionalTextureLayer0 = 0, int iOptionalTextureLayer1 = 0);
 void Draw_Point(float fX, float fY, int iColor = -1);
 void Draw_SpriteScaled(int iTexture, float fX, float fY, int iColor = -1, float fScaleX = 1.0f, float fScaleY = 1.0f);
 void Action_RecordDelete(int iRecordIndex);

 cCONST_TV_TEXTUREFILTER Settings_GetTextureFilter();
 void Settings_GetAlphaBlendingEx(bool* retbEnable, cCONST_TV_BLENDEX* reteSrcBlend, cCONST_TV_BLENDEX* reteDestBlend);
 void Settings_GetAlphaTest(bool* retbEnable, int* retAlphaRef);

 void Draw_TextureRotatedEx(int iTexture, float fX, float fY, float fWidth, float fHeight , float fAngle, float fCenterX, float fCenterY, int color1 = -1, int color2 = -2, int color3 = -2, int color4 = -2, float tu1 = 0.0f, float tv1 = 0.0f, float tu2 = 1.0f, float tv2 = 1.0f);
 void Draw_Box3D(cTV_3DVECTOR* vBoxMin, cTV_3DVECTOR* vBoxMax, int iColor);
                  //画3D盒子
 void Draw_Box3DEx(cTV_3DVECTOR* vBoxMin, cTV_3DVECTOR* vBoxMax,  cTV_3DMATRIX* mMatrix, int iColor);

4、其他Screen2DText函数:
                    int NormalFont_Create(const char* sUserFont, const char* sFontName, int iSize, bool bBold, bool bUnderlined, bool bItalic);
                   //创建普通字体
 void NormalFont_DrawText(const char* sText, float x, float y, int iColor, int iNFont = 0);
                  //用普通字体写文字
 int TextureFont_Create(const char* sUserFont,const char* sFontName, int iSize, bool bBold, bool bUnderlined, bool bItalic, bool bInternational, bool bUseClearTypeAntialiasing = false);
                  //创建字体
 void TextureFont_GetTextSize(const char* sText, int iTextureFontID, float* retWidth, float* retHeight );
                  //得到字体的大小
 void TextureFont_DrawBillboardText(const char* sText, float x, float y, float z, int iColor, int iFontID = 0, float fBillboardScaleX = 1, float fBillboardScaleY = 1);
                 //写板书
 void TextureFont_DrawText(const char* sText, float x, float y, int iColor, int iTFont = 0);
                 //字体写字
 void TextureFont_DrawTextEx(const char* sText, cTV_3DMATRIX* mMat, int iColor, int iTFont = 0);
 void TextureFont_DrawTextScaled(const char* sText, float x, float y, int iColor, float fScaleX = 1.0f, float fScaleY = 1.0f, int iTFont = 0);
                 //字体写字放缩
 int TextureFont_GetTexture(int iFontId);
 int TextureFont_CreateCustom(const char* sFontName, int iTextureID, int iNumChars, cTV_TEXTUREFONT_CHAR* pCharArray);

 void Font_DeleteAll();
                 //删除所有字体
 void Font_Delete(int iIndex);
                 //删除某一字体
 void Action_BeginText(bool bUseScreen2D = false);
                 //开写
 void Action_EndText();
                 //写完
 int NormalFont_GetFontByName(const char* sFontName);
                  //以字体名得到字体代号
 int TextureFont_GetFontByName(const char* sFontName);
                 //以纹理字体名得到字体代号

 void TextureFont_GetFontData(int iFontID, int* retNumChars, cTV_TEXTUREFONT_CHAR* pCharArray);
 void NormalFont_GetTextSize(const char* sText, int iNormalFontID, float* retWidth, float* retHeight );

 void NormalFont_DrawTextUnicode(const WCHAR* sUnicodeText, float x, float y, int iColor, int iNFont);
                
 void NormalFont_GetTextSizeUnicode(const WCHAR* sUnicodeText, int iNormalFontID, float* retWidth, float* retHeight );

  bool TextureFont_Save(int iTextureFontID, const char* sDataSource, bool bIncludeTexture = true);
                  //保存某一texture字体为某文件名
 int TextureFont_Load(const char* sDataSource,  bool bLoadTexture = true, int iDefaultTexture = 0);
                   //打开某一texture字体为某文件名

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值