elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Problema con SDL
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problema con SDL  (Leído 3,409 veces)
GhostLT

Desconectado Desconectado

Mensajes: 82


To know the truth,you must risk everything


Ver Perfil
Problema con SDL
« en: 9 Octubre 2010, 20:05 pm »

Hola amigos, estoy intentando iniciar con la programacion de videojuegos, me encuentro en la carga del sistema de video pero haciendo pruebas este codigo me muestra un error que no entiendo:

Este es el error:
In function `SDL_main':|
error: number of arguments doesn't match prototype|

haciendome referencia a este header

SDL_main.h|57|error: prototype declaration|

Código
  1. /** The prototype for the application's main() function */
  2. extern C_LINKAGE int SDL_main(int argc, char *argv[]);

Acá dejo el Código
Código
  1. // Creación de un degradado parcial, estableciendo un área de clipping
  2. #include <stdio.h>
  3. #include <SDL.h>
  4.  
  5.  
  6. int main()               //<------- Aqui es donde me marca el error
  7. {
  8. SDL_Surface *pantalla, *color_base;
  9. SDL_Rect posicion, clipping;
  10. SDL_Event evento;
  11. int i;
  12. // Iniciamos el subsistema de video SDL
  13. if( SDL_Init(SDL_INIT_VIDEO) < 0) {
  14. fprintf(stderr, "No se pudo iniciar SDL: %s\n",SDL_GetError());
  15. exit(1);
  16. }
  17. // Establecemos el modo de video
  18. pantalla = SDL_SetVideoMode(640, 500, 24,SDL_HWSURFACE|SDL_DOUBLEBUF);
  19. if(pantalla == NULL) {
  20. fprintf(stderr, "No se pudo establecer el modo de video:%s\n",SDL_GetError());
  21. exit(1);
  22. }
  23. atexit(SDL_Quit);
  24. // Cargamos la imagen del personaje principal
  25. color_base = SDL_LoadBMP("ima.bmp");
  26. if(color_base == NULL) {
  27. fprintf(stderr, "No se pudo cargar la imagen: %s\n",SDL_GetError());
  28. exit(1);
  29. }
  30. // Establecemos el área de clipping
  31. clipping.x = 0;
  32. clipping.y = 0;
  33. clipping.h = 500;
  34. clipping.w = 100;
  35. SDL_SetClipRect(pantalla, &clipping);
  36. // Vamos a dibujar 10 tiras
  37. for(i = 1; i <= 50; i++) {
  38. // Ajustamos las propiedades del canal alpha para las transparecnias
  39. SDL_SetAlpha(color_base, SDL_SRCALPHA|SDL_RLEACCEL, i * 5.1);
  40. // Establecemos donde vamos a dibujar las tiras
  41. posicion.x = 0;
  42. posicion.y = 10 * (i - 1);
  43. posicion.w = color_base->w;
  44. posicion.h = color_base->h;
  45. // Copiamos la imagen en la superficie principal
  46. SDL_BlitSurface(color_base, NULL, pantalla, &posicion);
  47. }
  48. // Mostramos la pantalla "oculta" del búffer
  49. SDL_Flip(pantalla);
  50. // Liberamos los recursos que no necesitamos
  51. SDL_FreeSurface(color_base);
  52. // Ahora mantenemos el resultado en pantalla
  53. // hasta cerrar la ventana
  54. for(;;) {
  55. while(SDL_PollEvent(&evento)) {
  56. if(evento.type == SDL_QUIT) // Si es de salida
  57. return 0;
  58. }
  59. }
  60. }
  61.  

espero y me puedan ayudar para no morir en el intento, Gracias


En línea

There is some fiction in you truth, and some truth in you fiction
Beakman

Desconectado Desconectado

Mensajes: 190



Ver Perfil WWW
Re: Problema con SDL
« Respuesta #1 en: 9 Octubre 2010, 21:38 pm »

Te falta la SDL_image, para cargar las imágenes y esas cosas, igual ese no puede ser el error porque te saltaría otra cosa.
Intenta compilar un programa simple como:
Código
  1. #include<iostream>
  2. #include<SDL/SDL.h>
  3. using namespace std;
  4. int main()
  5. {
  6.   return 0;
  7. }
  8.  
Y te fijas que te dice.

Pusiste <SDL.h>
Casi siempre las librerías las tenes en "<SDL/...etc"
Fijate bien como lo tenes.

Pero el error no esta en el programa.


En línea

GhostLT

Desconectado Desconectado

Mensajes: 82


To know the truth,you must risk everything


Ver Perfil
Re: Problema con SDL
« Respuesta #2 en: 9 Octubre 2010, 22:10 pm »

Con respecto a
Código
  1. <SDL.h>
me funciona de esta manera bien,

Ademas ya agregue:
Código
  1. <SDL_image.h>


Y modifique
main(int argc, char *argv[]);

Ya no me marco errores pero al correr no aparece la ventana de SDL (se queda colgado), solo me aparece la ventana del prompt con fondo negro  :-\



En línea

There is some fiction in you truth, and some truth in you fiction
anonimo12121


Desconectado Desconectado

Mensajes: 1.813


Ver Perfil WWW
Re: Problema con SDL
« Respuesta #3 en: 11 Octubre 2010, 00:53 am »

Prueba haber si te va esto .
Código:
#include <iostream>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
using namespace std;
SDL_Surface *screen;
SDL_Event evento;
Uint8 *tecla;
float tiempo;

int main(int argc,char *argv[]){
    SDL_Init(SDL_INIT_VIDEO);
    screen=SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
    SDL_WM_SetCaption("App1",0);
    while(1){
        //iniciamos el reloj
        tiempo=SDL_GetTicks();
        tecla=SDL_GetKeyState(0);
        SDL_PollEvent(&evento);
        if(tecla[SDLK_ESCAPE])exit(1);
        //comprovamos el tiempo
        tiempo =SDL_GetTicks()-tiempo;
        if(tiempo < 33.33){            //si aun sobra tiempo hasta llegar a los 33.33 ms
            SDL_Delay( 33.33-tiempo ); //vete a dormir durante 33.33-x milisegundos 33.33 ms es = 30 fps en 1 s
        }
    }


}

« Última modificación: 11 Octubre 2010, 00:55 am por Xafirot » En línea

Página para ganar Bitcoins y Dinero: http://earnbit.hol.es/
Video de YouTube con Hack para el LoL: http://adf.ly/5033746/youtube-lolemuhack
Si quieres ganar dinero con adfly entra y registrate aquí -> http://adf.ly/?id=5033746
GhostLT

Desconectado Desconectado

Mensajes: 82


To know the truth,you must risk everything


Ver Perfil
Re: Problema con SDL [SOLUCIONADO]
« Respuesta #4 en: 11 Octubre 2010, 20:03 pm »

Gracias, por mi parte pueden cerrar el post
En línea

There is some fiction in you truth, and some truth in you fiction
anonimo12121


Desconectado Desconectado

Mensajes: 1.813


Ver Perfil WWW
Re: Problema con SDL
« Respuesta #5 en: 12 Octubre 2010, 13:25 pm »

Gracias, por mi parte pueden cerrar el post
pero lo mio te a valido?
En línea

Página para ganar Bitcoins y Dinero: http://earnbit.hol.es/
Video de YouTube con Hack para el LoL: http://adf.ly/5033746/youtube-lolemuhack
Si quieres ganar dinero con adfly entra y registrate aquí -> http://adf.ly/?id=5033746
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines