So i have created this test app with examples found around the net. It works but there is a problem with the test image i'm using.
Here is complete code:
#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
int main(int argc, char* args[])
{
SDL_Surface *imageData = NULL;
SDL_Event event;
bool run = true;
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *mainWindow;
SDL_Renderer *mainRender;
mainWindow = SDL_CreateWindow("SDL_2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);
mainRender = SDL_CreateRenderer(mainWindow, -1, SDL_RENDERER_ACCELERATED);
imageData = IMG_Load("test.png");
while(run)
{
while(SDL_PollEvent(&event))
{
if(event.type == SDL_QUIT)
{
run = false;
}
}
imageData = SDL_CreateRGBSurfaceFrom((void*)imageData->pixels,
imageData->w,
imageData->h,
32,
imageData->pitch,
0xff0000, 0x00ff00, 0x0000ff, 0);
SDL_Texture *texture = SDL_CreateTextureFromSurface(mainRender, imageData);
SDL_RenderCopy(mainRender, texture, NULL, NULL);
SDL_RenderPresent(mainRender);
SDL_DestroyTexture(texture);
SDL_FreeSurface(imageData);
SDL_Delay(100);
}
SDL_FreeSurface(imageData);
SDL_DestroyRenderer(mainRender);
SDL_DestroyWindow(mainWindow);
SDL_Quit();
return 0;
}
Here is my test image:
http://i1153.photobucket.com/albums/p503/dbig17/test_zps0c7223a9.png
and here is how the program looks right now:
http://i1153.photobucket.com/albums/p503/dbig17/Untitled_zps3c3c782c.png
What am i doing wrong?