本文整理汇总了C++中DrawTexture函数的典型用法代码示例。如果您正苦于以下问题:C++ DrawTexture函数的具体用法?C++ DrawTexture怎么用?C++ DrawTexture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DrawTexture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawString
bool DrawString( int x, int y, std::string str, unsigned int color = 0xFFFFFFFF, Font* fnt = 0, int caretpos = -1 )
{
if( fnt == 0 )
fnt = mDefaultFont;
int charpos = 0;
int caretx = -1;
for( int i = 0; i < (int)str.length( ); i++ )
{
char thischar = str[i];
DrawTexture( x + charpos, y, fnt->GetCharSizeX( ), fnt->GetCharSizeY( ), fnt->GetCharTexX( thischar ),
fnt->GetCharTexY( thischar ), fnt->GetCharSizeX( ), fnt->GetCharSizeY( ), fnt->GetTexture( ),
color, true );
if( i == caretx )
caretx = charpos;
charpos += fnt->GetCharWidth( thischar );
}
if( caretpos >= 0 && GetTickCount( ) % 1500 > 750 )
{
if( caretx < 0 )
caretx = charpos;
caretx -= ( fnt->GetCharWidth( '|' ) / 2 ) - 1;
DrawTexture( x + caretx, y, fnt->GetCharSizeX( ), fnt->GetCharSizeY( ), fnt->GetCharTexX( '|' ),
fnt->GetCharTexY( '|' ), fnt->GetCharSizeX( ), fnt->GetCharSizeY( ), fnt->GetTexture( ),
color, true );
}
return true;
};
示例2: BlurGI
void BlurGI(RenderTarget *rt) {
blurRT->Bind();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
blurYShader.Bind();
blurYShader.SetUniform("resolution", (float)blurRT->Size(), (float)blurRT->Size());
// テクスチャ描画
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, rt->Texture());
blurYShader.SetUniform("texture", (int)0);
DrawTexture(0, 0, 1, 1);
blurYShader.Unbind();
rt->Bind();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
blurXShader.Bind();
blurXShader.SetUniform("resolution", (float)rt->Size(), (float)rt->Size());
// テクスチャ描画
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, blurRT->Texture());
blurXShader.SetUniform("texture", (int)0);
DrawTexture(0, 0, 1, 1);
blurXShader.Unbind();
}
示例3: GetColor
void GUIControl::Draw()
{
if(IsVisible())
{
if(GetTexture())
{
COLOR4 c = GetColor();
glColor4ub(c.r, c.g, c.b, c.a);
if(GetCurrentPattern() == 0)
{
DrawTexture(GetX(), GetY(),
0, 0,
GetWidth(), GetHeight(),
GetTexture(),
false, false, 100, 100);
}
else
{
DrawTexture(GetX(), GetY(),
GetCurrentPattern() * GetWidth(),
0,
GetCurrentPattern() * GetWidth() + GetWidth(),
GetHeight(),
GetTexture(),
false, false, 100, 100);
}
}
if(GetCaption() && GetCaptionFont())
{
COLOR4 c = GetCurrentCaptionColor();
glColor4ub(c.r, c.g, c.b, c.a);
PrintText(GetCaption(),
GetCaptionFont(),
GetX() + GetCaptionX(),
GetY() + GetCaptionY());
}
if(GetBorder())
{
if(GetBorderType() == btAlways)
{
Box(GetX(), GetY(), GetWidth(), GetHeight());
}
else if(GetBorderType() == btOnMouseMove)
{
if(_draw_border)
Box(GetX(), GetY(), GetWidth(), GetHeight());
}
}
}
}
示例4: glMatrixMode
// Draw texture.
MapilVoid GLSprite::DrawTexture( SharedPointer < Texture > pTexture,
ImageTransformationMethod method,
const Vector2 < MapilFloat32 >& v )
{
// If texture hasn't been created, this function returns immediately.
if( !pTexture.GetPointer() ){
return;
}
// Set up the transformation matrix for the image.
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
// Set up the transformation matrix for the image.
switch( method ){
case IMAGE_TRANSFORMATION_METHOD_MOVE:
glTranslatef( v.m_X, v.m_Y, 0.0f );
break;
default:
break;
}
// Draw texture.
DrawTexture( pTexture );
glFlush();
// Restore the transformation matrix.
glPopMatrix();
}
示例5: DrawOptions
/*
* Cheats Code Options Menu
*/
void DrawOptions(struct option_entry option, u8 alpha, int y_inc, int selIndex)
{
if (!option.name || !option.value)
return;
int c = 0, yOff = 80, cIndex = 0;
int maxPerPage = (512 - (yOff * 2)) / y_inc;
int startDrawX = selIndex - (maxPerPage / 2);
int max = maxPerPage + startDrawX;
SetFontSize(y_inc-6, y_inc-4);
for (c = startDrawX; c < max; c++)
{
if (c >= 0 && c < option.size)
{
SetFontColor(0x00000000 | ((alpha * CalculateAlphaList(c, selIndex, maxPerPage)) / 0xFF), 0);
if (option.name[c])
DrawString(MENU_SPLIT_OFF + MENU_ICON_OFF, yOff, option.name[c]);
//Selector
if (c == selIndex)
{
int i = 0;
for (i = MENU_SPLIT_OFF; i < 848; i++)
DrawTexture(menu_textures[mark_line_png_index], i, yOff, 0, menu_textures[mark_line_png_index].texture.width, menu_textures[mark_line_png_index].texture.height, 0xFFFFFF00 | alpha);
}
cIndex++;
}
yOff += y_inc;
}
}
示例6: BltSmartBuffer
void BltSmartBuffer(IDirect3DDevice9* Device)
{
if (SmartGlobal != nullptr)
{
std::uint8_t* Ptr = reinterpret_cast<std::uint8_t*>(SmartGlobal->dbg);
for (int I = 0; I < SmartGlobal->height; ++I)
{
for (int J = 0; J < SmartGlobal->width; ++J)
{
std::uint8_t B = *(Ptr++);
std::uint8_t G = *(Ptr++);
std::uint8_t R = *(Ptr++);
*(Ptr++) = (B == 0 && G == 0 && R == 0) ? 0 : 0xFF;
}
}
if (!Texture) /**Set Device->Reset for more info.**/
{
LoadTexture(Device, static_cast<unsigned char*>(SmartGlobal->dbg), SmartGlobal->width, SmartGlobal->height, Texture);
}
/*else
{
memcpy(TexturePixels, SmartGlobal->dbg, SmartGlobal->width * SmartGlobal->height * 4);
}*/
DrawTexture(Device, Texture, 0, 0, SmartGlobal->width, SmartGlobal->height);
SafeRelease(Texture);
}
}
示例7: Render
int Render() {
RenderVPL();
RenderVPLPos();
RenderVPLNormal();
RenderGI();
for (int i = 0; i < 6; i ++)
BlurGI(giRT);
RenderShadowmap();
RenderObject();
glViewport(0, 0, windowWidth, windowHeight);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
postShader.Bind();
// テクスチャ描画
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, cameraRT->Texture());
postShader.SetUniform("texture", (int)0);
postShader.SetUniform("resolution", (float)windowWidth, (float)windowHeight);
postShader.SetUniform("time", (float)SDL_GetTicks());
DrawTexture(0, 0, 1, 1);
postShader.Unbind();
SDL_GL_SwapBuffers();
return 0;
}
示例8: GetMaxGLTexCoords
DWORD SpoutSenderSDK2::ProcessOpenGL(ProcessOpenGLStruct *pGL)
{
// We need a texture to process
if (pGL->numInputTextures < 1) return FF_FAIL;
if (pGL->inputTextures[0] == NULL) return FF_FAIL;
FFGLTextureStruct &InputTexture = *(pGL->inputTextures[0]);
// get the max s,t that correspond to the width, height
// of the used portion of the allocated texture space
FFGLTexCoords maxCoords = GetMaxGLTexCoords(InputTexture);
// Draw now whether a sender has initialized or not
DrawTexture(InputTexture.Handle, maxCoords);
// If there is no sender name yet, the sender cannot be created
if(!UserSenderName[0]) {
return FF_SUCCESS; // keep waiting for a name
}
// Otherwise create a sender if not initialized yet
else if(!bInitialized) {
// Update the sender name
strcpy_s(SenderName, 256, UserSenderName);
// Set global width and height so any change can be tested
m_Width = (unsigned int)InputTexture.Width;
m_Height = (unsigned int)InputTexture.Height;
// Create a new sender
bInitialized = sender.CreateSender(SenderName, m_Width, m_Height);
if(!bInitialized) {
sender.spout.SelectSenderPanel("Could not create sender\nTry another name");
UserSenderName[0] = 0; // wait for another name to be entered
}
return FF_SUCCESS; // give it one frame to initialize
}
// Has the texture size or user entered sender name changed
else if(m_Width != (unsigned int)InputTexture.Width
|| m_Height != (unsigned int)InputTexture.Height
|| strcmp(SenderName, UserSenderName) != 0 ) {
// Release existing sender
sender.ReleaseSender();
bInitialized = false;
return FF_SUCCESS; // return for initialization on the next frame
}
// Render the Freeframe texture into the shared texture
// Important - pass the FFGL host FBO to restore the binding because Spout uses a local fbo
// Default aspect = 1.0, default invert flag = true
if(bMemoryMode)
sender.SendTexture(InputTexture.Handle, GL_TEXTURE_2D, m_Width, m_Height);
else
sender.DrawToSharedTexture(InputTexture.Handle, GL_TEXTURE_2D, m_Width, m_Height, (float)maxCoords.s, (float)maxCoords.t, 1.0f, true, pGL->HostFBO);
return FF_SUCCESS;
}
示例9: RenderObject
void RenderObject() {
cameraRT->Bind();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
shader.Bind();
shader.SetUniform("resolution", (float)cameraRT->Size(), (float)cameraRT->Size());
shader.SetUniform("uAmbient", ambient[0], ambient[1], ambient[2], ambient[3]);
shader.SetUniform("uLightIntensity", lightIntensity[0], lightIntensity[1], lightIntensity[2], lightIntensity[3]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, lightRT->Texture());
shader.SetUniform("shadowMap", (int)0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, giRT->Texture());
shader.SetUniform("giTexture", (int)1);
SetMatrix(shader);
DrawObjects(shader);
shader.Unbind();
// テクスチャ描画
const float aspect = (float)windowWidth / windowHeight;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, lightRT->Texture());
DrawTexture(0.9f, -0.8f, 0.1f, 0.1f * aspect);
glBindTexture(GL_TEXTURE_2D, vplRT->Texture());
DrawTexture(0.6f, -0.8f, 0.1f, 0.1f * aspect);
glBindTexture(GL_TEXTURE_2D, vplPosRT->Texture());
DrawTexture(0.3f, -0.8f, 0.1f, 0.1f * aspect);
glBindTexture(GL_TEXTURE_2D, vplNormalRT->Texture());
DrawTexture(0.0f, -0.8f, 0.1f, 0.1f * aspect);
glBindTexture(GL_TEXTURE_2D, giRT->Texture());
DrawTexture(-0.3f, -0.8f, 0.1f, 0.1f * aspect);
}
示例10: DrawGameList
/*
* Cheats Codes Selection Menu
*/
void DrawGameList(int selIndex, struct game_entry * games, int glen, u8 alpha)
{
SetFontSize(14, 16);
SetCurrentFont(font_comfortaa_regular);
int game_y = 80, y_inc = 20;
int maxPerPage = (512 - (game_y * 2)) / y_inc;
int x = selIndex - (maxPerPage / 2);
int max = maxPerPage + selIndex;
if (max > glen)
max = glen;
for (; x < max; x++)
{
int xo = 0; //(((selIndex - x) < 0) ? -(selIndex - x) : (selIndex - x));
if (x >= 0)
{
u8 a = ((alpha * CalculateAlphaList(x, selIndex, maxPerPage)) / 0xFF);
if (isGameActivated(games[x]))
{
DrawTextureCentered(menu_textures[mark_arrow_png_index], MENU_ICON_OFF + (MENU_TITLE_OFF / 2), game_y + (y_inc / 2), 0, MENU_TITLE_OFF / 3, y_inc / 2, 0xFFFFFF00 | a);
}
SetFontColor(0x00000000 | a, 0x00000000);
if (games[x].name)
{
char * nBuffer = (char*)malloc(strlen(games[x].name));
strcpy(nBuffer, games[x].name);
int game_name_width = 0;
while ((game_name_width = WidthFromStr(nBuffer)) > 0 && (MENU_ICON_OFF + (MENU_TITLE_OFF * 1) - xo + game_name_width) > (800 - (MENU_ICON_OFF * 3) - xo))
nBuffer[strlen(nBuffer) - 1] = '\0';
DrawString(MENU_ICON_OFF + (MENU_TITLE_OFF * 1) - xo, game_y, nBuffer);
free(nBuffer);
}
if (games[x].title_id)
DrawString(800 - (MENU_ICON_OFF * 3) - xo, game_y, games[x].title_id);
if (games[x].version)
DrawString(800 - (MENU_ICON_OFF * 1) - xo, game_y, games[x].version);
}
if (x == selIndex)
{
int c;
for (c = 0; c < 848; c++)
DrawTexture(menu_textures[mark_line_png_index], c, game_y, 0, menu_textures[mark_line_png_index].texture.width, menu_textures[mark_line_png_index].texture.height, 0xFFFFFF00 | alpha);
DrawTextureCenteredX(menu_textures[mark_arrow_png_index], MENU_ICON_OFF - 20, game_y, 0, (2 * y_inc) / 3, y_inc + 2, 0xFFFFFF00 | alpha);
}
game_y += y_inc;
}
DrawScrollBar(selIndex, glen, y_inc, 800, alpha);
}
示例11: DrawTexture
void UUTBetrayalScoreboard::DrawDaggers(AUTBetrayalPlayerState* PRI, float RenderDelta, float XOffset, float YOffset)
{
float BarOpacity = 0.75f;
float DaggerAspect = DaggerTexCoords.VL == 0.0 ? 0.0 : DaggerTexCoords.UL / DaggerTexCoords.VL;
if (PRI->BetrayalCount >= 100)
{
// draw simple format "x NUM"
DrawTexture(UT3GHudTexture, XOffset, YOffset, 32 * DaggerAspect, 32, DaggerTexCoords.U, DaggerTexCoords.V, DaggerTexCoords.UL, DaggerTexCoords.VL, BarOpacity, FLinearColor::White);
XOffset += 32 * DaggerAspect + (DaggerSpacing * RenderScale);
FText DaggerString = FText::Format(NSLOCTEXT("UTBetrayalScoreboard", "DaggersShortString", "x {0}"), FText::AsNumber(PRI->BetrayalCount));
DrawText(DaggerString, XOffset, YOffset + ColumnY, UTHUDOwner->SmallFont, 1.0f, 1.0f, FLinearColor::Gray, ETextHorzPos::Left, ETextVertPos::Center);
}
else
{
int32 NumGoldDaggers = PRI->BetrayalCount / 5;
int32 NumSilverDaggers = PRI->BetrayalCount % 5;
//Start drawing the daggers
for (int32 i = 0; i < NumGoldDaggers; i++)
{
DrawTexture(UT3GHudTexture, XOffset, YOffset, 32 * DaggerAspect, 32, DaggerTexCoords.U, DaggerTexCoords.V, DaggerTexCoords.UL, DaggerTexCoords.VL, BarOpacity, GoldLinearColor);
//Don't bump for the last gold dagger drawn
if (i<NumGoldDaggers - 1)
{
XOffset += (DaggerSpacing * RenderScale);
}
}
//Add spacing between gold/silver daggers
if (NumGoldDaggers > 0)
{
XOffset += (SilverDaggerOffset * RenderScale);
}
for (int32 i = 0; i < NumSilverDaggers; i++)
{
DrawTexture(UT3GHudTexture, XOffset, YOffset, 32 * DaggerAspect, 32, DaggerTexCoords.U, DaggerTexCoords.V, DaggerTexCoords.UL, DaggerTexCoords.VL, BarOpacity, SilverLinearColor);
XOffset += (DaggerSpacing * RenderScale);
}
}
}
示例12: main
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle");
const char textLine1[] = "Lena image is a standard test image which has been in use since 1973.";
const char textLine2[] = "It comprises 512x512 pixels, and it is probably the most widely used";
const char textLine3[] = "test image for all sorts of image processing algorithms.";
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/lena.png"); // Texture loading
Rectangle eyesRec = { 225, 240, 155, 50 }; // Part of the texture to draw
Vector2 position = { 369, 241 };
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("LENA", 220, 100, 20, PINK);
DrawTexture(texture, screenWidth/2 - 256, 0, Fade(WHITE, 0.1f)); // Draw background image
DrawTextureRec(texture, eyesRec, position, WHITE); // Draw eyes part of image
DrawText(textLine1, 220, 140, 10, DARKGRAY);
DrawText(textLine2, 220, 160, 10, DARKGRAY);
DrawText(textLine3, 220, 180, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
示例13: DrawTexture
void CFrameBufferObject::DrawTexture( CDrawContext * pDrawContext ) {
CMatrix< float > mat;
mat.Identity();
mat.Translate( 0.0f, m_Height, 0.0f );
DrawTexture( pDrawContext, &mat );
}
示例14: DrawAisle01Screen
// Gameplay Screen Draw logic
void DrawAisle01Screen(void)
{
DrawTexture(background, -scroll, 0, WHITE);
// Draw monsters
DrawMonster(lamp, scroll);
DrawMonster(picture, scroll);
// Draw door
Vector2 doorScrollPos = { doorCenter.position.x - scroll, doorCenter.position.y };
if (doorCenter.selected) DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, GREEN);
else DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, WHITE);
doorScrollPos = (Vector2){ doorLeft.position.x - scroll, doorLeft.position.y };
if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, GREEN);
else DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, WHITE);
doorScrollPos = (Vector2){ doorRight.position.x - scroll, doorRight.position.y };
if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, GREEN);
else DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(picture.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
示例15: DrawTexture
void nGraphics::DrawTexture(IDirect3DTexture9* texture,const nPoint& point,const nColor& color)
{
// Don't draw if fully transparent
if(color.a <= 0.0f)
return;
D3DSURFACE_DESC desc;
texture->GetLevelDesc(0,&desc);
DrawTexture(texture,nRect(point.x,point.y,point.x+desc.Width,point.y+desc.Height),color);
}