Es muy facil integrar la SDL en Rad Studio C++ Builder
puedes usar SDL o SDL2 en C++ Builder Rad Studio
solo necesitas convertir el fichero 32 o 64 bit DLL (SDL2.DLL) con Implib a libreria static (archivo LIB) para usarlo en tu Proyecto de Rad Studio
el comando (en linea de comandos del CMD de windows) es "convertir SDL2.DLL, ejecutar “IMPLIB -a -c SDL2.LIB SDL2.DLL” y agregar sdl2.lib al proyecto
he hecho una prueba para ver si funciona y si, funciona perfectamente en Rad Studio C++ Builder 11.3 Alexandria
Código:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <iostream>
#include <algorithm>
#include <SDL.h>
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// Initialize SDL
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
AnsiString cadena = "";
cadena = sprintf("SDL could not be initialized! - SDL_Error: %d", SDL_GetError());
ShowMessage(cadena);
//return 0;
}
#if defined linux && SDL_VERSION_ATLEAST(2, 0, 8)
// Disable compositor bypass
if(!SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"))
{
ShowMessage("SDL can not disable compositor bypass!");
//return 0;
}
#endif
// Create window
SDL_Window *window = SDL_CreateWindow("Basic C++ SDL project",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_SHOWN);
if(!window)
{
AnsiString cadena = "";
cadena = sprintf("Window could not be created! - SDL_Error: %d", SDL_GetError());
ShowMessage(cadena);
}
else
{
// Create renderer
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if(!renderer)
{
AnsiString cadena = "";
cadena = sprintf("Renderer could not be created! - SDL_Error: %d", SDL_GetError());
ShowMessage(cadena);
}
else
{
// Declare rect of square
SDL_Rect squareRect;
// Square dimensions: Half of the min(SCREEN_WIDTH, SCREEN_HEIGHT)
squareRect.w = std::min(SCREEN_WIDTH, SCREEN_HEIGHT) / 2;
squareRect.h = std::min(SCREEN_WIDTH, SCREEN_HEIGHT) / 2;
// Square position: In the middle of the screen
squareRect.x = SCREEN_WIDTH / 2 - squareRect.w / 2;
squareRect.y = SCREEN_HEIGHT / 2 - squareRect.h / 2;
// Event loop exit flag
bool quit = false;
// Event loop
while(!quit)
{
SDL_Event e;
// Wait indefinitely for the next available event
SDL_WaitEvent(&e);
// User requests quit
if(e.type == SDL_QUIT)
{
quit = true;
}
// Initialize renderer color white for the background
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
// Clear screen
SDL_RenderClear(renderer);
// Set renderer color red to draw the square
SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0x00, 0xFF);
// Draw filled square
SDL_RenderFillRect(renderer, &squareRect);
// Update screen
SDL_RenderPresent(renderer);
}
// Destroy renderer
SDL_DestroyRenderer(renderer);
}
// Destroy window
SDL_DestroyWindow(window);
}
// Quit SDL
SDL_Quit();
//return 0;
}
//---------------------------------------------------------------------------