added "iv.xcolornames" module with some standard X11 color names
[iv.d.git] / skeletons / sdpygl_simple.d
blob28e2b2a4488f6036abb9f9f87e4e1bdb20d0e178
1 import arsd.color;
2 import arsd.simpledisplay;
4 //import iv.bclamp;
5 import iv.cmdcon;
6 import iv.cmdcongl;
9 // ////////////////////////////////////////////////////////////////////////// //
10 void main (string[] args) {
11 glconShowKey = "M-Grave";
13 conProcessQueue(); // load config
14 conProcessArgs!true(args);
16 // first time setup
17 oglSetupDG = delegate () {
18 // this will create texture
19 //gxResize(glconCtlWindow.width, glconCtlWindow.height);
22 // draw main screen
23 redrawFrameDG = delegate () {
24 oglSetup2D(glconCtlWindow.width, glconCtlWindow.height);
26 glMatrixMode(GL_PROJECTION);
27 glLoadIdentity();
28 glOrtho(0, /*winWidth*/100, /*winHeight*/100, 0, -1, 1); // set origin to top left
29 glMatrixMode(GL_MODELVIEW);
30 glLoadIdentity();
33 glClearColor(0, 0, 0, 0);
34 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
36 // scale everything
37 glMatrixMode(GL_MODELVIEW);
38 //glScalef(2, 2, 2);
40 glColor4f(1, 1, 1, 1);
41 glBegin(GL_LINES);
42 glVertex2f(10, 10);
43 glVertex2f(90, 90);
44 glEnd();
46 glColor4f(1, 1, 0, 0.8);
47 glEnable(GL_BLEND); // other things was set in `oglSetup2D()`
49 glPointSize(6);
50 glEnable(GL_POINT_SMOOTH); // so our point will be "smoothed" to circle
52 glLineWidth(2);
53 glDisable(GL_LINE_SMOOTH);
55 glBegin(GL_POINTS);
56 glVertex2f(30, 30);
57 glEnd();
60 // rebuild main screen (do any calculations we might need)
61 nextFrameDG = delegate () {
64 keyEventDG = delegate (KeyEvent event) {
65 if (!event.pressed) return;
66 switch (event.key) {
67 case Key.Escape: concmd("quit"); break;
68 default:
72 mouseEventDG = delegate (MouseEvent event) {
75 charEventDG = delegate (dchar ch) {
76 if (ch == 'q') { concmd("quit"); return; }
79 resizeEventDG = delegate (int wdt, int hgt) {
82 version(none) {
83 // this...
84 sdpyWindowClass = "SDPY WINDOW";
85 auto sdwin = new SimpleWindow(VBufWidth, VBufHeight, "My D App", OpenGlOptions.yes, Resizability.allowResizing);
86 //sdwin.hideCursor();
87 glconSetupForGLWindow(sdwin);
88 sdwin.eventLoop(0);
89 flushGui();
90 conProcessQueue(int.max/4);
91 } else {
92 // or this
93 glconRunGLWindowResizeable(1024, 768, "My D App", "SDPY WINDOW");