code to check POP3 accounts; let's do some testing now! ;-)
[chiroptera.git] / egfx / backx11.d
blob4893e47c6892fbbf135b84c4ad14a76413600cc9
1 /* E-Mail Client
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module egfx.backx11 /*is aliced*/;
18 private:
20 import arsd.simpledisplay;
22 import iv.alice;
23 import iv.cmdcon;
24 import iv.cmdcongl;
26 import egfx.config;
27 import egfx.base;
30 // ////////////////////////////////////////////////////////////////////////// //
31 public __gshared uint vArrowTextureId = 0;
32 //public __gshared Image egx11img;
35 // ////////////////////////////////////////////////////////////////////////// //
36 shared static this () {
37 import core.stdc.stdlib : malloc;
38 vglTexBuf = cast(uint*)malloc((VBufWidth*VBufHeight+4)*4);
39 if (vglTexBuf is null) { import core.exception : onOutOfMemoryErrorNoGC; onOutOfMemoryErrorNoGC(); }
40 vglTexBuf[0..VBufWidth*VBufHeight] = 0;
44 // ////////////////////////////////////////////////////////////////////////// //
46 private extern(C) nothrow @trusted @nogc {
47 import core.stdc.config : c_long, c_ulong;
49 XImage* egfx_backx11_xxsimple_create_image (XDisplay* display, Visual* visual, uint depth, int format, int offset, ubyte* data, uint width, uint height, int bitmap_pad, int bytes_per_line) {
50 //return XCreateImage(display, visual, depth, format, offset, data, width, height, bitmap_pad, bytes_per_line);
51 return null;
54 int egfx_backx11_xxsimple_destroy_image (XImage* ximg) {
55 ximg.data = null;
56 ximg.width = ximg.height = 0;
57 return 0;
60 c_ulong egfx_backx11_xxsimple_get_pixel (XImage* ximg, int x, int y) {
61 if (ximg.data is null) return 0;
62 if (x < 0 || y < 0 || x >= ximg.width || y >= ximg.height) return 0;
63 auto buf = cast(const(uint)*)ximg.data;
64 //uint v = buf[y*ximg.width+x];
65 //v = (v&0xff_00ff00u)|((v>>16)&0x00_0000ffu)|((v<<16)&0x00_ff0000u);
66 return buf[y*ximg.width+x];
69 int egfx_backx11_xxsimple_put_pixel (XImage* ximg, int x, int y, c_ulong clr) {
70 return 0;
73 XImage* egfx_backx11_xxsimple_sub_image (XImage* ximg, int x, int y, uint wdt, uint hgt) {
74 return null;
77 int egfx_backx11_xxsimple_add_pixel (XImage* ximg, c_long clr) {
78 return 0;
81 // create "simple" XImage with allocated buffer
82 void egfx_backx11_ximageInitSimple (ref XImage handle, int width, int height, void* data) {
83 handle.width = width;
84 handle.height = height;
85 handle.xoffset = 0;
86 handle.format = ImageFormat.ZPixmap;
87 handle.data = data;
88 handle.byte_order = 0;
89 handle.bitmap_unit = 0;
90 handle.bitmap_bit_order = 0;
91 handle.bitmap_pad = 0;
92 handle.depth = 24;
93 handle.bytes_per_line = 0;
94 handle.bits_per_pixel = 0; // THIS MATTERS!
95 handle.red_mask = 0;
96 handle.green_mask = 0;
97 handle.blue_mask = 0;
99 handle.obdata = null;
100 handle.f.create_image = &egfx_backx11_xxsimple_create_image;
101 handle.f.destroy_image = &egfx_backx11_xxsimple_destroy_image;
102 handle.f.get_pixel = &egfx_backx11_xxsimple_get_pixel;
103 handle.f.put_pixel = &egfx_backx11_xxsimple_put_pixel;
104 handle.f.sub_image = &egfx_backx11_xxsimple_sub_image;
105 handle.f.add_pixel = &egfx_backx11_xxsimple_add_pixel;
111 // ////////////////////////////////////////////////////////////////////////// //
112 public void vglCreateArrowTexture () {
116 // ////////////////////////////////////////////////////////////////////////// //
117 public void vglBlitArrow (int px, int py) {
121 // ////////////////////////////////////////////////////////////////////////// //
122 // resize buffer, reinitialize OpenGL texture
123 public void vglResizeBuffer (int wdt, int hgt, int ascale=1) {
124 if (wdt < 1) wdt = 1;
125 if (hgt < 1) hgt = 1;
127 if (wdt > 8192) wdt = 8192;
128 if (hgt > 8192) hgt = 8192;
130 bool sizeChanged = (wdt != VBufWidth || hgt != VBufHeight);
131 VBufWidth = wdt;
132 VBufHeight = hgt;
134 if (vglTexBuf is null || sizeChanged) {
135 import core.stdc.stdlib : realloc;
136 vglTexBuf = cast(uint*)realloc(vglTexBuf, (VBufWidth*VBufHeight+4)*vglTexBuf[0].sizeof);
137 if (vglTexBuf is null) { import core.exception : onOutOfMemoryErrorNoGC; onOutOfMemoryErrorNoGC(); }
138 vglTexBuf[0..VBufWidth*VBufHeight] = 0;
141 if (ascale < 1) ascale = 1;
142 if (ascale > 32) ascale = 32;
143 vbufEffScale = cast(ubyte)ascale;
146 if (egx11img is null || egx11img.width != VBufWidth || egx11img.height != VBufHeight) {
147 egx11img = new Image(VBufWidth, VBufHeight);
148 //glconBackBuffer = egx11img;
154 // ////////////////////////////////////////////////////////////////////////// //
155 public void vglUpdateTexture () {
157 if (vglTexBuf is null) return;
158 if (egx11img is null || egx11img.width != VBufWidth || egx11img.height != VBufHeight) {
159 egx11img = new Image(VBufWidth, VBufHeight);
160 glconBackBuffer = egx11img;
164 if (egx11img !is null && vglTexBuf !is null) {
165 int bmpw = egx11img.width;
166 int bmph = egx11img.height;
167 int copyw = (bmpw < VBufWidth ? bmpw : VBufWidth);
168 if (bmph > VBufHeight) bmph = VBufHeight;
169 const(uint)* src = cast(const(uint)*)vglTexBuf;
170 uint* dest = cast(uint*)egx11img.getDataPointer;
171 while (bmph-- > 0) {
172 import core.stdc.string : memcpy;
173 memcpy(dest, src, copyw*4);
174 src += VBufWidth;
175 dest += bmpw;
182 // ////////////////////////////////////////////////////////////////////////// //
184 extern(C) nothrow @trusted @nogc {
185 Status XInitImage (XImage* image);
190 public void vglBlitTexture (SimpleWindow w) {
191 if (w !is null && !w.closed) {
192 XImage ximg;
193 //egfx_backx11_ximageInitSimple(ximg, VBufWidth, VBufHeight, vglTexBuf);
195 ximg.width = VBufWidth;
196 ximg.height = VBufHeight;
197 ximg.xoffset = 0;
198 ximg.format = ImageFormat.ZPixmap;
199 ximg.data = vglTexBuf;
200 ximg.byte_order = 0;
201 ximg.bitmap_unit = 32;
202 ximg.bitmap_bit_order = 0;
203 ximg.bitmap_pad = 8;
204 ximg.depth = 24;
205 ximg.bytes_per_line = 0;
206 ximg.bits_per_pixel = 32; // THIS MATTERS!
207 ximg.red_mask = 0x00ff0000;
208 ximg.green_mask = 0x0000ff00;
209 ximg.blue_mask = 0x000000ff;
210 XInitImage(&ximg);
212 XPutImage(w.impl.display, cast(Drawable)w.impl.buffer, w.impl.gc, &ximg, 0, 0, 0/*destx*/, 0/*desty*/, VBufWidth, VBufHeight);