Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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.

C++
#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;
}
Posted
Updated 5-Jun-14 6:21am
v2
Comments
Stefan_Lang 6-Jun-14 3:24am    
What have you changed since the last time it worked?

The first line comment mentions 32 bit - could it be a 32/64 bit issue?
New_proder 6-Jun-14 3:51am    
I am pretty sure i haven't changed anything. i have a 64bit system. Sdl2 only works on a 32 bit compiler for me.

Does it work for you?
Stefan_Lang 6-Jun-14 9:06am    
In my experience, bugs happen after someone changed something. That wasn't a question, it was in implicit assumption.

Also in my experience, 'I am pretty sure I haven't' is synonymous to 'I have, but don't believe anything I changed is connected to the problem'. Think again. Bugs weren't hard to solve if they were obvious - and if they aren't obvious, you may as well have missed an obscure connection.

As for 32/64 bit - what your system is doesn't actually matter. It matters however whether your code was compiled for 32 or 64 bit, and whether other libs you use were compiled for 32 or 64 bit! If that setting doesn't match, all kind of problems can occur.

1 solution

Thanks stefan_lang for you perseverance. It looks like i changed the project.exe, to run on the GPU instead of the CPU.

As soon as i changed it back, it worked.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 9-Jun-14 10:48am    
How could it be an answer? And what is completely unclear: how could you possibly accept it as the solution? Such posts are considered as abuse. Please remove acceptance and don't do such things, to avoid abuse reports.
—SA
New_proder 12-Jun-14 1:49am    
What do you mean? i answered my own question after i was advised to check what was wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900