News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Loading images problem(SDL 2.0)

Started by theatron, February 07, 2014, 12:09:32 AM

Previous topic - Next topic

theatron

Im tring to load an image and it doesnt work, it just has a black screen which is supposed to be there but nothing goes to it no matter if i switch up the order of SDL_RenderClear() and SDL_RenderCopy(), but the thing is the code seems like its correctt i dont even know now, im new at SDL 2.0 as you already know, but. i dont know how to fix this. im using codeblocks on windows 7. heres my code:

#include <SDL.h> #include <SDL_image.h> #include <iostream>

int main(int argc, char* args[]) { bool quit = false;

SDL_Init(SDL_INIT_VIDEO);

SDL_Window *window = NULL; SDL_Renderer *render = NULL; SDL_Event *evt = new SDL_Event(); text = IMG_LoadTexture(render, "player.png"); window = SDL_CreateWindow("SDL_PROJ", 100,100,800,600,SDL_WINDOW_SHOWN); render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); SDL_Rect txt_rect; txt_rect.x = 10; txt_rect.y = 10; txt_rect.w = 20; txt_rect.h = 10; while (!quit && evt->type != SDL_QUIT) {

SDL_PollEvent(evt); SDL_RenderClear(render); SDL_RenderCopy(render,text,NULL, &txt_rect); SDL_RenderPresent(render); } SDL_DestroyWindow(window); SDL_DestroyRenderer(render); delete evt; return 0; }}


Folco

Kernel Extremist - PedroM power ©