libsdl-org / SDL-1.2

Simple Directmedia Layer, 1.2 branch ... ***DEPRECATED***, please use https://github.com/libsdl-org/SDL for new projects!
https://libsdl.org
GNU Lesser General Public License v2.1
98 stars 81 forks source link

SDL doesn't render anything on MacOSX 11.5.1 #851

Closed LanFly closed 2 years ago

LanFly commented 2 years ago

environment

SDL: 1.2.15 gcc: Apple clang version 13.0.0 (clang-1300.0.29.3)

SDL doesn't render anything on MacOSX 11.5.1.

I confirm that the picture exists.

expect: render hello.bmp

result: nothing

image

code: src/window.c

#include <SDL/SDL.h>

#undef main
int main(int argc, char *argv[])
{
  SDL_bool quit = SDL_FALSE;
  SDL_Event event;
  SDL_Init(SDL_INIT_EVERYTHING);

  SDL_Rect rect = {0, 0, 100, 100};

  SDL_Surface* window = SDL_SetVideoMode(480, 480, 32, SDL_SWSURFACE);
  SDL_Surface* hello = SDL_LoadBMP("../preview2.bmp");
  if (hello == NULL) {
    printf("read bmp error\n");
  }
  SDL_BlitSurface(hello, NULL, window, NULL);
  SDL_WM_SetCaption("hello sdl", "logo.png");
  SDL_Flip(window);

  while (!quit)
  {
    while (SDL_PollEvent(&event))
    {
      if (event.type == SDL_QUIT) {
        quit = SDL_TRUE;
      }
    }
  }

  SDL_FreeSurface(hello);
  SDL_Quit();
  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.5)
set(project_name sdl-demo)
project(${project_name})

add_executable(${project_name} src/window.c)
target_include_directories(${project_name} PUBLIC ~/Library/SDL ~/Library)

target_link_libraries(${project_name} /Users/lan/Library/SDL/SDL)
slouken commented 2 years ago

@icculus, @sezero, does sdl12-compat work on macOS?

sezero commented 2 years ago

@icculus, @sezero, does sdl12-compat work on macOS?

As far as I know, yes.

sezero commented 2 years ago

SDL: 1.2.15 gcc: Apple clang version 13.0.0 (clang-1300.0.29.3)

I suggest trying SDL-1.2 from git instead of the 1.2.15 release.

icculus commented 2 years ago

sdl12-compat and the latest in git both work, to my knowledge.

1.2.15 is broken on newer macOS releases, and has been for quite some time now.

LanFly commented 2 years ago

thank's all. I resolved the problem with recompile sdl1.2 and link libSDLmain.a.

sezero commented 2 years ago

OK, closing.