1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#ifdef __cplusplus
#include <cstdlib>
#else
#include <stdlib.h>
#endif
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <string>
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
SDL_Window* window = NULL;
int width = 640,
height = 480,
widthBD = width,
heightBD = 48;
SDL_Surface* border = NULL;
SDL_Texture* tex = NULL;
SDL_Renderer* renderer = NULL;
SDL_Rect rect;
int main ( int argc, char** argv )
{
window = SDL_CreateWindow("My Own Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED
,width ,height ,SDL_WINDOW_SHOWN|SDL_WINDOW_BORDERLESS);
border = SDL_CreateRGBSurface(0, widthBD, heightBD, 32,
rmask, gmask, bmask, amask);
renderer = SDL_CreateRenderer(window, -1, 0);
tex = SDL_CreateTextureFromSurface(renderer, border);
rect.x = 0;
rect.y = 0;
rect.w = widthBD;
rect.h = heightBD;
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, tex, NULL, &rect);
SDL_RenderPresent(renderer);
SDL_Delay(2000);
return 0;
}
|