Author Topic: Loading images problem(SDL 2.0)  (Read 7875 times)

Offline theatron

  • Single posting newcomer
  • *
  • Posts: 2
Loading images problem(SDL 2.0)
« on: February 07, 2014, 12:09:32 am »
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; }}

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352

Offline Folco

  • Regular
  • ***
  • Posts: 343
    • Folco's blog (68k lover)
Re: Loading images problem(SDL 2.0)
« Reply #2 on: February 08, 2014, 09:48:51 am »
The right forum for your problem is here : http://forums.libsdl.org/
Kernel Extremist - PedroM power ©