diff --git a/CMakeLists.txt b/CMakeLists.txt index c88fd77..d540c72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,29 +11,27 @@ set(EXECUTABLE demo1_pixels_wave) # Buscar SDL3 automáticamente find_package(SDL3 REQUIRED) -include_directories(${SDL3_INCLUDE_DIRS}) -link_directories(${SDL3_LIBRARY_DIRS}) # Detectar la plataforma y ajustar configuraciones específicas if(WIN32) set(PLATFORM windows) - set(LDFLAGS "-lmingw32 -lws2_32 ${SDL3_LIBRARIES}") set(EXE_EXT ".exe") + set(EXTRA_LIBS mingw32 ws2_32) elseif(UNIX AND NOT APPLE) set(PLATFORM linux) set(EXE_EXT ".out") - set(LDFLAGS "${SDL3_LIBRARIES}") + set(EXTRA_LIBS "") elseif(APPLE) set(PLATFORM macos) set(EXE_EXT ".out") - set(LDFLAGS "${SDL3_LIBRARIES}") + set(EXTRA_LIBS "") endif() # Añadir el ejecutable add_executable(${EXECUTABLE}${EXE_EXT} ${SOURCE}) -# Enlazar las bibliotecas -target_link_libraries(${EXECUTABLE}${EXE_EXT} ${LDFLAGS}) +# Enlazar las bibliotecas específicas y SDL3 +target_link_libraries(${EXECUTABLE}${EXE_EXT} ${EXTRA_LIBS} SDL3::SDL3) # Colocar el ejecutable en la raíz del proyecto set_target_properties(${EXECUTABLE}${EXE_EXT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}) diff --git a/demo1_pixels_wave.cpp b/demo1_pixels_wave.cpp index 6806449..209d372 100644 --- a/demo1_pixels_wave.cpp +++ b/demo1_pixels_wave.cpp @@ -1,3 +1,4 @@ +#define _USE_MATH_DEFINES #include #include @@ -55,10 +56,10 @@ int main(int argc, char *argv[]) { float dist = sqrt(i * i + j * j); float z = cos((dist / 40 - time) * M_PI * 2) * 6; - const int x = rad + i + dx; - const int y = rad + j - z + dy; - if (x < WIDTH && y < HEIGHT && x >= 0 && y >= 0) - surface[x + y * WIDTH] = 1; + const int X = rad + i + dx; + const int Y = rad + j - z + dy; + if (X < WIDTH && Y < HEIGHT && X >= 0 && Y >= 0) + surface[X + Y * WIDTH] = 1; } // Vuelca la surface a la textura @@ -68,9 +69,7 @@ int main(int argc, char *argv[]) } SDL_UnlockTexture(texture); - SDL_RenderTexture(renderer, texture, nullptr, nullptr); - SDL_RenderPresent(renderer); }