Codesnippets > Code Snippets
FASTMEM2SPRITE
dreamerman:
Ah yes, it must be called from inline so arguments have proper types, but it should compile without problems, I've pasted it into your project at the end of *_OGL file and it compiles properly. I'm using it in this way:
--- Code: (glbasic) ---// put Steam Image from img_handle to GLB sprite with specified ID
// posy -> needs to be calculated to OpenGL notation - from left bottom corner upwards
FUNCTION putSteamImageOnSprite%: img_handle%, sprite_id%, posx%, posy%
INLINE
uint32 cwidth, cheight;
SteamAPI_ISteamUtils_GetImageSize(si_steamutils, img_handle, &cwidth, &cheight);
//printf("image size: %1d x %1d \n", cwidth, cheight);
const int cSizeInBytes = cwidth * cheight * 4;
uint8 *pavatarImage = new uint8[cSizeInBytes];
SteamAPI_ISteamUtils_GetImageRGBA(si_steamutils, img_handle, pavatarImage, cSizeInBytes);
FastMem2Sprite_uint(pavatarImage, sprite_id, posx, posy - cheight, cwidth, cheight);
delete[] pavatarImage;
ENDINLINE
ENDFUNCTION
--- End code ---
main difference to your code is that start x/y position to paste image, nothing more, and you can add that to glTexSubImage2D call without other modifications, for me it's sometimes just easier to use inline like this when working with Steamworks.
As this function is fast and user avatars are small there are no visible slowdowns when they are fetched and pasted into larger sprite.
Navigation
[0] Message Index
[*] Previous page
Go to full version