Пример #1
1
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());
}
Пример #2
0
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);
	}
}
Пример #3
0
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];
    }
}
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;
}
Пример #5
0
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);
	}
}
Пример #6
0
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;
}
Пример #7
0
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;
}
Пример #8
0
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);
}
Пример #9
0
//
// 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);
}
Пример #10
0
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);
}
Пример #11
0
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);
}
Пример #12
0
 void Driver_p::render()
 {
     SDL_RenderClear(rend_);
     SDL_UpdateTexture(screenTex_, nullptr, screenSurface_->pixels, screenSurface_->pitch);
     SDL_RenderCopy(rend_, screenTex_, nullptr, nullptr);
     SDL_RenderPresent(rend_);
 }
Пример #13
0
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);
}
Пример #14
0
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);
}
Пример #15
0
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);
}
Пример #16
0
internal void 
render_all(SDL_Renderer *renderer, 
          SDL_Texture *screen, 
          PT_Console *console) 
{
    PT_ConsoleClear(console);

    // Render the map
    for (u32 y = 0; y < MAP_HEIGHT; y++) {
        for (u32 x = 0; x < MAP_WIDTH; x++) {
            if (map[x][y].blockSight) {
                PT_ConsolePutCharAt(console, '#', x, y, COLOR_DARK_WALL, 0x000000ff);
            } else {
                PT_ConsolePutCharAt(console, '.', x, y, COLOR_DARK_FLOOR, 0x000000ff);
            }
        }
    }

    object_list_item *item = gameObjects.first;
    while (item != NULL) {
        object_draw(console, item->object);
        item = item->next;
    }

    SDL_UpdateTexture(screen, NULL, console->pixels, console->width * sizeof(u32));
    SDL_RenderClear(renderer);
    SDL_RenderCopy(renderer, screen, NULL, NULL);
    SDL_RenderPresent(renderer);
}
Пример #17
0
void gp2x_video_flip()
{
#if 0
static int nFrame;
if ( ( ++nFrame % 2 ) == 0 ) return;
#endif
	if (displayRect.x)
	{
		SDL_Rect blank;
		blank.x = 0;
		blank.y = 0;
		blank.w = displayRect.x;
		blank.h = window_height;

		SDL_RenderFillRect(renderer, &blank);
		blank.x = (window_width - displayRect.x - 1);
		SDL_RenderFillRect(renderer, &blank);
	}
	else if (displayRect.y)
	{
		SDL_Rect blank;
		blank.x = 0;
		blank.y = 0;
		blank.w = window_width;
		blank.h = displayRect.y;

		SDL_RenderFillRect(renderer, &blank);
		blank.y = (window_height - displayRect.y - 1);
		SDL_RenderFillRect(renderer, &blank);
	}

	SDL_UpdateTexture(texture, NULL, gp2x_screen32, surface_width*4);
	SDL_RenderCopy(renderer, texture, NULL, &displayRect);
	SDL_RenderPresent(renderer);
}
Пример #18
0
void Screen::screenUpdate() {
	SDL_UpdateTexture(m_texture, NULL, m_buffer, SCREEN_WIDTH * sizeof(Uint32));
	SDL_RenderClear(m_renderer);
	SDL_RenderCopy(m_renderer, m_texture, NULL, NULL);
	SDL_RenderPresent(m_renderer);

}
Пример #19
0
SDL_Texture *create_chequered(SDL_Renderer *renderer)
{
  SDL_RendererInfo ri;
  SDL_GetRendererInfo(renderer, &ri);
  int width = 512;
  int height = 512;
  if(ri.max_texture_width != 0 && ri.max_texture_width < width) {
    width = ri.max_texture_width;
  }
  if(ri.max_texture_height != 0 && ri.max_texture_height < height) {
    height = ri.max_texture_height;
  }
  const int box_size = 16;
  /* Create a chequered texture */
  const unsigned char l = 196;
  const unsigned char d = 96;

  size_t pixels_len = 3 * width * height;
  unsigned char *pixels = malloc(pixels_len);
  for(int y = 0; y < height; y++) {
    for(int x = 0; x < width; x += box_size) {
      unsigned char color = l;
      if(((x/box_size) % 2 == 0) ^ ((y/box_size) % 2 == 0)) {
        color = d;
      }
      memset(pixels + 3 * x + 3 * width * y, color, 3 * box_size);
    }
  }
  SDL_Texture *ret = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB24,
    SDL_TEXTUREACCESS_STATIC,
    width, height);
  SDL_UpdateTexture(ret, NULL, pixels, 3 * width);
  free(pixels);
  return ret;
}
Пример #20
0
void
IO_Swap (void)
{
	SDL_UpdateTexture (sdl_tex, NULL, video.buf, video.w * video.bytes_pp);
	SDL_RenderCopy (sdl_render, sdl_tex, NULL, NULL);
	SDL_RenderPresent (sdl_render);
}
Пример #21
0
/**
 * \brief Creates a hardware texture from the software surface.
 *
 * Also converts the software surface to a preferred format if necessary.
 */
void Surface::create_texture_from_surface() {

  SDL_Renderer* main_renderer = Video::get_renderer();
  if (main_renderer != nullptr) {

    Debug::check_assertion(internal_surface != nullptr,
        "Missing software surface to create texture from");

    // Create the texture.
    internal_texture = SDL_Texture_UniquePtr(
        SDL_CreateTexture(
            main_renderer,
            Video::get_pixel_format()->format,
            SDL_TEXTUREACCESS_STATIC,
            internal_surface->w,
            internal_surface->h
        )
    );
    SDL_SetTextureBlendMode(internal_texture.get(), get_sdl_blend_mode());

    // Copy the pixels of the software surface to the GPU texture.
    SDL_UpdateTexture(internal_texture.get(), nullptr, internal_surface->pixels, internal_surface->pitch);
    SDL_GetSurfaceAlphaMod(internal_surface.get(), &opacity);
  }
}
Пример #22
0
void oledRefresh(void) {
	/* Draw triangle in upper right corner */
	oledInvertDebugLink();

	const uint8_t *buffer = oledGetBuffer();

	static uint32_t data[OLED_HEIGHT][OLED_WIDTH];

	for (size_t i = 0; i < OLED_BUFSIZE; i++) {
		int x = (OLED_BUFSIZE - 1 - i) % OLED_WIDTH;
		int y = (OLED_BUFSIZE - 1 - i) / OLED_WIDTH * 8 + 7;

		for (uint8_t shift = 0; shift < 8; shift++, y--) {
			bool set = (buffer[i] >> shift) & 1;
			data[y][x] = set ? 0xFFFFFFFF : 0xFF000000;
		}
	}

	SDL_UpdateTexture(texture, NULL, data, OLED_WIDTH * sizeof(uint32_t));
	SDL_RenderCopy(renderer, texture, NULL, NULL);
	SDL_RenderPresent(renderer);

	/* Return it back */
	oledInvertDebugLink();
}
Пример #23
0
void screen_swap(int indicate_rasterpos)
{
  SDL_Rect dst,src;
  
  if(disable) return;

    if(debugger) {
      display_swap_screen();
    }
    SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch);
    if(crop_screen) {
      src.x = mon.crop_offset_x;
      src.y = mon.crop_offset_y;
      src.w = mon.crop_width;
      src.h = mon.crop_height;
      SDL_RenderCopy(renderer, texture, &src, NULL);
    } else {
      SDL_RenderCopy(renderer, texture, NULL, NULL);
    }
    if(indicate_rasterpos) {
      int rasterpos = screen_get_vsync();
      dst.x = 2*(rasterpos%512)-8;
      dst.y = 2*(rasterpos/512);
      dst.w = 8;
      dst.h = 2;
      SDL_RenderCopy(renderer, rasterpos_indicator[rasterpos_indicator_cnt&1], NULL, &dst);
      rasterpos_indicator_cnt++;
    }
    SDL_RenderPresent(renderer);
}
Пример #24
0
void CVideo::flip()
{
	SDL_UpdateTexture(frameTexture, NULL, frameBuffer->pixels, frameBuffer->w * sizeof (Uint32));
	SDL_RenderClear(renderer);
	SDL_RenderCopy(renderer, frameTexture, NULL, NULL);
	SDL_RenderPresent(renderer);
}
Пример #25
0
void clear_render_target() {
    // Update target with black pixels
    int size = NATIVE_W * state.scale_factor * NATIVE_H * state.scale_factor * 4;
    char *pixels = calloc(1, size);
    SDL_UpdateTexture(state.target, NULL, pixels, NATIVE_W * state.scale_factor * 4);
    free(pixels);
}
Пример #26
0
bool PicTryMakeTex(Pic *p)
{
	SDL_DestroyTexture(p->Tex);
	p->Tex = TextureCreate(
		gGraphicsDevice.gameWindow.renderer, SDL_TEXTUREACCESS_STATIC,
		p->size, SDL_BLENDMODE_NONE, 255);
	if (p->Tex == NULL)
	{
		LOG(LM_GFX, LL_ERROR, "cannot create texture: %s", SDL_GetError());
		return false;
	}
	if (SDL_UpdateTexture(
		p->Tex, NULL, p->Data, p->size.x * sizeof(Uint32)) != 0)
	{
		LOG(LM_GFX, LL_ERROR, "cannot update texture: %s", SDL_GetError());
		return false;
	}
	// Check for alpha pixels - if none we can get away with no blending
	bool hasAlpha = false;
	for (int i = 0; i < p->size.x * p->size.y; i++)
	{
		const Uint32 pixel = p->Data[i];
		color_t c;
		SDL_GetRGBA(pixel, gGraphicsDevice.Format, &c.r, &c.g, &c.b, &c.a);
		hasAlpha = hasAlpha || c.a < 255;
	}
	if (hasAlpha && SDL_SetTextureBlendMode(p->Tex, SDL_BLENDMODE_BLEND) != 0)
	{
		LOG(LM_GFX, LL_ERROR, "cannot set texture blend mode: %s",
			SDL_GetError());
		return false;
	}
	return true;
}
Пример #27
0
/**
 * \brief Creates a hardware texture from the software surface.
 *
 * Also converts the software surface to a preferred format if necessary.
 */
void Surface::create_texture_from_surface() {

  SDL_Renderer* main_renderer = Video::get_renderer();
  if (main_renderer != NULL) {

    Debug::check_assertion(internal_surface != NULL,
        "Missing software surface to create texture from");

    // Make sure the software surface has the same format as the texture.
    // This is because SDL_UpdateTexture does not have a format parameter
    // for performance reasons.
    convert_software_surface();

    // Create the texture.
    internal_texture = SDL_CreateTexture(
        main_renderer,
        Video::get_pixel_format()->format,
        SDL_TEXTUREACCESS_STATIC,
        internal_surface->w,
        internal_surface->h
    );
    SDL_SetTextureBlendMode(internal_texture, SDL_BLENDMODE_BLEND);

    // Copy the pixels of the software surface to the GPU texture.
    SDL_UpdateTexture(internal_texture, NULL, internal_surface->pixels, internal_surface->pitch);
    SDL_GetSurfaceAlphaMod(internal_surface, &internal_opacity);
  }
}
Пример #28
0
void CSDL_Ext::update(SDL_Surface * what)
{
	if(!what)
		return;
	if(0 !=SDL_UpdateTexture(screenTexture, nullptr, what->pixels, what->pitch))
		logGlobal->errorStream() << __FUNCTION__ << "SDL_UpdateTexture " << SDL_GetError();
}
Пример #29
0
void sdl_thread() {
	for (;;) {

		// Wait for the emulation thread to signal that a frame has completed

		SDL_LockMutex(frame_lock);
		ready_to_draw_new_frame = true;
		while (!frame_available && !pending_sdl_thread_exit)
			SDL_CondWait(frame_available_cond, frame_lock);
		if (pending_sdl_thread_exit) {
			SDL_UnlockMutex(frame_lock);
			return;
		}
		frame_available = ready_to_draw_new_frame = false;
		SDL_UnlockMutex(frame_lock);

		// Process events and calculate controller input state (which might
		// need left+right/up+down elimination)

		process_events();

		// Draw the new frame

		fail_if(SDL_UpdateTexture(screen_tex, 0, front_buffer, 256*sizeof(Uint32)),
				"failed to update screen texture: %s", SDL_GetError());
		fail_if(SDL_RenderCopy(renderer, screen_tex, 0, 0),
				"failed to copy rendered frame to render target: %s", SDL_GetError());
		SDL_RenderPresent(renderer);
	}
}
Пример #30
0
void PixelDrawer::Update()
{
	SDL_UpdateTexture(texture, NULL, pixelData, WindowWidth*sizeof(Uint32));
	SDL_RenderClear(renderer);
	SDL_RenderCopy(renderer, texture, NULL, NULL);
	SDL_RenderPresent(renderer);
}