diff options
| author | raysan5 <[email protected]> | 2020-12-24 13:26:30 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-12-24 13:26:30 +0100 |
| commit | 83ab2cb01746a869b625c9d84fbb4737146b73a9 (patch) | |
| tree | 010b0794848d863916e5acb4f766ea9e7ecb6e90 /examples/web/textures/textures_raw_data.c | |
| parent | d11274dcfcb0f349fba16ab4b83d2b96bcac8d1a (diff) | |
| download | raylib.com-83ab2cb01746a869b625c9d84fbb4737146b73a9.tar.gz raylib.com-83ab2cb01746a869b625c9d84fbb4737146b73a9.zip | |
Updated Web examples to raylib 3.5
Diffstat (limited to 'examples/web/textures/textures_raw_data.c')
| -rw-r--r-- | examples/web/textures/textures_raw_data.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/examples/web/textures/textures_raw_data.c b/examples/web/textures/textures_raw_data.c index f07496d..c1078dc 100644 --- a/examples/web/textures/textures_raw_data.c +++ b/examples/web/textures/textures_raw_data.c @@ -47,9 +47,9 @@ int main(void) fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM) UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data - // Generate a checked texture by code (1024x1024 pixels) - int width = 1024; - int height = 1024; + // Generate a checked texture by code + int width = 960; + int height = 480; // Dynamic memory allocation to store pixels data (Color type) Color *pixels = (Color *)malloc(width*height*sizeof(Color)); @@ -58,13 +58,20 @@ int main(void) { for (int x = 0; x < width; x++) { - if (((x/32+y/32)/1)%2 == 0) pixels[y*height + x] = ORANGE; - else pixels[y*height + x] = GOLD; + if (((x/32+y/32)/1)%2 == 0) pixels[y*width + x] = ORANGE; + else pixels[y*width + x] = GOLD; } } // Load pixels data into an image structure and create texture - Image checkedIm = LoadImageEx(pixels, width, height); + Image checkedIm = { + .data = pixels, // We can assign pixels directly to data + .width = width, + .height = height, + .format = UNCOMPRESSED_R8G8B8A8, + .mipmaps = 1 + }; + checked = LoadTextureFromImage(checkedIm); UnloadImage(checkedIm); // Unload CPU (RAM) image data @@ -72,7 +79,7 @@ int main(void) free(pixels); // Unload CPU (RAM) pixels data #if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); + emscripten_set_main_loop(UpdateDrawFrame, 60, 1); #else SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -114,9 +121,9 @@ void UpdateDrawFrame(void) DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.5f)); DrawTexture(fudesumi, 430, -30, WHITE); - DrawText("CHECKED TEXTURE ", 84, 100, 30, BROWN); - DrawText("GENERATED by CODE", 72, 164, 30, BROWN); - DrawText("and RAW IMAGE LOADING", 46, 226, 30, BROWN); + DrawText("CHECKED TEXTURE ", 84, 85, 30, BROWN); + DrawText("GENERATED by CODE", 72, 148, 30, BROWN); + DrawText("and RAW IMAGE LOADING", 46, 210, 30, BROWN); DrawText("(c) Fudesumi sprite by Eiden Marsal", 310, screenHeight - 20, 10, BROWN); |
