Hello,
impossible to display an image in a window, in debug mode as soon as the execution line arrives on ‘image = SDL_LoadBMP …’ the pointer changes to ‘NULL’ the path is good, two bmp and png files to test. … same result …
if you have any ideas, because here I park
#include <SDL2/SDL.h>
#include <stdlib.h>
#include <stdio.h>
#include <OpenGL/gl3.h>
#include <SDL2_image/SDL_image.h>
#include <SDL_ttf/SDL_ttf.h>
int main(int argc, char** argv)
{
//SDL_Surface * ws = NULL;
SDL_Surface * is = NULL,*texte = NULL,*image = NULL;
SDL_DisplayMode dpm;
SDL_GetDesktopDisplayMode(0, &dpm);
SDL_Renderer *renderer = NULL;
TTF_Font *fonts;
SDL_Color ct ={ 255, 255, 255, 255 };
SDL_Rect pt;
int quit = 0;
TTF_Init();
if (TTF_Init() != 0){
SDL_Quit();
return 1;
}
fonts = TTF_OpenFont("Cochin.ttf",15);
SDL_Event event;IMG_Init(IMG_INIT_PNG);
/* Initialisation simple */
if (SDL_Init(SDL_INIT_VIDEO) != 0 )
{
fprintf(stdout,"Échec de l'initialisation de la SDL (%s)\n",SDL_GetError());
return -1;
}
/* Création de la fenêtre */
SDL_Window* pWindow = NULL;
pWindow = SDL_CreateWindow("Ma première application SDL2",SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
800,
600,
SDL_WINDOW_RESIZABLE);
//SDL_ShowWindow(pWindow);
//SDL_GLContext glcontext = SDL_GL_CreateContext(pWindow);
renderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC);
image =malloc(sizeof(SDL_Surface));
image = SDL_LoadBMP("/Users/bob/Downloads/Projet_SDL2_macos_XCode/src/RAY.bmp");
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, image);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);