当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_UpdateTexture函数代码示例

本文整理汇总了C++中SDL_UpdateTexture函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_UpdateTexture函数的具体用法?C++ SDL_UpdateTexture怎么用?C++ SDL_UpdateTexture使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_UpdateTexture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ATLASSERT

void RenderWindow2D::Update()
{
   ATLASSERT(texture != nullptr);
   ATLASSERT(surface != nullptr);
   ATLASSERT(renderer != nullptr);

   if (scalerFunc != nullptr)
   {
      // scale then update
      unsigned int bufferType = surface->format->BitsPerPixel == 32 ? 888 : 565;

      scalerFunc(bufferType,
         scaleFactor,
         reinterpret_cast<Uint8*>(surface->pixels),
         unscaledSurfaceBuffer.data(),
         unscaledWidth, unscaledHeight);

      SDL_UpdateTexture(texture.get(), nullptr, surface->pixels, surface->pitch);
   }
   else
   {
      // just update from unscaled surface
      SDL_UpdateTexture(texture.get(), nullptr, unscaledSurfaceBuffer.data(), unscaledWidth * BitsPerPixel() / 8);
   }

   SDL_RenderClear(renderer.get());
   SDL_RenderCopy(renderer.get(), texture.get(), nullptr, nullptr);
   SDL_RenderPresent(renderer.get());
}
开发者ID:vividos,项目名称:OldStuff,代码行数:29,代码来源:RenderWindow2D.cpp

示例2: SDL_UpdateTexture

void ListBox::updateDisplay()
{
	// Clear the display texture. Otherwise, remnants of previous text might be left over.
	SDL_UpdateTexture(this->texture, nullptr, clearSurface->pixels, clearSurface->pitch);

	// Prepare the range of text boxes that will be displayed.
	const int totalElements = static_cast<int>(this->textBoxes.size());
	const int maxDisplayed = this->getMaxDisplayedCount();
	const int indexEnd = std::min(this->scrollIndex + maxDisplayed, totalElements);

	// Draw the relevant text boxes according to scroll index.
	for (int i = this->scrollIndex; i < indexEnd; ++i)
	{
		const SDL_Surface *surface = this->textBoxes.at(i)->getSurface();

		SDL_Rect rect;
		rect.x = 0;
		rect.y = (i - this->scrollIndex) * surface->h;
		rect.w = surface->w;
		rect.h = surface->h;

		// Update the texture's pixels at the correct height offset.
		SDL_UpdateTexture(this->texture, &rect, surface->pixels, surface->pitch);
	}
}
开发者ID:afritz1,项目名称:OpenTESArena,代码行数:25,代码来源:ListBox.cpp

示例3: colorSurface

void RenderManagerSDL::colorizeBlobs(int player)
{
    std::vector<DynamicColoredTexture> *handledBlob = 0;
    std::vector<DynamicColoredTexture> *handledBlobShadow = 0;
    int frame;

    if (player == LEFT_PLAYER)
    {
        handledBlob = &mLeftBlob;
        handledBlobShadow = &mLeftBlobShadow;
        frame = mLeftBlobAnimationState;
    }
    if (player == RIGHT_PLAYER)
    {
        handledBlob = &mRightBlob;
        handledBlobShadow = &mRightBlobShadow;
        frame = mRightBlobAnimationState;
    }

    if( (*handledBlob)[frame].mColor != mBlobColor[player])
    {
        SDL_Surface* tempSurface = colorSurface(mStandardBlob[frame], mBlobColor[player]);
        SDL_UpdateTexture((*handledBlob)[frame].mSDLsf, NULL, tempSurface->pixels, tempSurface->pitch);
        SDL_FreeSurface(tempSurface);

        SDL_Surface* tempSurface2 = colorSurface(mStandardBlobShadow[frame], mBlobColor[player]);
        SDL_UpdateTexture((*handledBlobShadow)[frame].mSDLsf, NULL, tempSurface2->pixels, tempSurface2->pitch);
        SDL_FreeSurface(tempSurface2);

        (*handledBlob)[frame].mColor = mBlobColor[player];
    }
}
开发者ID:EliasOenal,项目名称:blobby,代码行数:32,代码来源:RenderManagerSDL.cpp

示例4: PL_Texture_BlitSurface

int PL_Texture_BlitSurface(int textureRefID, SDL_Surface *surface, const SDL_Rect *rect) {
    TextureRef *textureref = (TextureRef*)PL_Handle_GetData(textureRefID, DXHANDLE_TEXTURE);
    SDL_Texture *texture;
    if (textureref == NULL || textureref->texture == NULL) {
        return -1;
    }
    
    texture = textureref->texture;
    
    /* Convert to target format if different. */
    if (textureref->format != surface->format->format) {
        SDL_Surface *tempSurface = SDL_ConvertSurfaceFormat(surface, textureref->format, 0);
        if (SDL_MUSTLOCK(tempSurface)) {
            SDL_LockSurface(tempSurface);
            SDL_UpdateTexture(texture, rect, tempSurface->pixels, tempSurface->pitch);
            SDL_UnlockSurface(tempSurface);
        } else {
            SDL_UpdateTexture(texture, rect, tempSurface->pixels, tempSurface->pitch);
        }
        SDL_FreeSurface(tempSurface);
    } else {
        if (SDL_MUSTLOCK(surface)) {
            SDL_LockSurface(surface);
            SDL_UpdateTexture(texture, rect, surface->pixels, surface->pitch);
            SDL_UnlockSurface(surface);
        } else {
            SDL_UpdateTexture(texture, rect, surface->pixels, surface->pitch);
        }
    }
    
    return 0;
}
开发者ID:marron-akanishi,项目名称:DxPortLib,代码行数:32,代码来源:SDL2Render_Texture.c

示例5: bmx_SDL_UpdateTexture

int bmx_SDL_UpdateTexture(SDL_Texture * texture, void * pixels, int pitch, int x, int y, int w, int h) {
	if (x < 0 || y < 0 || w < 0 || h < 0) {
		return SDL_UpdateTexture(texture, 0, pixels, pitch);
	} else {
		SDL_Rect r = { x, y, w, h };
		return SDL_UpdateTexture(texture, &r, pixels, pitch);
	}
}
开发者ID:GWRon,项目名称:sdl.mod,代码行数:8,代码来源:glue.c

示例6: malloc

struct overview *overview_init(int x, int y, int w, int h, struct track *tr, SDL_Renderer *renderer, struct twinterface *twinterface)
{
  struct overview *overview;
  overview = (struct overview *) malloc(sizeof(struct overview));
  overview->rect.x = x;
  overview->rect.y = y;
  overview->rect.w = w;
  overview->rect.h = h;
  overview->clicked = 0;
  overview->tr = &tracks[twinterface->current_deck];  
  overview->renderer = renderer;
  overview->twinterface = twinterface;
  
  /* SDL interprets each pixel as a 32-bit number, so our masks must depend
    on the endianness (byte order) of the machine */
  Uint32 rmask, gmask, bmask, amask;  
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
  rmask = 0xff000000;
  gmask = 0x00ff0000;
  bmask = 0x0000ff00;
  amask = 0x000000ff;
#else
  rmask = 0x000000ff;
  gmask = 0x0000ff00;
  bmask = 0x00ff0000;
  amask = 0xff000000;
#endif  
  overview->surface = SDL_CreateRGBSurface(0, w, h, 32,
                                   rmask, gmask, bmask, amask);
  overview->texture = SDL_CreateTexture(overview->renderer, SDL_PIXELFORMAT_ARGB8888, 
                    SDL_TEXTUREACCESS_STREAMING, w, h); 

  overview->playhead_surface = SDL_CreateRGBSurface(0, w, 1, 32,
                                   rmask, gmask, bmask, amask);
  overview->playhead_texture = SDL_CreateTexture(overview->renderer, SDL_PIXELFORMAT_ARGB8888, 
                    SDL_TEXTUREACCESS_STREAMING, w, 1);
                    
  SDL_FillRect(overview->playhead_surface, NULL, overview_palette(overview->playhead_surface, &needle_col));
  SDL_UpdateTexture(overview->playhead_texture, NULL, overview->playhead_surface->pixels, overview->playhead_surface->pitch);   

  //SDL_SetTextureBlendMode(overview->texture, SDL_BLENDMODE_BLEND);
  //SDL_SetTextureAlphaMod(overview->texture, 255);
                    
  overview_draw(overview);
  SDL_UpdateTexture(overview->texture, NULL, overview->surface->pixels, overview->surface->pitch);    
  
  printf("overview inited.\n");
  return overview;
}
开发者ID:cmeon,项目名称:touchwax,代码行数:49,代码来源:overview.c

示例7: hw_endframe

void hw_endframe(void)
{
    if (g_videoenable)
    {
        if (audiocounter < framecounter)
        {
            SDL_UpdateTexture(frame, NULL, framebuf, 320*4);

            SDL_RenderClear(renderer);
            SDL_RenderCopy(renderer, frame, NULL, NULL);
            SDL_RenderPresent(renderer);
            fpscounter += 1;

            while (audiocounter < framecounter)
                SDL_Delay(1);
        }

        if (fpsclock+1000 < SDL_GetTicks())
        {
            char title[256];
            sprintf(title, "Genemu - Sega Genesis Emulator - %d FPS", fpscounter);
            SDL_SetWindowTitle(screen, title);
            fpscounter = 0;
            fpsclock += 1000;
        }
    }

    framecounter += 1;
}
开发者ID:harlowja,项目名称:genemu,代码行数:29,代码来源:hw.c

示例8: DisplayFinishText

void DisplayFinishText(int ms, const char* text){
    
    TTF_Font* font = TTF_OpenFont("data/font.ttf", 70);
    
    int posX = g_GamePtr->GetScreen_W()/2;
    int posY = g_GamePtr->GetScreen_H()/2;
    
    
    SDL_Color color = {0x2b, 0xd7, 0xb7, 0};
    SDL_Color shade = {0xff, 0xff, 0xff, 0};
    
    SDL_Surface* text_image = TTF_RenderText_Solid(font, text, color);
    SDL_Surface* text_shade = TTF_RenderText_Solid(font, text, shade);
    
    Game::Draw(g_GamePtr->GetScreen(), text_shade, posX - text_shade->w/2 +2, posY - text_shade->h/2 +2);
    Game::Draw(g_GamePtr->GetScreen(), text_image, posX - text_image->w/2, posY - text_image->h/2);
    
    //SDL_Flip(g_GamePtr->GetScreen());
	SDL_RenderClear(g_GamePtr->m_pRenderer);
	SDL_UpdateTexture(g_GamePtr->m_pScreenTexture, NULL, g_GamePtr->GetScreen()->pixels, g_GamePtr->GetScreen()->pitch);
	SDL_RenderCopy(g_GamePtr->m_pRenderer, g_GamePtr->m_pScreenTexture, NULL, NULL);
	SDL_RenderPresent(g_GamePtr->m_pRenderer);
    
    int firstMeasure = SDL_GetTicks();
    while(SDL_GetTicks() - firstMeasure <= ms);
    
    SDL_FreeSurface(text_shade);
    SDL_FreeSurface(text_image);
    TTF_CloseFont(font);
}
开发者ID:ZHANITEST,项目名称:SDLProgramming,代码行数:30,代码来源:Game.cpp

示例9: UpdateGrab

//
// SDLVideoDriver::FinishUpdate
//
// Push the newest frame to the display.
//
void SDLVideoDriver::FinishUpdate()
{
   // haleyjd 10/08/05: from Chocolate DOOM:
   UpdateGrab(window);

   // Don't update the screen if the window isn't visible.
   // Not doing this breaks under Windows when we alt-tab away 
   // while fullscreen.   
   if(!(SDL_GetWindowFlags(window) & SDL_WINDOW_SHOWN))
      return;

   if(setpalette)
   {
      if(primary_surface)
         SDL_SetPaletteColors(primary_surface->format->palette, colors, 0, 256);

      setpalette = false;
   }

   // haleyjd 11/12/09: blit *after* palette set improves behavior.
   if(primary_surface)
   {
      // Don't bother checking for errors. It should just cancel itself in that case.
      SDL_BlitSurface(primary_surface, nullptr, rgba_surface, nullptr);
      SDL_UpdateTexture(sdltexture, nullptr, rgba_surface->pixels, rgba_surface->pitch);
      SDL_RenderCopy(renderer, sdltexture, nullptr, destrect);
   }

   // haleyjd 11/12/09: ALWAYS update. Causes problems with some video surface
   // types otherwise.
   SDL_RenderPresent(renderer);
}
开发者ID:Altazimuth,项目名称:eternity,代码行数:37,代码来源:i_sdlvideo.cpp

示例10: SDL_RenderClear

void SDLSingleton::DoRender()
{
    SDL_RenderClear(m_pRenderer);
    SDL_UpdateTexture(m_pGameTexture, NULL, m_pGameScreen->pixels, m_pGameScreen->pitch);
    SDL_Rect srcRect;
    SDL_Rect destRect;

    srcRect.x = 0;
    srcRect.y = 0;
    srcRect.w = destRect.w = 320;
    srcRect.h = destRect.h = 200;
    destRect.x = 0;
    destRect.y = 0;

    destRect.x = 0;
    destRect.y = 0;

    destRect.w = SDL_RATIO_X(destRect.w);
    destRect.h = SDL_RATIO_Y(destRect.h);

    SDL_SetTextureAlphaMod(m_pGameTexture, 255);
    SDL_RenderCopyEx(SDLSingleton::GetInstance()->GetRenderer(), m_pGameTexture, &srcRect, &destRect, 0, 0, SDL_FLIP_NONE);

    SDL_RenderPresent(m_pRenderer);
}
开发者ID:ZHANITEST,项目名称:SDLProgramming,代码行数:25,代码来源:SDLSingleton.cpp

示例11: SDLUpdateWindow

internal void SDLUpdateWindow(
        SDL_Window *Window, SDL_Renderer *Renderer,
        sdl_offscreen_buffer Buffer, void* vbuffer){
    SDL_UpdateTexture(Buffer.Texture, 0, vbuffer, Buffer.Pitch);
    SDL_RenderCopy(Renderer, Buffer.Texture, 0, 0);
    SDL_RenderPresent(Renderer);
}
开发者ID:deltragon,项目名称:hmpfunctional,代码行数:7,代码来源:sdl_handmade.cpp

示例12: SDL_RenderClear

 void Driver_p::render()
 {
     SDL_RenderClear(rend_);
     SDL_UpdateTexture(screenTex_, nullptr, screenSurface_->pixels, screenSurface_->pitch);
     SDL_RenderCopy(rend_, screenTex_, nullptr, nullptr);
     SDL_RenderPresent(rend_);
 }
开发者ID:No44,项目名称:gamebonk,代码行数:7,代码来源:Driver.cpp

示例13: RENDERER_Draw

void RENDERER_Draw(SdlRenderer *const rend)
{
	SDL_UpdateTexture(rend->texture, NULL, rend->gfx, rend->pitch );
	SDL_RenderCopy(rend->renderer, rend->texture, NULL, NULL);
	SDL_RenderPresent(rend->renderer);
	SDL_Delay(rend->fps);
}
开发者ID:dhustkoder,项目名称:chip8_ARM,代码行数:7,代码来源:sdl_renderer.c

示例14: render

void render() {
	/* FIXME: Docs says SDL_UpdateTexture() be slow */
	SDL_UpdateTexture(tex, NULL, bmp->data, bmp->w*4);
	SDL_RenderClear(ren);
	SDL_RenderCopy(ren, tex, NULL, NULL);
	SDL_RenderPresent(ren);
}
开发者ID:wernsey,项目名称:rengine,代码行数:7,代码来源:game.c

示例15: SDL_UpdateTexture

void GraphicsSDL::FlipScreen()
{
    SDL_UpdateTexture(sdl2_screen_as_texture, NULL, screen->pixels, screen->pitch);
    SDL_RenderClear(sdl2_renderer);
    SDL_RenderCopy(sdl2_renderer, sdl2_screen_as_texture, NULL, NULL);
    SDL_RenderPresent(sdl2_renderer);
}
开发者ID:Ronoh55,项目名称:supermariowar,代码行数:7,代码来源:gfxSDL.cpp


注:本文中的SDL_UpdateTexture函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。