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; };
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(); }
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()); } } } }
void UIDirect3D9Window::DrawImage(UIEffect *Effect, QRectF *Dest, bool &PositionChanged, UIImage *Image) { if (!Image) return; if (Image->GetState() == UIImage::ImageReleasedFromGPU) { LOG(VB_GENERAL, LOG_INFO, QString("Image '%1' cache hit").arg(Image->GetName())); Image->SetState(UIImage::ImageNull); } if (Image->GetState() == UIImage::ImageLoading) return; if (Image->GetState() == UIImage::ImageNull) { LoadImageFromFile(Image); return; } if (!Dest) return; PositionChanged |= Image->IsShared(); D3D9Texture *texture = AllocateTexture(Image); if (texture) DrawTexture(texture, Dest, Image->GetSizeF(), PositionChanged); }
// 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(); }
/* * 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; } }
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); } }
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; }
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; }
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); }
/* * 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); }
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); } } }
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; }
void CFrameBufferObject::DrawTexture( CDrawContext * pDrawContext ) { CMatrix< float > mat; mat.Identity(); mat.Translate( 0.0f, m_Height, 0.0f ); DrawTexture( pDrawContext, &mat ); }
// 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! }
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); }
void Sprite::Draw() { glColor4f(drawColor[0], drawColor[1], drawColor[2], drawColor[3]); if(texture != 0) { // Bind the texture glBindTexture(GL_TEXTURE_2D, texture); DrawTexture(); } }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib test - DDS texture loading and drawing"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) //Texture2D texture = LoadTexture("resources/raylib_logo.dds"); // Texture loading //Texture2D texture = LoadTexture("resources/raylib_logo_uncompressed.dds"); // Texture loading Image image = LoadImage("resources/raylib_logo_uncompressed.dds"); Texture2D texture = CreateTexture(image, false); // NOTE: With OpenGL 3.3 mipmaps generation works great SetTargetFPS(60); //--------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- // TODO: Update your variables here //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); DrawText("this IS a texture!", 360, 370, 10, GRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- //UnloadTexture(texture); // Texture unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
void golly_render::pixblit(int x, int y, int w, int h, char* pmdata, int pmscale) { // is Tom's hashdraw code doing unnecessary work??? if (x >= currwd || y >= currht) return; if (x + w <= 0 || y + h <= 0) return; // stride is the horizontal pixel width of the image data int stride = w/pmscale; // clip data outside viewport if (pmscale > 1) { // pmdata contains 1 byte per `pmscale' pixels, so we must be careful // and adjust x, y, w and h by multiples of `pmscale' only if (x < 0) { int dx = -x/pmscale*pmscale; pmdata += dx/pmscale; w -= dx; x += dx; } if (y < 0) { int dy = -y/pmscale*pmscale; pmdata += dy/pmscale*stride; h -= dy; y += dy; } if (x + w >= currwd + pmscale) w = (currwd - x + pmscale - 1)/pmscale*pmscale; if (y + h >= currht + pmscale) h = (currht - y + pmscale - 1)/pmscale*pmscale; } int numstates = currlayer->algo->NumCellStates(); if (pmscale == 1) { // draw rgb pixel data at scale 1:1 if (drawing_paste || numstates == 2) { // we can't use DrawTexture to draw paste image because glTexImage2D clobbers // any background pattern, so we use DrawPoints which is usually faster than // DrawTexture in a sparsely populated universe with only 2 states (eg. Life) DrawPoints((unsigned char*) pmdata, x, y, w, h); } else { DrawTexture((unsigned char*) pmdata, x, y, w, h); } } else if (showicons && pmscale > 4 && icontextures) { // draw icons at scales 1:8 or above DrawIcons((unsigned char*) pmdata, x, y, w/pmscale, h/pmscale, pmscale, stride); } else { // draw magnified cells, assuming pmdata contains (w/pmscale)*(h/pmscale) bytes // where each byte contains a cell state if (numstates == 2) { DrawMagnifiedTwoStateCells((unsigned char*) pmdata, x, y, w/pmscale, h/pmscale, pmscale, stride); } else { DrawMagnifiedCells((unsigned char*) pmdata, x, y, w/pmscale, h/pmscale, pmscale, stride, numstates); } } }
/*********************************************************************************** Function Name : glDrawTexfOES Inputs : Outputs : Returns : Description : ************************************************************************************/ GL_API_EXT void GL_APIENTRY glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) { __GLES1_GET_CONTEXT(); PVR_DPF((PVR_DBG_CALLTRACE,"glDrawTexfOES")); GLES1_TIME_START(GLES1_TIMES_glDrawTexfOES); DrawTexture(gc, x, y, z, width, height); GLES1_TIME_STOP(GLES1_TIMES_glDrawTexfOES); }
/*********************************************************************************** Function Name : glDrawTexfvOES Inputs : Outputs : Returns : Description : ************************************************************************************/ GL_API_EXT void GL_APIENTRY glDrawTexfvOES(const GLfloat *coords) { __GLES1_GET_CONTEXT(); PVR_DPF((PVR_DBG_CALLTRACE,"glDrawTexfvOES")); GLES1_TIME_START(GLES1_TIMES_glDrawTexfvOES); DrawTexture(gc, coords[0], coords[1], coords[2], coords[3], coords[4]); GLES1_TIME_STOP(GLES1_TIMES_glDrawTexfvOES); }
/*********************************************************************************** Function Name : glDrawTexiOES Inputs : Outputs : Returns : Description : ************************************************************************************/ GL_API_EXT void GL_APIENTRY glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) { __GLES1_GET_CONTEXT(); PVR_DPF((PVR_DBG_CALLTRACE,"glDrawTexiOES")); GLES1_TIME_START(GLES1_TIMES_glDrawTexiOES); DrawTexture(gc, (GLfloat)x, (GLfloat)y, (GLfloat)z, (GLfloat)width, (GLfloat)height); GLES1_TIME_STOP(GLES1_TIMES_glDrawTexiOES); }
void Draw_CheatsMenu_Options(void) { int c = 0, w = 0, h = 0; //------------ Backgrounds Draw_CheatsMenu_Selection(menu_old_sel[5], 0xD0D0D0FF); DrawTexture(menu_textures[edit_shadow_png_index], MENU_SPLIT_OFF - (menu_textures[edit_shadow_png_index].texture.width * 1) + 1, -marginVertical, 0, menu_textures[edit_shadow_png_index].texture.width, 512 + (marginVertical * 2), 0x000000FF); DrawHeader(menu_textures[header_ico_opt_png_index], MENU_SPLIT_OFF, "Cheat Option", selected_centry.name, 0x000000ff, 0xffffffff, 1); DrawOptions(selected_centry.options[option_index], 0xFF, 20, menu_sel); DrawScrollBar(menu_sel, selected_centry.options[option_index].size, 20, 800, 0xFF); }
/** * Render a single line. Do not use for formatted text! * Authors: C-Junkie, GreatEmerald */ void DrawTextLine(char* text, SizeF location) { GLuint texture; Size TextureSize; texture = TextToTexture(Fonts[Font_Message], text); TTF_SizeText(Fonts[Font_Message], text, &(TextureSize.X), &(TextureSize.Y)); DrawTexture(texture, TextureSize, AbsoluteTextureSize(TextureSize), location, 1.0); /* Clean up */ glDeleteTextures(1, &texture); }
Title::Title( Sequence* ptr ) : Mode( ptr ) { DrawFps = dynamic_cast< DxFont* >( FindObjectBox( "MS_UI_Gothic_16" ) ); title = dynamic_cast< DxFont* >( FindObjectBox( "MS_MINCHO_52" ) ); column = dynamic_cast< DxFont* >( FindObjectBox( "MS_UI_Gothic_28" ) ); column_italic = dynamic_cast< DxFont* >( FindObjectBox( "HGS_GYOSYOTAI_32_Italic" ) ); Cursor = _NEW DrawTexture( dynamic_cast< Texture* >( FindObjectBox( "Cursor" ) ) ); Cursor->SetSpriteRect( 0, 0, 24, 24 ); Count = 0; frame = 0; cursorpos = 0; }
void Draw_CheatsMenu_View(void) { int c = 0, w = 0, h = 0; //------------ Backgrounds Draw_CheatsMenu_Selection(menu_old_sel[5], 0xD0D0D0FF); DrawTexture(menu_textures[edit_shadow_png_index], MENU_SPLIT_OFF - (menu_textures[edit_shadow_png_index].texture.width * 1) + 1, -marginVertical, 0, menu_textures[edit_shadow_png_index].texture.width, 512 + (marginVertical * 2), 0x000000FF); DrawHeader(menu_textures[header_ico_opt_png_index], MENU_SPLIT_OFF, "Cheat View", selected_centry.name, 0x000000ff, 0xffffffff, 1); int nlines = DrawCodes(selected_centry, 0xFF, 20, MENU_SPLIT_OFF, menu_sel); //DrawScrollBar2(menu_sel, nlines, 18, 700, 0xFF); DrawScrollBar(menu_sel, nlines, 20, 800, 0xFF); }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) Image image = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM) Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM //--------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- // TODO: Update your variables here //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadTexture(texture); // Texture unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
// Mission Screen Draw logic void DrawMissionScreen(void) { // Draw MISSION screen here! DrawTexture(texBackground, 0,0, WHITE); DrawTexturePro(texBackline, sourceRecBackLine, destRecBackLine, (Vector2){0,0},0, Fade(WHITE, fadeBackLine)); if (writeNumber) DrawTextEx(fontMission, FormatText("Filtración #%02i ", currentMission + 1), numberPosition, missionSize + 10, 0, numberColor); DrawTextEx(fontMission, TextSubtext(missions[currentMission].brief, 0, missionLenght), missionPosition, missionSize, 0, missionColor); if (writeKeyword && blinkKeyWord) DrawTextEx(fontMission, FormatText("Keyword: %s", missions[currentMission].key), keywordPosition, missionSize + 10, 0, keywordColor); if (showButton) { if (!writeEnd) DrawButton("saltar"); else DrawButton("codificar"); } }
void FWApplication::DrawText(const std::string & message, uint32_t offsetX, uint32_t offsetY) { SDL_Color color = { mColor.r, mColor.g, mColor.b, mColor.a }; //SDL_Color bgColor = { mTextBackgroundColor.r, mTextBackgroundColor.g, mTextBackgroundColor.b, mTextBackgroundColor.a }; SDL_Surface * surface = TTF_RenderText_Blended(mFont, message.c_str(), color); if (surface) { SDL_Texture * texture = SDL_CreateTextureFromSurface(mRenderer, surface); if (texture) { DrawTexture(texture, offsetX, offsetY, surface->w, surface->h); } SDL_FreeSurface(surface); SDL_DestroyTexture(texture); } }
//Draws the specified texture //param:texture->the index given from load texture //param:color->the tint to apply to the texture //param:sourceRect->the rectangle to pull a smaller image from the texture with. NULL for the whole texture //param:position->the point to draw to //param:angle->the rotation to apply //param:scale->the scale to apply. This is uniform across x and y //param:flip->SDL_RendererFlip::None/FlipHorizontal/FlipVertical. If you want both Flip Horizontal and Flip Vertical, //use the bitwise operator '|' //param:origin->Origin to rotate around. If NULL, uses center of destRect created by position and scale //param:layerDepth->The depth to draw the image at //returns -1 on error, 0 for success int SpriteBatch::DrawTexture(Uint32 texture, SDL_Color color, const SDL_Rect* sourceRect, const SDL_Point* position, float angle, float scale, SDL_RendererFlip flip, const SDL_Point* origin, float layerDepth) { //Check if spritebatch.begin has been called if(!begun) { std::cout<<"Begin must be called before attempting to draw"<<std::endl; return -1; } ///create a temporary point SDL_Point pos = SDL_Point(); //if position is null, set our temp to 0,0 if(!position) { pos = CreatePoint(0, 0); } else { //otherwise set with position pos = CreatePoint(position->x, position->y); } SDL_Rect destRect = SDL_Rect(); //If we were given a source rectangle if(sourceRect) { //create a dest rectangle using position and source rectangle's dimensions destRect = CreateRect(pos.x, pos.y, (int)(sourceRect->w * scale), (int)(sourceRect->h * scale)); } else { int w = 0; int h = 0; //get the width and height SDL_QueryTexture(textureList[texture], NULL, NULL, &w, &h); //create a dest rect using position and the image dimensions destRect = CreateRect(pos.x, pos.y, (int)(w * scale), (int)(h * scale)); } //Call other DrawTexture to do the actual drawing return DrawTexture(texture, color, sourceRect, &destRect, angle, origin, flip, layerDepth); }