void defense_render() { int i, x, y; for (i = 0; i < 4; i++) { //SDL_BlitScaled(defensesurf1, NULL, gScreen, &defense[i].rect); for (y = 0; y < 2; y++) { for (x = 0; x < 11; x++) { if (defense[i].state[x][y] == 1) { SDL_BlitScaled(defensesurf1, &defense[i].clip[x][y], gScreen, &defense[i].stretch[x][y]); } else if (defense[i].state[x][y] == 2) { SDL_BlitScaled(defensesurf2, &defense[i].clip[x][y], gScreen, &defense[i].stretch[x][y]); } else if (defense[i].state[x][y] == 3) { SDL_BlitScaled(defensesurf3, &defense[i].clip[x][y], gScreen, &defense[i].stretch[x][y]); } } } } }
void initBGTex() { SDL_Surface* temp = NULL; temp = SDL_LoadBMP("xzbackground.bmp"); SDL_Rect rdst; rdst.x = 0; rdst.y = 0; rdst.h = SCR_H / 2; rdst.w = SCR_W; SDL_BlitScaled(temp, NULL, gSurf, &rdst); SDL_FreeSurface(temp); temp = NULL; temp = SDL_LoadBMP("xybackground.bmp"); rdst.x = 0; rdst.y = SCR_H / 2; rdst.h = SCR_H / 2; rdst.w = SCR_W; SDL_BlitScaled(temp, NULL, gSurf, &rdst); SDL_FreeSurface(temp); gBGTex = SDL_CreateTextureFromSurface(gRend, gSurf); }
void enemy_render() { int x, y; for (y = 0; y < 5; y++) { for (x = 0; x < 11; x++) { if (enemy[x][y].alive) { if (SDL_GetTicks() % (enemy_animation_time*2) < enemy_animation_time) { SDL_BlitScaled(enemy[x][y].surf[0], NULL, gScreen, &enemy[x][y].rect); } else { SDL_BlitScaled(enemy[x][y].surf[1], NULL, gScreen, &enemy[x][y].rect); } } else if (SDL_GetTicks() - enemy[x][y].death_time < 300) { SDL_BlitScaled(enemyexplosionsurf, NULL, gScreen, &enemy[x][y].rect); } } } if (command.alive) { SDL_BlitScaled(command.surf[0], NULL, gScreen, &command.rect); } else if (SDL_GetTicks() - command.death_time < 300) { SDL_BlitScaled(command.surf[1], NULL, gScreen, &command.rect); } }
/* Horizontally centered */ void blitTextSurf(SDL_Surface *surf, int x, int y, int alignW, SDL_Surface *txtSurf, Justification just) { SDL_Rect dstRect; dstRect.x = drawOff.x; dstRect.y = drawOff.y + y - txtSurf->h / 2; dstRect.w = txtSurf->w; dstRect.h = txtSurf->h; switch (just) { case Left: dstRect.x += x; break; case Center: dstRect.x += x - (txtSurf->w - alignW) / 2; break; } if (txtSurf->w <= alignW) { SDL_BlitSurface(txtSurf, 0, surf, &dstRect); } else { dstRect.w = alignW; dstRect.x = x; SDL_BlitScaled(txtSurf, 0, surf, &dstRect); } }
void Screen::Refresh(Rect *RefRect) { Uint32 StartTime = SDL_GetTicks(); static SDL_mutex *mutex; if (mutex == NULL) mutex = SDL_CreateMutex(); //if (SDL_LockMutex(mutex) == 0) { int _w, _h; SDL_GetWindowSize(this->MainWnd, &_w, &_h); double Multi = (double)_w / this->width; SDL_Rect _rect, _r; _r.x = ((RefRect == NULL)? 0 : RefRect->x); _r.y = ((RefRect == NULL)? 0 : RefRect->y); _r.w = ((RefRect == NULL)? this->width : RefRect->w); _r.h = ((RefRect == NULL)? this->height : RefRect->h); _rect.x = _r.x * Multi; _rect.y = _r.y * Multi; _rect.w = _r.w * Multi; _rect.h = _r.h * Multi; SDL_BlitScaled(this->ScreenSurface, &_r, this->buffer, &_rect); Uint32 EndTime = SDL_GetTicks(); Uint32 MustDelay = (1000 / FPSNEED) - (EndTime - StartTime); if (MustDelay > 10) SDL_Delay(MustDelay); #if DEBUG_LAYER == 1 DrawDebugLayer(this->buffer, 1000.0f / (SDL_GetTicks() - StartTime)); #endif // DEBUG_LAYER SDL_UpdateWindowSurface(this->MainWnd); SDL_UnlockMutex(mutex); } }
void blitScaled(SDL_Surface *srcSfc, SDL_Rect &srGsRect, SDL_Surface *dstSfc, SDL_Rect &dstRect, filterOptionType filter) { assert(filter>=NONE && filter<=SCALE_4X); // First phase: Filter the surface (scaleX) SDL_Rect lSrGsRect = srGsRect; SDL_Rect lDstRect = dstRect; // Check for filter and reduce if the surface to be scaled is way too small while( filter>NONE ) { // Does it fit? if( dstSfc->w >= srcSfc->w*filter && dstSfc->h >= srcSfc->h*filter ) { break; } filter = (filterOptionType)((int)(filter)-1); } if( filter>NONE ) { SDL_LockSurface( srcSfc ); SDL_LockSurface( dstSfc ); scale( filter, dstSfc->pixels, dstSfc->pitch, srcSfc->pixels, srcSfc->pitch, dstSfc->format->BytesPerPixel, srcSfc->w, srcSfc->h ); SDL_UnlockSurface( dstSfc ); SDL_UnlockSurface( srcSfc ); lSrGsRect.w = lSrGsRect.w*filter; lSrGsRect.h = lSrGsRect.h*filter; } // Second phase: Scale it normally #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_BlitScaled( srcSfc, &lSrGsRect, dstSfc, &lDstRect ); #else scaleDynamic( srcSfc, lSrGsRect, dstSfc, lDstRect ); //scaleNormal(srcSfc, dstSfc, (Uint32)SCALE_4X ); #endif }
void GameEngine::gamedisplay( SDL_Window * window ) { ////clear screen SDL_FillRect ( screenSurface, &screenBuffer, 0x000000/*black*/); list<dood>::iterator it = actors.begin(); set_camera(); cur -> show(); //hero -> show(); while (it != actors.end()) { it->show(); it++; } batch.sort( Comparedepth ); while(!batch.empty()) { // printf( "body dest loc w = %d, h = %d, y =%d, x = %d\n", batch.front()->srcloc.w , batch.front()->srcloc.h , batch.front()->srcloc.y , batch.front()->srcloc.x); //printf( "body dest loc w = %d, h = %d, y =%d, x = %d\n", batch.front()->camloc.w , batch.front()->camloc.h , batch.front()->camloc.y , batch.front()->camloc.x); SDL_BlitSurface(batch.front()->src, &batch.front()->srcloc , screenSurface, &batch.front()->camloc); batch.pop_front(); } //SDL_Delay(1000); //SDL_BlitSurface(screenSurface, NULL, screen, NULL); SDL_BlitScaled( screenSurface, NULL, screen, NULL); SDL_UpdateWindowSurface( window ); }
static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_FRect * dstrect) { SDL_Surface *surface = SW_ActivateRenderer(renderer); SDL_Surface *src = (SDL_Surface *) texture->driverdata; SDL_Rect final_rect; if (!surface) { return -1; } if (renderer->viewport.x || renderer->viewport.y) { final_rect.x = (int)(renderer->viewport.x + dstrect->x); final_rect.y = (int)(renderer->viewport.y + dstrect->y); } else { final_rect.x = (int)dstrect->x; final_rect.y = (int)dstrect->y; } final_rect.w = (int)dstrect->w; final_rect.h = (int)dstrect->h; if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) { return SDL_BlitSurface(src, srcrect, surface, &final_rect); } else { return SDL_BlitScaled(src, srcrect, surface, &final_rect); } }
static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_FRect * dstrect) { SDL_Surface *surface = SW_ActivateRenderer(renderer); SDL_Surface *src = (SDL_Surface *) texture->driverdata; SDL_Rect final_rect; if (!surface) { return -1; } if (renderer->viewport.x || renderer->viewport.y) { final_rect.x = (int)(renderer->viewport.x + dstrect->x); final_rect.y = (int)(renderer->viewport.y + dstrect->y); } else { final_rect.x = (int)dstrect->x; final_rect.y = (int)dstrect->y; } final_rect.w = (int)dstrect->w; final_rect.h = (int)dstrect->h; if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) { return SDL_BlitSurface(src, srcrect, surface, &final_rect); } else { /* If scaling is ever done, permanently disable RLE (which doesn't support scaling) * to avoid potentially frequent RLE encoding/decoding. */ SDL_SetSurfaceRLE(surface, 0); return SDL_BlitScaled(src, srcrect, surface, &final_rect); } }
int main(int argc, char** args) { if (init()) { if (loadMedia()) { bool quit = false; SDL_Event e; SDL_Rect stretchRect; stretchRect.x = 0; stretchRect.y = 0; stretchRect.w = SCREEN_WIDTH; stretchRect.h = SCREEN_HEIGHT; SDL_BlitScaled(stretchedSurface, NULL, surface, &stretchRect); while (!quit) { while (SDL_PollEvent(&e) != 0) { if (e.type == SDL_QUIT) { quit = true; } SDL_UpdateWindowSurface(window); } } } } // Quit SDL close(); return 0; }
void FillRectBall(int x, int y, int w, int h) { rectBall = { x, y, w, h }; Uint32 grey = SDL_MapRGB(surfaceBall->format, 0, 0, 0); SDL_SetColorKey(surfaceBall, SDL_SRCCOLORKEY, grey); SDL_BlitScaled(surfaceBall, NULL, surfaceScreen, &rectBall); }
void ReinforcementPictures<T>::calculateFeatureVector(SDL_Surface* pic, whiteice::math::vertex<T>& f) const { f.resize(FEATURE_PICSIZE*FEATURE_PICSIZE*3); f.zero(); if(pic == NULL){ return; } SDL_Surface* scaled = NULL; scaled = SDL_CreateRGBSurface(0, FEATURE_PICSIZE, FEATURE_PICSIZE, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); if(scaled == NULL) return; SDL_Rect srcrect; if(pic->w < pic->h){ srcrect.w = pic->w; srcrect.x = 0; srcrect.h = pic->w; srcrect.y = (pic->h - pic->w)/2; } else{ srcrect.h = pic->h; srcrect.y = 0; srcrect.w = pic->h; srcrect.x = (pic->w - pic->h)/2; } if(SDL_BlitScaled(pic, &srcrect, scaled, NULL) != 0){ SDL_FreeSurface(scaled); return; } unsigned int index = 0; for(int j=0;j<scaled->h;j++){ for(int i=0;i<scaled->w;i++){ unsigned int pixel = ((unsigned int*)(((char*)scaled->pixels) + j*scaled->pitch))[i]; unsigned int r = (0x00FF0000 & pixel) >> 16; unsigned int g = (0x0000FF00 & pixel) >> 8; unsigned int b = (0x000000FF & pixel); f[index] = (double)r/255.0; index++; f[index] = (double)g/255.0; index++; f[index] = (double)b/255.0; index++; } } SDL_FreeSurface(scaled); return; // everything OK }
/** * Render the menu to the screen. * * @param[in,out] world A reference to the world structure containing entities to render. * @param[in,out] surface Surface player is being rendered to. * * @designer Jordan Marling * * @author Jordan Marling * @date March 12s, 2024 */ void render_menu_system(World *world, SDL_Surface *surface) { unsigned int entity; RenderPlayerComponent *renderPlayer; PositionComponent *position; TextFieldComponent *text; SDL_Rect menu_rect; for(entity = 0; entity < MAX_ENTITIES; entity++){ if (IN_THIS_COMPONENT(world->mask[entity], SYSTEM_MASK | COMPONENT_MENU_ITEM)) { position = &(world->position[entity]); renderPlayer = &(world->renderPlayer[entity]); menu_rect.x = position->x; menu_rect.y = position->y; menu_rect.w = renderPlayer->width; menu_rect.h = renderPlayer->height; if (IN_THIS_COMPONENT(world->mask[entity], COMPONENT_BUTTON)) { if (world->button[entity].hovered) { menu_rect.x -= 5; menu_rect.y -= 5; menu_rect.w += 10; menu_rect.h += 10; } } SDL_BlitScaled(renderPlayer->playerSurface, NULL, surface, &menu_rect); //check if a textbox. if (IN_THIS_COMPONENT(world->mask[entity], COMPONENT_TEXTFIELD)) { text = &(world->text[entity]); menu_rect.x += 10; menu_rect.y += 8; //TODO: Store the text in a component instead of creating it every frame. //Perhaps we should store it in the renderPlayer component and draw the //textbox if it has a text field component? SDL_BlitSurface(draw_text(text->text, MENU_FONT), NULL, surface, &menu_rect); if (text->focused) { menu_rect.x += get_text_width(text->text, MENU_FONT) + 1; SDL_BlitSurface(ibeam, NULL, surface, &menu_rect); } } } } }
SDL_Surface* two_digit_number(surface_cache_t* cache,int number){ SDL_Surface* load_surface = SDL_CreateRGBSurface(0,25 * 2,25,32,0,0,0,0); if(load_surface){ SDL_Rect rect = {0,0,25,25}; if(number / 10 > -1 && number / 10 < 10){ SDL_BlitScaled(cache->digits[number / 10],NULL,load_surface,&rect); } rect.x = 25; number %=10; if(number > -1 && number < 10){ SDL_BlitScaled(cache->digits[number],NULL,load_surface,&rect); } SDL_SetColorKey(load_surface,SDL_TRUE,SDL_MapRGB(load_surface->format,0,0,0)); return load_surface; } return (SDL_Surface*)NULL; }
int main(int argc, char* args[]) { //Start up SDL and create window if (!init()) { printf("Failed to initialize!\n"); } else { //Load media if (!loadMedia()) { printf("Failed to load media!\n"); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //While application is running while (!quit) { //Handle events on queue while (SDL_PollEvent(&e) != 0) { //User requests quit if (e.type == SDL_QUIT) { quit = true; } } //Apply the image stretched SDL_Rect stretchRect; stretchRect.x = 0; stretchRect.y = 0; stretchRect.w = SCREEN_WIDTH; stretchRect.h = SCREEN_HEIGHT; SDL_BlitScaled(gStretchedSurface, NULL, gScreenSurface, &stretchRect); //Update the surface SDL_UpdateWindowSurface(gWindow); } } } //Free resources and close SDL close(); return 0; }
void draw_block(min_block_type blck, int x, int y, int rx, int ry, int pw=w, int ph=h, SDL_Surface *extra=NULL) { cr.w = WINDOW_W / pw; cr.h = WINDOW_H / ph; cr.x = x * cr.w; cr.y = y * cr.h; switch(blck & 0xffff) { case BLCK_AIR: { SDL_Rect s_cr = cr; SDL_BlitScaled(s_b_sky, &s_cr, surface, &cr); } break; case BLCK_DIRT: { SDL_Rect s_cr; s_cr.x = 20 * (rx % 20); s_cr.y = 20 * (ry % 20); s_cr.w = s_cr.h = 20; SDL_BlitScaled(s_b_dirt, &s_cr, surface, &cr); } break; case BLCK_GRASS: { SDL_Rect s_cr; s_cr.x = 20 * (rx % 20); s_cr.y = 20 * (ry % 20); s_cr.w = s_cr.h = 20; SDL_BlitScaled(s_b_grass, &s_cr, surface, &cr); } break; case BLCK_BRICK: SDL_BlitScaled(s_b_brick, NULL, surface, &cr); break; } if (extra != NULL) { SDL_BlitScaled(extra, NULL, surface, &cr); } }
inline void updateWindow(SDL_Surface* toShow, Screen* screen) { SDL_Rect stretch; stretch.x = 0; stretch.y = 0; stretch.w = screen->width; stretch.h = screen->height; SDL_BlitScaled(toShow, null, screen->surface, &stretch); //SDL_BlitSurface(toShow, null, screen->surface, null); SDL_UpdateWindowSurface(screen->window); }
void KImage::blitSurface(SDL_Surface *dest, const KRect &dRect, const KRect &sRect) { if(surface == nullptr || dest == nullptr) { return; } SDL_Rect sr = KRectTOSDLRect(sRect); SDL_Rect dr = KRectTOSDLRect(dRect); if(SDL_BlitScaled(surface, &sr, dest, &dr) == -2) { // to-do: image memory was lost reload it. } }
static mrb_value mrb_sdl2_video_surface_blit_scaled(mrb_state *mrb, mrb_value self) { mrb_value src_rect, dst, dst_rect; mrb_get_args(mrb, "ooo", &src_rect, &dst, &dst_rect); SDL_Surface * const ss = mrb_sdl2_video_surface_get_ptr(mrb, self); SDL_Rect const * const sr = mrb_sdl2_rect_get_ptr(mrb, src_rect); SDL_Surface * const ds = mrb_sdl2_video_surface_get_ptr(mrb, dst); SDL_Rect * const dr = mrb_sdl2_rect_get_ptr(mrb, dst_rect); int ret; if (NULL != dr) { SDL_Rect tmp = *dr; ret = SDL_BlitScaled(ss, sr, ds, &tmp); } else { ret = SDL_BlitScaled(ss, sr, ds, dr); } if (0 != ret) { mruby_sdl2_raise_error(mrb); } return self; }
//Stretch given surface. SDL_Surface* Renderer::StretchSurface(SDL_Surface surface){ //Apply the image stretched SDL_Surface* stretchedsurface = NULL; SDL_Rect stretchRect; stretchRect.x = 0; stretchRect.y = 0; stretchRect.w = window_width; stretchRect.h = window_height; SDL_BlitScaled( stretchedsurface, NULL, screensurface, &stretchRect ); return stretchedsurface; }
Cell* fbfs_write(Cell* arg) { sdl_init(0); SDL_Event event; SDL_PollEvent(&event); SDL_Rect sr = {0,0,WIDTH/SCALE,HEIGHT/SCALE}; SDL_Rect dr = {0,0,WIDTH,HEIGHT}; SDL_BlitScaled(pixels_surf,&sr,win_surf,&dr); SDL_UpdateWindowSurface(win); return arg; }
int bmx_sdl_surface_BlitScaled(SDL_Surface * surface, int sx, int sy, int sw, int sh, SDL_Surface * dest, int dx, int dy) { SDL_Rect sr; sr.x = sx; sr.y = sy; sr.w = sw; sr.h = sh; SDL_Rect dr; dr.x = dx; dr.y = dy; return SDL_BlitScaled(surface, (sw==0 && sh==0 && sx==0 && sy==0) ? NULL : &sr, dest, &dr); }
//Set void SetPlayscreenBackground (SDL_Surface* gScreenSurface, SDL_Surface* gBlitingSurface) { copy.x = 0; copy.y = SCREEN_HEIGHT; copy.w = SCREEN_WIDTH; copy.h = SCREEN_HEIGHT; paste.x = 0; paste.y = 0; paste.w = SCREEN_WIDTH; paste.h = SCREEN_HEIGHT; SDL_BlitScaled( gBlitingSurface, ©, gScreenSurface, &paste ); }
bool render::drawScaledSurface(SDL_Surface* surface, SDL_Rect rect) { if (SDL_BlitScaled(surface, NULL, screenSurface, &rect))// draw the surface to the screen to the size of the rectangle { std::cout << "[ERROR]: the surface couldn't be scale-blitted" << std::endl; return false; } if (surface == NULL) { std::cout << "[ERROR]: the surface passed was NULL" << std::endl; return false; } return true; }
void waiting_for_other_player(DECK card[], int cardNumberOnScreen, PLAYER usr [],int myPlayerNumber){ int i; char game_table[50]="grafik/casino_betlight_off.bmp"; SDL_Surface* table_lightsOff_img = NULL; //Loaded converted table image table_lightsOff_img=loadSurface(game_table); SDL_BlitSurface(table_lightsOff_img, NULL, screen, NULL); SDL_FreeSurface(table_lightsOff_img); for(i=0;i<3;i++) { display_score(usr,i); // display user and dealer score } for(i=0;i<cardNumberOnScreen+1;i++) { card[i].card_img = SDL_LoadBMP(card[i].path); SDL_BlitScaled(card[i].card_img, NULL, screen, &card[i].CardPos); SDL_FreeSurface(card[i].card_img); } display_bet_holding(usr,card,myPlayerNumber,cardNumberOnScreen); }
/** * Renders an opponent player contingent on his presence inside the team's visibility bubbles * Calls render_player_speech to provide sound effects * * Revisions: * None. *loading * @param world The world struct * @param surface The surface to blit to * @param map_rect A struct containing the camera offset from the map's origin * @param fow A pointer to a FogComponent struct which contains a tile map and sound effects * @return void. * * @designer Sam Youssef * @author Sam Youssef * * @date April 3rd, 2014 */ void render_opponent_players(World& world, SDL_Surface *surface, FowComponent *fow, SDL_Rect map_rect) { for(int entity = 0; entity < opponentPlayersCount && entity < 32; entity++) { PositionComponent *position = &(world.position [ opponentPlayers[entity] ]); RenderPlayerComponent *renderPlayer = &(world.renderPlayer[ opponentPlayers[entity] ]); SDL_Rect playerRect; SDL_Rect clipRect; playerRect.x = position->x + map_rect.x - 20; playerRect.y = position->y + map_rect.y - 20 ; playerRect.w = renderPlayer->width; playerRect.h = renderPlayer->height; int xPos = position->x / TILE_WIDTH; int yPos = position->y / TILE_HEIGHT; //if(xPos >= 0 && yPos >= 0 && yPos < world.level[ position->level ].height && xPos < world.level[ position->level ].width) if(fow -> tiles[yPos][xPos].visible[ position->level ] == 0) { // show enemy player clipRect.x = -playerRect.x; clipRect.y = -playerRect.y; clipRect.w = playerRect.w; clipRect.h = playerRect.h; if (clipRect.x < 0) clipRect.x = 0; if (clipRect.y < 0) clipRect.y = 0; if (clipRect.h > HEIGHT - playerRect.y) clipRect.h = HEIGHT - playerRect.y; if (clipRect.w > WIDTH - playerRect.x) clipRect.w = WIDTH - playerRect.x; SDL_BlitScaled(renderPlayer->playerSurface, &clipRect, surface, &playerRect); render_player_speech(fow, xPos, yPos); } } }
void core_render() { SDL_Surface *windowSurface = SDL_GetWindowSurface(gCore.window); SDL_Rect stretchRect; render_tree(gCore.tree->root); node *cur = gCore.entities->head; while (cur != NULL) { stretchRect.x = cur->b->x; stretchRect.y = cur->b->y; stretchRect.w = 2 * cur->b->radius; stretchRect.h = 2 * cur->b->radius; SDL_BlitScaled(cur->b->texture, NULL, windowSurface, &stretchRect); cur = cur->next; } }
// If Pacman is partially off the edge of the window, the part of him that would be outside the // window will be drawn on the other side. void loopPacmanOnEdges() { SDL_Rect *imgRect; int errorCheck; for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) { delete mainRect; mainRect = scaledIntersection(0, 0, 640, 480, pmX + i*640, pmY + j*480, pmWidth, pmHeight, 1, 1); imgRect = scaledIntersection(0, 0, pmWidth, pmHeight, -(pmX + i*640), -(pmY + j*480), 640, 480, pmOrigWidth/pmWidth, pmOrigHeight/pmHeight); errorCheck = SDL_BlitScaled(imgSurface, imgRect, mainSurface, mainRect); if(errorCheck < 0) printf("SDL_BlitScaled: %s\n", SDL_GetError()); delete imgRect; } }
SDL_Texture* create_texture_from_surfaces(WindowElements* windowElements, SDL_Surface* src, SDL_Rect* srcRect, SDL_Surface* dest, SDL_Rect* destRect, bool scaled) { SDL_Texture* texture = NULL; //Due to a bug in SDL2, SDL_Surface* src must be converted to same pixel format as //SDL_Surface* dest in order to do scaled blitting // //More info: http://forums.libsdl.org/viewtopic.php?t=9975&highlight=sdlblitscaled SDL_Surface* convertedsrc = NULL; convertedsrc = SDL_ConvertSurface(src, dest->format, 0); if (convertedsrc==NULL) { printf("Unable to convert src pixel format to match dest! SDL_Error: %s\n", SDL_GetError()); return texture; } if (scaled) { SDL_BlitScaled(convertedsrc, srcRect, dest, destRect); } else { SDL_BlitSurface(convertedsrc, srcRect, dest, destRect); } texture = SDL_CreateTextureFromSurface(windowElements->renderer, dest); if(texture==NULL) { printf("Unable to create texture from surfaces! SDL Error: %s\n", SDL_GetError()); } SDL_FreeSurface(convertedsrc); return texture; }
Cell* fbfs_write(Cell* arg) { sdl_init(0); SDL_Event event; if (SDL_PollEvent(&event)) { if (event.type==SDL_QUIT) exit(0); } SDL_Rect sr = {0,0,WIDTH,HEIGHT}; SDL_Rect dr = {0,0,WIDTH*SCALE,HEIGHT*SCALE}; if (SCALE!=1) { SDL_BlitScaled(pixels_surf,&sr,win_surf,&dr); } else { SDL_BlitSurface(pixels_surf,NULL,win_surf,NULL); } // TODO only if changes happened SDL_UpdateWindowSurface(win); SDL_Delay(20); return arg; }