Load bmp returns NULL

And what did you do to make it work?

DAVIDlavi20091997 wrote:

mr naith and mr tawan tanke you very much to help me dill with this problam the problam just was that the i didnt crated the renderr befure the sdl texture and that i didnt copied the image to the main cpp dirctaury, imn very surry for wasting your time on such an abstract and Trivial matter,tanke you very very much :smiley: :smiley: :smiley: :smiley: :smiley: :smiley:

I know that you’re too excited by now. but you might want to consider asking someone to spell check first ^^’ It’s kinda hard to read.

Glad you get it working (I didn’t really help much after all, all the credit goes to Nait.).

Glad it works now.

Take all this as a reminder:

Whenever you want to execute your program from within Visual Studio, all the files that the program needs (images, sounds and so on), need to be in the same directory as the source (*.h, *.cpp) files (or as in my case, some kind of Data directory).
Whenever you want to execute your program from the Debug / Release directory, all the files that the program needs (images, sounds and so on), need to be in the same directory as the executable file (or as in my case, some kind of Data directory).

Glad it works now.

Take this as a reminder

  • Whenever you want to execute your program from within Visual Studio, all the files that the program needs (images, sounds and so on), need to be in the same directory as the source (*.h, *.cpp) files (or as in my case, some kind of Data directory).
  • Whenever you want to execute your program from the Debug / Release directory, all the files that the program needs (images, sounds and so on), need to be in the same directory as the executable file (or as in my case, some kind of Data directory).

http://s14.postimg.org/t9mtjuinj/New_Bitmap_Image_4.png

http://s14.postimg.org/yv98nwjch/New_Bitmap_Image_2.png

http://speedy.sh/QryVp/sdl.zip here is the zip, i copyed the pic every where

by the way im using v-s express 2010

om my frikking goood,IT WORKES…

no… the probkam was just crating the texture befure the render i think the image is stored at the .exe dirc…i dont know what happind that it didnt work befure [Embarassed]

im gonne try upload a video in it i start from the top, from including the sdl liblery to v-s and coping the image and your code to it and then i well run it

i just dont know what im doing wrong, i did everything you said multiple times and its still not working,i changed the working dirctury to every posible situation from the folder to debug and even outside the project and its stil dosnet work, i cureected the mistakes changed the bmp and the lpcitaion to every place in the project still…nuthing
:frowning:
#include <SDL.h>

SDL_Window* g_pWindow = NULL;
SDL_Renderer* g_pRenderer = NULL;

SDL_Texture* g_pTexture = NULL;

int main(int argc, char* args[])
{
// Initialize SDL
if(SDL_Init(SDL_INIT_EVERYTHING) >= 0)
{
// If SDL was succesfully initialized, create the SDL window
g_pWindow = SDL_CreateWindow(“Chapter 1: Setting up SDL”, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);

  // If the SDL window was succesfully created 
  if(g_pWindow) 
  { 
     // Create the renderer 
     g_pRenderer = SDL_CreateRenderer(g_pWindow, -1, 0); 

     // If the renderer was succesfully created 
     if(g_pRenderer) 
     { 
        // Set the render draw color 
        SDL_SetRenderDrawColor(g_pRenderer, 0, 0, 0, SDL_ALPHA_OPAQUE); 
         
        // Create the temp surface 
        SDL_Surface* pTempSurface = SDL_LoadBMP("//asd.bmp"); 

        // If the temp surface was successfully created 
        if(pTempSurface) 
        { 
           // Create the texture 
           g_pTexture = SDL_CreateTextureFromSurface(g_pRenderer, pTempSurface); 

           // Destroy the temp surface 
           SDL_FreeSurface(pTempSurface); 
        } 
     } 
  } 

}

// If SDL for some reason couldn’t initialize
else
return 1;

// Clear the current render target
SDL_RenderClear(g_pRenderer);

// Render the texture
if(g_pTexture)
SDL_RenderCopy(g_pRenderer, g_pTexture, NULL, NULL);

// Update the screen
SDL_RenderPresent(g_pRenderer);

// Wait 2 seconds and then exit the program
SDL_Delay(2000);

// Destroy the texture
if(g_pTexture)
SDL_DestroyTexture(g_pTexture);

// Quit SDL
SDL_Quit();

return 0;
} [Laughing] [Laughing] [Laughing] [Laughing] [Laughing] :o :o [Laughing] [Laughing] 8) [Laughing] [Laughing] :o :frowning: :slight_smile: :smiley: :smiley: :o :o :o :o :o :o [Laughing]

ps-soory for the shouting and the smaly paces in the end [Laughing] [Laughing] [Laughing] :smiley:

im surry it didnt worked,http://i60.tinypic.com/2zq4qdt_th.jpg
http://s8.tinypic.com/2mwz69f_th.jpg
http://s8.tinypic.com/10nezc7_th.jpg

and i cant give direct access to my computer its just my private stuff and the things of my famlay is on it

i knowon that befure i just wanted to use your image so i cunverted it but i crated some bmp files and drew them my self {using paind} and copied them to there place,the result is the same no matter

mr naith and mr tawan tanke you very much to help me dill with this problam the problam just was that the i didnt crated the renderr befure the sdl texture and that i didnt copied the image to the main cpp dirctaury, imn very surry for wasting your time on such an abstract and Trivial matter,tanke you very very much :smiley: :smiley: :smiley: :smiley: :smiley: :smiley:

mr naith your were right the problam was that the texture was crated befure the Renderer,i deleted all the if statmants just to chack if thats the error and it workes fine without them,tanke you for the halp and time.
and surry for my bad english…im an israeli and speak hebrew as my native tung.tanke you all and see on in the feuture :o

http://tinypic.com/player.php?v=2h85tfd>&s=8#.U8_Sg_l_vpA

http://tinypic.com/player.php?v=96yesl>&s=8#.U8_TVPl_vpA

http://tinypic.com/player.php?v=358thft>&s=8#.U8_Tt_l_vpA