历史公交车吧 关注:869贴子:15,549
  • 4回复贴,共1

一个帖庆祝我的第一个SDL黑窗

取消只看楼主收藏回复

由于我一直记不住SDL的结构体类型名
和函数
我助记一下的
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
int main(int,char**){
SDL_Renderer*renderer;
SDL_Window*win=NULL;
SDL_Surface*hello=NULL;
SDL_Surface*world=NULL;
SDL_Init(SDL_INIT_EVERYTHING);
win=SDL_CreateWindow("myhw",0,0,400,500,0);
hello=IMG_Load("/sdcard/DCIM/ 6.jpg");
SDL_FreeSurface(hello);
SDL_Delay(2000);
SDL_Quit();
return 0;
}


来自Android客户端1楼2016-05-28 17:15回复
    @中华星尊


    来自Android客户端3楼2016-05-28 17:16
    回复
      @儒雅的亮迷


      来自Android客户端5楼2016-05-28 17:26
      回复
        @中华星尊
        结构体有些烦
        比如
        typedef struct people{
        char*name;
        int funny;
        int number;
        struct people*this_t;
        }p;
        int main(int argv,char*args[]){
        p bjgt,*hj;
        hj=&bjgt;
        hj->this_t=&bjgt;
        hj->this_t->name="烦人";
        hj->this_t->funny=100;
        return 0;
        }


        来自Android客户端8楼2016-05-28 20:04
        收起回复
          第二版
          终于学会输出图片了
          不再是黑窗
          #include <SDL2/SDL.h>
          #include<SDL2/SDL_image.h>
          int main(int,char**){
          SDL_Window*win=NULL;
          SDL_Surface*Surface=NULL;
          SDL_Texture*Texture=NULL;
          SDL_Renderer*r=NULL;
          SDL_Init(SDL_INIT_EVERYTHING);
          win=SDL_CreateWindow("六",0,0,400,600,0);
          Surface=IMG_Load("/sdcard/hello.jpg");
          r=SDL_CreateRenderer(win,-1,SDL_RENDERER_ACCELERATED);
          Texture=
          SDL_CreateTextureFromSurface(r,
          Surface);
          SDL_FreeSurface(Surface);
          SDL_RenderClear(r);
          SDL_RenderCopy(r,Texture,NULL,
          NULL);
          SDL_RenderPresent(r);
          SDL_Delay(3000);
          SDL_DestroyTexture(Texture);
          SDL_DestroyRenderer(r);
          SDL_DestroyWindow(win);
          return 0;
          }


          来自Android客户端14楼2016-05-28 22:22
          收起回复