本文介绍了SDL_Delay();执行得太快了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是打开一个窗口。(SDK)(dev c ++,orwell)

而不是五秒,它需要几毫秒。请帮忙解决问题。就在几天前,它工作但现在没有。



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;
}

推荐答案


这篇关于SDL_Delay();执行得太快了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 23:49