本文整理汇总了C++中TextBox::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ TextBox::Init方法的具体用法?C++ TextBox::Init怎么用?C++ TextBox::Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextBox
的用法示例。
在下文中一共展示了TextBox::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char **argv )
{
SDL_Surface *surface = 0;
// SDL initialization steps.
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER | SDL_INIT_AUDIO ) < 0 )
{
fprintf( stderr, "SDL initialization failed: %s\n", SDL_GetError( ) );
exit( 1 );
}
SDL_EnableKeyRepeat( 0, 0 );
SDL_EnableUNICODE( 1 );
const SDL_version* sversion = SDL_Linked_Version();
void* handle = SDL_LoadObject( "SDL_image" );
libIMG_Load = (PFN_IMG_LOAD)SDL_LoadFunction( handle, "IMG_Load" );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8);
int videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */
videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
surface = SDL_SetVideoMode( SCREEN_X, SCREEN_Y, 32, videoFlags );
// Load text texture
SDL_Surface* textSurface = SDL_LoadBMP( "stdfont2.bmp" );
GLuint textTextureID;
glGenTextures( 1, &textTextureID );
glBindTexture( GL_TEXTURE_2D, textTextureID );
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, textSurface->w, textSurface->h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, textSurface->pixels );
SDL_FreeSurface( textSurface );
// Load a bitmap
SDL_Surface* imageSurface = libIMG_Load( "buttons.png" );
GLuint imageTextureID;
glGenTextures( 1, &imageTextureID );
glBindTexture( GL_TEXTURE_2D, imageTextureID );
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, imageSurface->w, imageSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageSurface->pixels );
SDL_FreeSurface( imageSurface );
// 256, 128
RenderAtom textAtom( (const void*)RENDERSTATE_TEXT, (const void*)textTextureID, 0, 0, 0, 0 );
RenderAtom textAtomD = textAtom;
textAtomD.renderState = (const void*) RENDERSTATE_TEXT_DISABLED;
// 100x100
RenderAtom imageAtom( (const void*)RENDERSTATE_NORMAL, (const void*)imageTextureID, 0.5f, 0.5f, 228.f/256.f, 28.f/256.f );
// 50x50
RenderAtom decoAtom( (const void*)RENDERSTATE_NORMAL, (const void*)imageTextureID, 0, 0.25f, 0.25f, 0.f );
RenderAtom decoAtomD = decoAtom;
decoAtomD.renderState = (const void*) RENDERSTATE_DISABLED;
RenderAtom focusAtom( (const void*)RENDERSTATE_NORMAL, (const void*)imageTextureID, 0.0f, 0.25f, 0.25f, 0.50f );
TextMetrics textMetrics;
Renderer renderer;
Gamui gamui( &renderer, textAtom, textAtomD, &textMetrics );
TextLabel textLabel[2];
textLabel[0].Init( &gamui );
textLabel[1].Init( &gamui );
textLabel[0].SetText( "Hello Gamui" );
textLabel[1].SetText( "Very long text to test the string allocator." );
textLabel[1].SetPos( 10, 20 );
Image image0( &gamui, imageAtom, true );
image0.SetPos( 50, 50 );
image0.SetSize( 100, 100 );
TextBox block;
block.Init( &gamui );
block.SetPos( 50, 50 );
block.SetSize( 100, 100 );
block.SetText( "This is paragraph one.\n\nAnd number 2." );
Image image1( &gamui, imageAtom, true );
image1.SetPos( 50, 200 );
image1.SetSize( 125, 125 );
//.........这里部分代码省略.........