#include <SDL2/SDL.h>
#include "MCANV.h"
int main()
{
if (SDL_Init(SDL_INIT_EVERYTHING)!=0)
return -1;
SDL_Window *wnd=SDL_CreateWindow(
"KANKA TITLE MY",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
1280,
960,
SDL_WINDOW_SHOWN);
if (!wnd)
return -1;
SDL_Renderer *rdr=SDL_CreateRenderer(
wnd,
-1,
SDL_RENDERER_ACCELERATED|
SDL_RENDERER_PRESENTVSYNC);
if (!rdr)
return -1;
MCANVINFO mci={
.width=800,
.height=600,
.std_font=std_font,
};
MCANV *canv=MCANV_Alloc(&mci;);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,"1");
SDL_Texture *canv_txr=SDL_CreateTexture(
rdr,
SDL_PIXELFORMAT_ABGR8888,
SDL_TEXTUREACCESS_STREAMING,
canv->info.width,
canv->info.height);
if (!canv_txr)
return -1;
unsigned long freq=SDL_GetPerformanceFrequency();
unsigned long time0=0,time1=SDL_GetPerformanceCounter();
float dt=0.0f;
SDL_Event evnt;
bool done=false;
while (!done) {
time1=SDL_GetPerformanceCounter();
dt=(float)(time1-time0)/(float)freq;
time0=time1;
while (SDL_PollEvent(&evnt;)) {
if (evnt.type==SDL_QUIT)
done=true;
}
canv->color=STD_PALETTE_BLACK;
MCANV_Fill(canv);
canv->color=STD_PALETTE_YELLOW;
MCANV_PrintFmt(canv,
canv->info.width-14*STD_FONT_WIDTH,
canv->info.height-2*STD_FONT_HEIGHT,
"dt: %.4fnfps: %.3f",
dt,1.0f/dt);
SDL_UpdateTexture(canv_txr,NULL,canv->buff,canv->pitch);
SDL_RenderCopy(rdr,canv_txr,NULL,NULL);
SDL_RenderPresent(rdr);
}
MCANV_Free(canv);
SDL_DestroyTexture(canv_txr);
SDL_DestroyRenderer(rdr);
SDL_DestroyWindow(wnd);
SDL_Quit();
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}