Zdar,
myslim ze som spravil viac-menej vsetko ako v seriali SDL ale nech sa snazim vykreslit cokolvek(pixel, bmp), nic sa nevykresli. Ostane len cierne SDL okno. Tu je kod pre vykreslenie bitmapy(ktory nefunguje):
#include "SDL/SDL.h"
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
using namespace std;
SDL_Surface *screen;
SDL_Surface *image;
#include "data/func.cpp"
void DrawScene(){
DrawIMG(image, 0, 0);
SDL_Flip(screen);
}
int main(int argc, char *argv[]){
if(SDL_Init(SDL_INIT_VIDEO) < 0){
cout << "Could not initialize SDL: " << SDL_GetError();
getch();
exit(1);
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
if (screen == NULL){
cout << "Could not initialize screen: " << SDL_GetError();
getch();
exit(1);
}
cout << "text"; //tento text sa ani nezobrazi v cmd okne
bool done=false;
while(done == false){
SDL_Event event;
while( SDL_PollEvent(&event) ){
if( event.type == SDL_QUIT ) done=true;
}
}
DrawScene();
}
func.cpp
void LoadImages(){
image = SDL_LoadBMP("/data/images/noimg.bmp");
}
void DrawIMG(SDL_Surface *img, int x, int y){
SDL_Rect rect;
rect.x = x;
rect.y = y;
SDL_BlitSurface(img, NULL, screen, &rect);
}