Re: [問題] 請問SDL的部分程式碼問題

看板C_and_CPP (C/C++)作者時間13年前 (2012/07/19 17:10), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/2 (看更多)
First the image is loaded using SDL_LoadBMP(). But it shouldn't be used immediately because the bitmap is 24-bit. The screen is 32-bit and it's not a good idea to blit a surface onto another surface that is a different format because SDL will have to change the format on the fly which causes slow down. 第一件事先用 SDL_LoadBMP() 讀取 image, 但是不能馬上使用因為圖是 24-bit 但螢幕卻是 32-bit, 硬要將圖貼上的話 SDL 必須很快的轉換格式從而造成效能低落 --------------------------------------------------------------------------- If the image loaded fine, SDL_DisplayFormat() is called which creates a new version of "loadedImage" in the same format as the screen. The reason we do this is because when you try to stick one surface onto another one of a different format, SDL converts the surface so they're the same format. SDL_DisplayFormat 是把傳入的 surface 轉成跟螢幕一樣的格式並儲存起來, 而不用 每次都把格式轉成一樣再貼上去 So now we have 2 surfaces, the old loaded image and the new optimized image. 大概就是這樣, 有錯請指正 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 36.229.84.166

07/19 20:41, , 1F
謝謝你的幫忙,我了解他意思了
07/19 20:41, 1F
文章代碼(AID): #1G1yxr9j (C_and_CPP)
文章代碼(AID): #1G1yxr9j (C_and_CPP)