este es el codigo:
- Código: Seleccionar todo
#include "programa.hpp"
#include <iostream>
#include <SDL/SDL.h>
#include <stdio.h>
using namespace std;
void compatibilidad_video_sdl(int w, int h, int bpp);
void sdl_videoinfo();
void datos_configuracion(int *w,int *h,int *bpp);
int main()
{
int opcion;
int w, h, bpp;
atexit(SDL_Quit);
do
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
cerr << "NO SE PUEDE INICIAR EL SDL VIDEO: "<<SDL_GetError()<<endl;
return -1;
}
cout<<endl;
cout<<"1-Compatibilidad Del Video SDL."<<endl;
cout<<"2-Informacion SDL_Video_info."<<endl;
cout<<"3-Salir."<<endl;
(int)cin.get();
switch (opcion)
{
case 1:
datos_configuracion(&h, &w, &bpp);
compatibilidad_video_sdl (w,h,bpp);
SDL_Quit();
break;
case 2:
sdl_video_info ();
SDL_Quit();
break;
case 3:
SDL_Quit();
break;
default:
cout <<endl<<"Opcion no valida"<<endl;
}
}
while (opcion != 3);
cout << endl<<"OK"<<endl;
return 0;
}
void compatibilidad_video_sdl(int w, int h, int bpp)
{
SDL_Surface *pantalla;
//SWSURFACE superficie en la memoria principal (por software)
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE);
if (pantalla == NULL)
{
cout <<" SDL_SWSURFACE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_SWSURFACE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//HWSURFACE superficie en la memoria de la gpu (hardware)
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_HWSURFACE);
if (pantalla == NULL)
{
cout <<" SDL_HWSURFACE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_HWSURFACE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//HWSURFACE+DOUBLEBUFFER
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (pantalla == NULL)
{
cout <<" SDL_HWSURFACE con SDL_DOUBLEBUF hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_HWSURFACE con SDL_DOUBLEBUF hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//SDL_ASYNCBLIT Especial para Multiprocesadores
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_ASYNCBLIT);
if (pantalla == NULL)
{
cout <<" SDL_ASYNCBLIT hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_ASYNCBLIT hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//SDL_ANYFORMAT Forzar bbp en modo ventana
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_ANYFORMAT);
if (pantalla == NULL)
{
cout <<" SDL_ANYFORMAT hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_ANYFORMAT hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//SDL_HWPALETTE acceso exclusivo paleta de color
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_HWPALETTE);
if (pantalla == NULL)
{
cout <<" SDL_HWPALETTE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_HWPALETTE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//SDL_OPENGLBLIT permite renderizado opengl
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_OPENGLBLIT);
if (pantalla == NULL)
{
cout <<" SDL_OPENGLBLIT hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_OPENGLBLIT hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//SDL_RESIZABLE permite a la aplicacion redimensionar la superficie
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_RESIZABLE);
if (pantalla == NULL)
{
cout <<" SDL_RESIZABLE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_RESIZABLE hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//SDL_NOFRAME
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_NOFRAME);
if (pantalla == NULL)
{
cout <<" SDL_NOFRAME hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_NOFRAME hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
//SDL_FULLSCREEN
pantalla = SDL_SetVideoMode(w, h, bpp, SDL_FULLSCREEN);
if (pantalla == NULL)
{
cout <<" SDL_FULLSCREEN hwbpp: "<<h<<" "<<w<<" "<<bpp<<" No compatible, El error es: "<<SDL_GetError()<<endl;
}
else
{
cout <<" SDL_FULLSCREEN hwbpp: "<<h<<" "<<w<<" "<<bpp<<" Es compatible"<<endl;
}
}
void sdl_videoinfo()
{
const SDL_VideoInfo *propiedades;
SDL_Surface *superficie;
SDL_Rect **modos;
//variables auxiliares
char driver[20];
int maxlon = 20;
propiedades = SDL_GetVideoInfo();
if (propiedades == NULL)
{
cerr << endl<<"ERROR no se puede obtener la informacion de la gpu"<<endl;
}
modos = SDL_ListModes(NULL,SDL_HWSURFACE);
cout <<endl<<" == MODOS DE VIDEO DISPONIBLES == "<<endl;
if (modos == (SDL_Rect **)0)
{
cerr << endl<<" NO EXISTEN MODOS DISPONIBLES!!!"<<endl;
}
else if (modos == (SDL_Rect **)-1)
{
cout <<endl<<" TODOS LOS MODOS DISPONIBLES "<<endl;
}
else
{
cout <<endl<< "MODOS DISPONIBLES: "<<endl;
for (int i = 0;modos[i];i++)
{
cout << modos[i] -> w <<" x " <<modos[i] -> h<<endl;
}
}
// vamos a comprobar que el modo esta ok
if (SDL_VideoModeOK(1280, 1024, 32, SDL_HWSURFACE)== 0)
{
cerr << "HWSURFACE 1280 x 1024 32bits no compatible ERROR: " <<SDL_GetError()<<endl;
}
superficie = SDL_SetVideoMode(1280, 1024, 32, SDL_HWSURFACE);
if (superficie == NULL)
{
cerr << "ERROR AL ASIGNAR EL MODO DE VIDEO: " << SDL_GetError()<<endl;
}
cout <<endl<<endl<<" DRIVER OBTENIDO "<<endl;
SDL_VideoDriverName(driver,maxlon);
if (driver == NULL)
{
cerr << "ERROR AL OBTENER EL NOMBRE DEL DRIVER "<< SDL_GetError()<<endl;
}
cout <<driver<<endl;
cout <<endl<<endl<< " == INFORMACION DE SDL_INFO =="<<endl;
if(propiedades->hw_available == 1)
{
cout << "HW COMPATIBLE"<<endl;
}
else
{
cout << "HW NO COMPATIBLE"<<endl;
}
if(propiedades->wm_available == 1)
{
cout << "HAY UN MANEJADOR DE VENTANAS"<<endl;
}
else
{
cout << "NO HAY GESTOR DE VENTANAS"<<endl;
}
if(propiedades->blit_hw == 1)
{
cout << "EL BLIT POR HW ESTA ACCELERADO"<<endl;
}
else
{
cout << "EL BLIT POR HW NO ESTA HABLITADO"<<endl;
}
if(propiedades->blit_hw_CC == 1)
{
cout << "EL BLIT CON TRANSPARENCIA POR HW ESTA ACCELERADO"<<endl;
}
else
{
cout << "EL BLIT CON TRANSPARENCIAS NO ESTA ACCELERADO"<<endl;
}
if(propiedades->blit_sw == 1)
{
cout << "BLIT SOFT. ESTA ACCELERADO"<<endl;
}
else
{
cout << "BLIT SOFT. NO ESTA ACCELERADO"<<endl;
}
if(propiedades->blit_fill == 1)
{
cout << "EL BLIT DE RELLENO ESTA ACCELERADO"<<endl;
}
else
{
cout << "BLIT DE RELLENO NO ACCELERADO"<<endl;
}
if(propiedades->blit_sw_A == 1)
{
cout << "BLIT SOFT. CON ALPHA ESTA ACCELERADO"<<endl;
}
else
{
cout << "BLIT SOFT. CON ALPHA NO ESTA ACCELERADO"<<endl;
}
cout << "La memoria de video tiene: "<<(float)propiedades->video_mem<<endl;
}
void datos_configuracion(int *w,int *h,int *bpp)
{
cout << endl<<"Introduce la anchura de la pantalla en pixels: ";
scanf("%d",w);
cout << endl<<"Introduce la altura de la pantalla en pixels: ";
scanf("%d",h);
cout << endl<<"Introduce la profundidad del color: ";
scanf("%d",bpp);
cout <<endl;
}
AYUDA PORFAVOORR!! xD
el error del compilador:
samuel@desktop:~/Projectos/Anjuta/SDLPRIMER/src$ g++ programa.cpp -o samu `sdl-config --cflags --libs --static-libs`
/tmp/ccsoJbff.o: In function `main':
programa.cpp:(.text+0x128f): undefined reference to `sdl_video_info()'
collect2: ld devolvió el estado de salida 1