牵着老婆满街逛

严以律己,宽以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

HGE:OO FrameFunc/RenderFunc

#pragma once 

#include 
< hge.h >  

class  CGlobal 

public
   CGlobal(
void ); 
   
~ CGlobal( void ); 
   
static   bool  FrameFunction( void ); 
   
static  CGlobal *  g_pGlobal;
   HGE
*  hge; 
// private: 
    bool  InitHGE( void ); 
   
void  DestroyHGE( void ); 
}
;
Global.h


Global.cpp
#include ".\global.h" 

CGlobal::CGlobal(
void
{
   g_pGlobal 
= this
   hge 
= hgeCreate(HGE_VERSION); 
}
 

CGlobal::
~CGlobal(void

}
 

bool CGlobal::InitHGE(void

   hge
->System_SetState(HGE_LOGFILE, "global.log"); 
   hge
->System_SetState(HGE_FRAMEFUNC, this->FrameFunction); 
   hge
->System_SetState(HGE_TITLE, "Global Test"); 
   hge
->System_SetState(HGE_WINDOWED, true); 
   hge
->System_SetState(HGE_SCREENWIDTH, 1024); 
   hge
->System_SetState(HGE_SCREENHEIGHT, 768); 
   hge
->System_SetState(HGE_SCREENBPP, 32); 

   
try 
   

      hge
->System_Initiate(); 
      
return true
   }
 
   
catch(
   

      
return false
   }
 
}
 

void CGlobal::DestroyHGE(void

   hge
->System_Shutdown(); 
   hge
->Release(); 
}
 

bool CGlobal::FrameFunction(void

   
if (hge->Input_GetKeyState(HGEK_ESCAPE)) 
      
return true
   
return false
}


Main.cpp
#include "Global.h" 

CGlobal
* Main; 

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int

   Main 
= new CGlobal(); 
   
if(!Main->InitHGE()) PostQuitMessage(1); 
   Main
->DestroyHGE(); 
   delete Main; 
   
return 0
}

posted on 2007-03-08 13:39 杨粼波 阅读(517) 评论(3)  编辑 收藏 引用

评论

# re: HGE:OO FrameFunc/RenderFunc 2011-10-10 21:04 mm

FrameFunction 静态成员函数可以访问非静态的成员函数吗?  回复  更多评论   

# re: HGE:OO FrameFunc/RenderFunc[未登录] 2011-10-11 10:31 杨粼波

不能够直接访问。  回复  更多评论   

# re: HGE:OO FrameFunc/RenderFunc 2011-10-16 10:27 mm

bool CGlobal::FrameFunction(void)
{
if (hge->Input_GetKeyState(HGEK_ESCAPE))
return true;
return false;
}
这个函数不是静态的成员函数吗,hge又是非静态成员变量,这样访问不会出问题吗?求解,我写的代码跟你好相像= =。。  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理