My code is to open a window.(SDK)(dev c++, orwell)
Instead of five seconds it takes a few milliseconds. Please help solve the problem. Just few day ago it worked but now ti does'nt.

#include "SDL.h"    //cool graphics API. Only works with 32 bit for me.
#include <stdio.h>

typedef struct      // what is typedef?
{
  int x, y;
  short life;
  char *name;
} Man;

int main(int a, char *b[])
{
  SDL_Window *window;                    // Declare a window      //these are structs
  SDL_Renderer *renderer;                // Declare a renderer

  SDL_Init(SDL_INIT_VIDEO);              // Initialize SDL2       //this is obviously a funtion

  //Create an application window with the following settings:
  window = SDL_CreateWindow("Ash First Window",                     // window title
                            SDL_WINDOWPOS_UNDEFINED,           // initial x position
                            SDL_WINDOWPOS_UNDEFINED,           // initial y position
                            640,                               // width, in pixels
                            480,                               // height, in pixels
                            0                                  // flags
 );

renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

//set the drawing color to blue
  SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);

  //Clear the screen (to blue)
  SDL_RenderClear(renderer);

  //set the drawing color to white
  SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);

  SDL_Rect rect = { 220, 140, 200, 200 };
  SDL_RenderFillRect(renderer, &rect);

  //We are done drawing, "present" or show to the screen what we've drawn
  SDL_RenderPresent(renderer);


  SDL_Delay(5000);



  // Close and destroy the window
  SDL_DestroyWindow(window);
  SDL_DestroyRenderer(renderer);

  // Clean up
  SDL_Quit();
  return 0;
}

Recommended Answers

All 2 Replies

where did you get sdl.h from?

commented: it is an api +0

the problem was that i was running the file on my gpu instead of my cpu. SDl_delay, probally does not work with the gpu.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.