Hey! raylib forum is closing!

After a year with not much movement in the forum I decided to close it.

The cost of maintaining the hosting is a bit high for the usage of the platform, updating the forum and managing it is also a bit cumbersome and the truth is that I'm already trying to maintain multiple other networks pretty more active than this forum.

I'll recommend you to move to the other raylib networks:

- For a forum style, use Reddit: https://www.reddit.com/r/raylib/
- For direct messaging and questions, use Discord: https://discord.gg/VkzNHUE
- To report issues, use GitHub: https://github.com/raysan5/raylib

- Also, remember you can contact me personally on Twitter: https://twitter.com/raysan5 or directly by mail to ray[at]raylib.com

If you feel generous, you can also contribute to the project on my Patreon: https://www.patreon.com/raylib

Thanks to you all for joining the project and help to improve it with your questions. Keep it up! :)

Best Regards,

Ray

PD. Closing will be effective by October 31th.

Texture Error Codes?

edited August 8 in raylib: textures
What I am doing wrong? All I did was trying make Variable for lands and clouds but I keep getting errors

#include "raylib.h"

int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;

InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading");

// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)

Image lands = LoadImage("resources/foregrounds.png"); // Loaded in CPU memory (RAM)
Texture2D texture = LoadTextureFromImage(image); // The Grass Land.....


Image image = LoadImage("resources/Clouds1.png");
Texture2D clouds = LoadTextureFromImage(image);

UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM

//------------------------------------------------------------------------------------

// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------

// Draw
//----------------------------------------------------------------------------------
BeginDrawing();

ClearBackground(RAYWHITE);

DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);

DrawTexture(clouds, 50, 50, WHITE);

// DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY);

EndDrawing();
//----------------------------------------------------------------------------------
}

// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading

CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

return 0;
}

Comments


  • error: 'image' undeclared (first use in this function); did you mean 'Image'?
    Texture2D texture = LoadTextureFromImage(image); // The Grass Land.....
    ^~~~~
    Image
  • I did corrected it but still get errors thought.....

    So I decide do very basic image showing like this

    [code]
    #include "raylib.h"

    int main()
    {
    // Initialization
    //--------------------------------------------------------------------------------------
    int screenWidth = 800;
    int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing");

    // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)

    Image grass = LoadImage("resources/block2.png"); // Load image in CPU memory (RAM)

    UnloadImage(grass); // Unload image from RA

    // SetTargetFPS(60);
    //---------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose()) // Detect window close button or ESC key
    {
    // Update
    //----------------------------------------------------------------------------------
    // TODO: Update your variables here
    //----------------------------------------------------------------------------------

    // Draw
    //----------------------------------------------------------------------------------
    BeginDrawing();

    ClearBackground(RAYWHITE);

    DrawTexture(grass, 0, 0, WHITE);

    EndDrawing();
    //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    UnloadTexture(grass); // Texture unloading

    CloseWindow(); // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
    }
    [/code]

    I still got error and can you correct it for me because it seem like I pulling my hair out lol
  • grass is an Image, it should be a Texture.

    Please, check raylib examples carefully.
Sign In or Register to comment.