-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCNC_PlatformServices.cpp
More file actions
38 lines (28 loc) · 1.24 KB
/
CNC_PlatformServices.cpp
File metadata and controls
38 lines (28 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "CNC_PlatformServices.h"
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_PNG
#include "libs/stb_image.h"
Image* PlatformLoadImage( const char* imagePath )
{
Image* image = (Image*)malloc( sizeof( Image ) );
image->m_data = stbi_load( imagePath, &image->m_width, &image->m_height, &image->m_channels, 4 );
return image;
}
/* implemented in the Renderer
u32 PlatformUploadImage( void* renderer, Image* image );
void PlatformUploadParticles( void* renderer, Particle* particles, u32 numParticles );
void PlatformRenderImage( void* renderer, u32 textureId );
void PlatformRenderParticles( void* renderer, u32 numParticles, u32 snowMask, u32 skyMask );
void PlatformUpdateImage( void* renderer, Image* image );
*/
PlatformServices* CreatePlatformServices()
{
PlatformServices* services = (PlatformServices*)malloc( sizeof( PlatformServices ) );
services->f_loadImage = &PlatformLoadImage;
services->f_uploadImage = &PlatformUploadImage;
services->f_uploadParticles = &PlatformUploadParticles;
services->f_renderImage = &PlatformRenderImage;
services->f_renderParticles = &PlatformRenderParticles;
services->f_updateImage = &PlatformUpdateImage;
return services;
}