2 import arsd
.simpledisplay
;
9 // ////////////////////////////////////////////////////////////////////////// //
10 __gshared string optEditorFont
= "~/ttf/ms/arial.ttf:noaa";
11 __gshared
int optEditorFontSize
= 14;
12 __gshared NVGContext nvg
= null;
15 // ////////////////////////////////////////////////////////////////////////// //
16 void main (string
[] args
) {
17 glconShowKey
= "M-Grave";
19 conRegVar
!optEditorFont("ed_font_path", "path to TTF font");
20 conRegVar
!optEditorFontSize(6, 72, "ed_font_size", "editor font size");
22 conProcessQueue(); // load config
23 conProcessArgs
!true(args
);
27 oglSetupDG
= delegate () {
28 // create and upload texture, rebuild screen
29 nvg
= createGL2NVG(NVG_FONT_NOAA|NVG_ANTIALIAS|NVG_STENCIL_STROKES
/*|NVG_DEBUG*/);
30 if (nvg
is null) assert(0, "Could not init nanovg.");
31 nvg
.createFont("sans", optEditorFont
);
35 resizeEventDG
= delegate (int wdt
, int hgt
) {
40 redrawFrameDG
= delegate () {
42 glClearColor(0, 0, 0, 0);
43 glClear(glNVGClearFlags|GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT
);
44 glViewport(0, 0, glconCtlWindow
.width
, glconCtlWindow
.height
);
47 nvg
.beginFrame(glconCtlWindow
.width
, glconCtlWindow
.height
, 1);
50 nvg
.roundedRect(0, 0, glconCtlWindow
.width
, glconCtlWindow
.height
, 3);
51 nvg
.fillColor(nvgRGB(255, 127, 0));
54 nvg
.fontSize(optEditorFontSize
);
56 nvg
.textAlign(NVGTextAlign
.H
.Center
, NVGTextAlign
.V
.Middle
);
57 nvg
.fillColor(nvgRGB(0, 0, 255));
58 nvg
.text(glconCtlWindow
.width
/2, glconCtlWindow
.height
/2, "Hello! Двощер молодых");
65 // rebuild main screen (do any calculations we might need)
66 nextFrameDG
= delegate () {
70 keyEventDG
= delegate (KeyEvent event
) {
71 if (!event
.pressed
) return;
73 case Key
.Escape
: concmd("quit"); break;
78 mouseEventDG
= delegate (MouseEvent event
) {
81 charEventDG
= delegate (dchar ch
) {
82 if (ch
== 'q') { concmd("quit"); return; }
86 glconRunGLWindowResizeable(800, 600, "My D App", "SDPY WINDOW");
87 if (nvg
!is null) { nvg
.deleteGL2(); nvg
= null; }