946 Aufrufe
Gefragt in Anwendungen(Java,C++...) von
Hi Leute,

hat jemand von euch ne Ahnung wie ich SDL unter Borland Turbo C++ (Borland 6) zum laufen bekomme? Ich weiß, dass die *lib* ne andere is als die *lib* von VC++. Dort läuft das Programm reibungslos mit folgendem Quelltext:

#include <SDL/SDL.h> /* All SDL App's need this */
#include <stdio.h>

#pragma once

#pragma comment(lib,"SDL")
#pragma comment(lib,"SDLmain")

#ifdef _WIN32
#undef main
#endif

void display_bmp(char *file_name);

int main(int argc, char *argv[]) {
SDL_Surface *screen;

/* Initialize the SDL library */
if( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr,
"Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}

/* Clean up on exit */
atexit(SDL_Quit);

/* Have a preference for 8-bit, but accept any depth */
screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE|SDL_ANYFORMAT);
if ( screen == NULL ) {
fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
SDL_GetError());
exit(1);
}
display_bmp("C:\Dokumente und Einstellungen\All Users\Dokumente\Eigene Bilder\Beispielbilder\Blaue Berge.bpm");
SDL_Quit();
return 0;
}

void display_bmp(char *file_name)
{
SDL_Surface *image;
SDL_Surface *screen;

/* Load the BMP file into a surface */
image = SDL_LoadBMP(file_name);
if (image == NULL) {
fprintf(stderr, "Couldn't load %s: %s\n", file_name, SDL_GetError());
return;
}

/*
* Palettized screen modes will have a default palette (a standard
* 8*8*4 colour cube), but if the image is palettized as well we can
* use that palette for a nicer colour matching
*/
if (image->format->palette && screen->format->palette) {
SDL_SetColors(screen, image->format->palette->colors, 0,
image->format->palette->ncolors);
}

/* Blit onto the screen surface */
if(SDL_BlitSurface(image, NULL, screen, NULL) < 0)
fprintf(stderr, "BlitSurface error: %s\n", SDL_GetError());

SDL_UpdateRect(screen, 0, 0, image->w, image->h);

/* Free the allocated BMP surface */
SDL_FreeSurface(image);
}

selber quellcode funktioniert nicht unter borland. könnt ihr mir helfen?

Deine Antwort

Dein angezeigter Name (optional):
Datenschutz: Deine Email-Adresse benutzen wir ausschließlich, um dir Benachrichtigungen zu schicken. Es gilt unsere Datenschutzerklärung.
Anti-Spam-Captcha:
Bitte logge dich ein oder melde dich neu an, um das Anti-Spam-Captcha zu vermeiden.
...