![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
|
SDL en C++ Builder Rad Studio
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;
}
//---------------------------------------------------------------------------
|
|
#2
|
||||
|
||||
|
Tal vez para los neófitos en el tema, estaría bien explicar qué son SDL y SFML.
Y algún link para que se hagan (o nos hagamos) una idea.
__________________
Germán Estévez => Web/Blog Guía de estilo, Guía alternativa Utiliza TAG's en tus mensajes. Contactar con el Clubdelphi ![]() P.D: Más tiempo dedicado a la pregunta=Mejores respuestas. |
|
#3
|
|||
|
|||
|
pues basicamente son unas librerias graficas aunque tambien controlan cosas de sonido y algunas cosas mas
Simple DirectMedia Layer (SDL) es un conjunto de bibliotecas desarrolladas en el lenguaje de programación C que proporcionan funciones básicas para realizar operaciones de dibujo en dos dimensiones, gestión de efectos de sonido y música, además de carga y gestión de imágenes. https://es.wikipedia.org/wiki/Simple...SDL)%20es%20un https://gzalo.com/articles/sdl/#:~:t...%20un%20editor Última edición por navbuoy fecha: 27-09-2024 a las 06:36:39. |
|
#4
|
||||
|
||||
|
Cita:
![]() ![]() ![]() ![]()
__________________
Germán Estévez => Web/Blog Guía de estilo, Guía alternativa Utiliza TAG's en tus mensajes. Contactar con el Clubdelphi ![]() P.D: Más tiempo dedicado a la pregunta=Mejores respuestas. |
![]() |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| consultar a API ChatGPT con REST en C++ Builder Rad Studio 12 | navbuoy | C++ Builder | 12 | 13-03-2024 23:23:00 |
| CSFML en Rad Studio 10.0 Seattle (o en C++ Builder en general) | Snaked | C++ Builder | 3 | 24-11-2016 04:40:32 |
| [DANYSOFT] Novedades Delphi, C++Builder y RAD Studio XE8 | neftali2 | Noticias | 0 | 07-04-2015 11:30:39 |
| Aplicación C++builder 6 a Visual studio 2005 | Julian Uribe | C++ Builder | 0 | 23-02-2010 15:57:01 |
|