GLES2

Check-in [ebb74a58ae]
Login

Check-in [ebb74a58ae]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:new commands value2pixel and getdiamondpositions
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ebb74a58ae0a9b2fb4696ee5da65a83d175f33e9
User & Date: arnulf 2013-08-18 15:02:35.615
Context
2013-08-18
21:50
fixes check-in: 21185d0470 user: arnulf tags: trunk
15:02
new commands value2pixel and getdiamondpositions check-in: ebb74a58ae user: arnulf tags: trunk
2013-08-12
12:26
fixes and new code check-in: 207683acc1 user: arnulf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/gles2Builtin.c.
33
34
35
36
37
38
39

40
41

42
43
44
45
46
47
48
static Tcl_ObjCmdProc Gles2_BiDrawTextureRectangleCmd;
static Tcl_ObjCmdProc Gles2_BiSetupRenderBufferCmd;
static Tcl_ObjCmdProc Gles2_BiSetupFrameBufferCmd;
static Tcl_ObjCmdProc Gles2_BiCompileShadersCmd;
static Tcl_ObjCmdProc Gles2_BiGetFontInfoCmd;
static Tcl_ObjCmdProc Gles2_BiMakeTextTextureCmd;
static Tcl_ObjCmdProc Gles2_BiPixel2CoordCmd;

static Tcl_ObjCmdProc Gles2_BiColorValue2RGBACmd;
static Tcl_ObjCmdProc Gles2_BiGetElementPositionsCmd;

static Tcl_ObjCmdProc Gles2_BiGetShadowsCmd;
static Tcl_ObjCmdProc Gles2_BiSwapShadersCmd;

/*
 *  Standard list of built-in methods for all objects.
 */
typedef struct BiMethod {







>


>







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
static Tcl_ObjCmdProc Gles2_BiDrawTextureRectangleCmd;
static Tcl_ObjCmdProc Gles2_BiSetupRenderBufferCmd;
static Tcl_ObjCmdProc Gles2_BiSetupFrameBufferCmd;
static Tcl_ObjCmdProc Gles2_BiCompileShadersCmd;
static Tcl_ObjCmdProc Gles2_BiGetFontInfoCmd;
static Tcl_ObjCmdProc Gles2_BiMakeTextTextureCmd;
static Tcl_ObjCmdProc Gles2_BiPixel2CoordCmd;
static Tcl_ObjCmdProc Gles2_BiValue2PixelCmd;
static Tcl_ObjCmdProc Gles2_BiColorValue2RGBACmd;
static Tcl_ObjCmdProc Gles2_BiGetElementPositionsCmd;
static Tcl_ObjCmdProc Gles2_BiGetDiamondPositionsCmd;
static Tcl_ObjCmdProc Gles2_BiGetShadowsCmd;
static Tcl_ObjCmdProc Gles2_BiSwapShadersCmd;

/*
 *  Standard list of built-in methods for all objects.
 */
typedef struct BiMethod {
151
152
153
154
155
156
157






158
159
160
161
162
163
164
165
166
167
168
169






170
171
172
173
174
175
176
	0
    },
    { "pixel2coord",
        "",
        "@gles2-builtin-pixel2coord",
        Gles2_BiPixel2CoordCmd,
	0






    },
    { "colorvalue2rgba",
        "",
        "@gles2-builtin-colorvalue2rgba",
        Gles2_BiColorValue2RGBACmd,
	0
    },
    { "getelementpositions",
        "",
        "@gles2-builtin-getelementpositions",
        Gles2_BiGetElementPositionsCmd,
	0






    },
    { "getshadows",
        "",
        "@gles2-builtin-getshadows",
        Gles2_BiGetShadowsCmd,
	0
    },







>
>
>
>
>
>












>
>
>
>
>
>







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
	0
    },
    { "pixel2coord",
        "",
        "@gles2-builtin-pixel2coord",
        Gles2_BiPixel2CoordCmd,
	0
    },
    { "value2pixel",
        "",
        "@gles2-builtin-value2pixel",
        Gles2_BiValue2PixelCmd,
	0
    },
    { "colorvalue2rgba",
        "",
        "@gles2-builtin-colorvalue2rgba",
        Gles2_BiColorValue2RGBACmd,
	0
    },
    { "getelementpositions",
        "",
        "@gles2-builtin-getelementpositions",
        Gles2_BiGetElementPositionsCmd,
	0
    },
    { "getdiamondpositions",
        "",
        "@gles2-builtin-getdiamondpositions",
        Gles2_BiGetDiamondPositionsCmd,
	0
    },
    { "getshadows",
        "",
        "@gles2-builtin-getshadows",
        Gles2_BiGetShadowsCmd,
	0
    },
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
	    }
            cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	    cmd_objv[0] = cmd_obj;
	    if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
                exit(1);
	    }
fprintf(stderr, "obj!%s!\n", Tcl_GetString(obj));
            if (Tcl_EvalObjEx(interp, obj, 0) != TCL_OK) {
fprintf(stderr, "VerticalBevel: error in executing fillrectangle command:%s\n", Tcl_GetStringResult(interp));
                exit(1);
	    }
        } else {
#ifdef NOTDEF
            if (strcmp(relief, "ridge") == =) {







<







412
413
414
415
416
417
418

419
420
421
422
423
424
425
	    }
            cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	    cmd_objv[0] = cmd_obj;
	    if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
                exit(1);
	    }

            if (Tcl_EvalObjEx(interp, obj, 0) != TCL_OK) {
fprintf(stderr, "VerticalBevel: error in executing fillrectangle command:%s\n", Tcl_GetStringResult(interp));
                exit(1);
	    }
        } else {
#ifdef NOTDEF
            if (strcmp(relief, "ridge") == =) {
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
	    }
            cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	    cmd_objv[0] = cmd_obj;
	    if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
                 exit(1);
	    }
fprintf(stderr, "obj!%s!\n", Tcl_GetString(obj));
            if (Tcl_EvalObjEx(interp, obj, 0) != TCL_OK) {
fprintf(stderr, "VerticalBevel: error in executing fillrectangle command:%s\n", Tcl_GetStringResult(interp));
                exit(1);
	     }
         }
         x1 += x1Delta;
         x2 += x2Delta;







<







566
567
568
569
570
571
572

573
574
575
576
577
578
579
	    }
            cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	    cmd_objv[0] = cmd_obj;
	    if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
                 exit(1);
	    }

            if (Tcl_EvalObjEx(interp, obj, 0) != TCL_OK) {
fprintf(stderr, "VerticalBevel: error in executing fillrectangle command:%s\n", Tcl_GetStringResult(interp));
                exit(1);
	     }
         }
         x1 += x1Delta;
         x2 += x2Delta;
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
    int i;

    /*
     *  "::itcl::builtin" commands.
     *  These commands are imported into each class
     *  just before the class definition is parsed.
     */
fprintf(stderr, "Gles2_BiInit\n");
    Tcl_DStringInit(&buffer);
    for (i=0; i < BiMethodListLen; i++) {
	Tcl_DStringSetLength(&buffer, 0);
	Tcl_DStringAppend(&buffer, "::gles2::builtin::", -1);
	Tcl_DStringAppend(&buffer, BiMethodList[i].name, -1);
fprintf(stderr, "CMD!%s!\n", Tcl_DStringValue(&buffer));
        Tcl_CreateObjCommand(interp, Tcl_DStringValue(&buffer),
	        BiMethodList[i].proc, NULL,
		(Tcl_CmdDeleteProc*)NULL);
    }
    Tcl_DStringFree(&buffer);

    gles2BiNs = Tcl_FindNamespace(interp, "::gles2::builtin",







|





<







603
604
605
606
607
608
609
610
611
612
613
614
615

616
617
618
619
620
621
622
    int i;

    /*
     *  "::itcl::builtin" commands.
     *  These commands are imported into each class
     *  just before the class definition is parsed.
     */
//fprintf(stderr, "Gles2_BiInit\n");
    Tcl_DStringInit(&buffer);
    for (i=0; i < BiMethodListLen; i++) {
	Tcl_DStringSetLength(&buffer, 0);
	Tcl_DStringAppend(&buffer, "::gles2::builtin::", -1);
	Tcl_DStringAppend(&buffer, BiMethodList[i].name, -1);

        Tcl_CreateObjCommand(interp, Tcl_DStringValue(&buffer),
	        BiMethodList[i].proc, NULL,
		(Tcl_CmdDeleteProc*)NULL);
    }
    Tcl_DStringFree(&buffer);

    gles2BiNs = Tcl_FindNamespace(interp, "::gles2::builtin",
1766
1767
1768
1769
1770
1771
1772





























1773
1774
1775
1776
1777
1778
1779
fprintf(stderr, "bad value for useWidth!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    glValue = Pixel2Coord(interp, value, useWidth);
    Tcl_SetObjResult(interp, Tcl_ObjPrintf("%.3f", glValue));
    return result;
}






























/*
 * ------------------------------------------------------------------------
 *  Gles2_BiColorValue2RGBACmd()
 *
 *  Invoked to handle the "colorvalue2rgba" command
 *  Handles the







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
fprintf(stderr, "bad value for useWidth!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    glValue = Pixel2Coord(interp, value, useWidth);
    Tcl_SetObjResult(interp, Tcl_ObjPrintf("%.3f", glValue));
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiValue2PixelCmd()
 *
 *  Invoked to handle the "value2pixel" command
 *  Handles the
 *  following syntax:
 *
 *    value2pixel value
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiValue2PixelCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    GLfloat glValue;

    Gles2ShowArgs(0, "Gles_BiValue2PixelCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "value");
        return TCL_ERROR;
    }
    return Value2Pixel(interp, objv[1]);
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiColorValue2RGBACmd()
 *
 *  Invoked to handle the "colorvalue2rgba" command
 *  Handles the
1832
1833
1834
1835
1836
1837
1838








































1839
1840
1841
1842
1843
1844
1845
        Tcl_WrongNumArgs(interp, 1, objv, "box");
        return TCL_ERROR;
    }
    obj = GetElementPositions(interp, objv[1]);
fprintf(stderr, "OBJ!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;








































    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

/*
 * ------------------------------------------------------------------------







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
        Tcl_WrongNumArgs(interp, 1, objv, "box");
        return TCL_ERROR;
    }
    obj = GetElementPositions(interp, objv[1]);
fprintf(stderr, "OBJ!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiGetDiamondPositionsCmd()
 *
 *  Invoked to handle the "getdiamondpositions" command
 *  Handles the
 *  following syntax:
 *
 *    getdiamondpositions value diameter
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiGetDiamondPositionsCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;
    int diameter;

    Gles2ShowArgs(0, "Gles_BiGetDiamondPositionsCmd", objc, objv);
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "box diameter");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[2], &diameter) != TCL_OK) {
fprintf(stderr, "bad value for diameter!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    obj = GetDiamondPositions(interp, objv[1], diameter);
fprintf(stderr, "OBJ!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

/*
 * ------------------------------------------------------------------------
Changes to generic/gles2Helpers.c.
1
2
3
4
5
6
7
8
9






10



11


12
13
14
15
16
17
18
/*
 * gles2Helpers.c --
 *
 * Copyright (c) 2013 by Arnulf P. Wiedemann
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */







#include <tcl.h>



#include "gles2Int.h"



#ifdef GLES2_DEBUG
int _gles2_debug_level = 0;

/*
 * ------------------------------------------------------------------------
 *  Gles2ShowArgs()









>
>
>
>
>
>

>
>
>

>
>







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
/*
 * gles2Helpers.c --
 *
 * Copyright (c) 2013 by Arnulf P. Wiedemann
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#ifdef HAVE_SYS_TYPES_H
#    include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#    include <sys/param.h>
#endif
#include <tcl.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "gles2Int.h"

#define UCHAR(c) ((unsigned char) (c))

#ifdef GLES2_DEBUG
int _gles2_debug_level = 0;

/*
 * ------------------------------------------------------------------------
 *  Gles2ShowArgs()
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305








































































306
307
308
309
310
311
312
    rgba->Color[3] = (GLubyte)(dbl * 255);
fprintf(stderr, "r:%d!g:%d!b:%d!@:%d!\n", rgba->Color[0], rgba->Color[1], rgba->Color[2], rgba->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  Pixel2Coor()
 *
 *  the width or height depending on the ui size is delivered
 * ------------------------------------------------------------------------
 */

GLfloat
Pixel2Coord(
    Tcl_Interp *interp,      /* current interpreter */
    int pixels,              /* width or height in pixels */
    int useWidth)            /* whether to use width or height */
{
    if (useWidth) {
        return pixels * 4.0 / uiWidth;
    } else {
        return pixels * 4.0 / uiHeight;
    }
}









































































/*
 * ------------------------------------------------------------------------
 *  ColorValue2RGBA()
 *
 *  convert a color value like #d9d9d9 to a rgba list of values
 * ------------------------------------------------------------------------







|

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
    rgba->Color[3] = (GLubyte)(dbl * 255);
fprintf(stderr, "r:%d!g:%d!b:%d!@:%d!\n", rgba->Color[0], rgba->Color[1], rgba->Color[2], rgba->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  Pixel2Coord()
 *
 *  the width or height depending on the ui size is delivered
 * ------------------------------------------------------------------------
 */

GLfloat
Pixel2Coord(
    Tcl_Interp *interp,      /* current interpreter */
    int pixels,              /* width or height in pixels */
    int useWidth)            /* whether to use width or height */
{
    if (useWidth) {
        return pixels * 4.0 / uiWidth;
    } else {
        return pixels * 4.0 / uiHeight;
    }
}

/*
 * ------------------------------------------------------------------------
 *  Value2Pixel()
 *
 *  the width or height depending on the ui size is delivered
 * ------------------------------------------------------------------------
 */

int
Value2Pixel(
    Tcl_Interp *interp,      /* current interpreter */
    Tcl_Obj *obj)            /* value */
{
    const char *string;
    char *rest;
    double d;
    int i;
    int units;
    GLfloat value = 0.0;
    static const double bias[] = {
        10.0,   25.4,   1.0,    0.35278 /*25.4 / 72.0*/
    };



    string = Tcl_GetString(obj);

    d = strtod(string, &rest);
    if (rest == string) {
        goto error;
    }
    while ((*rest != '\0') && isspace(UCHAR(*rest))) {
        rest++;
    }

    switch (*rest) {
    case '\0':
        units = -1;
        break;
    case 'm':
        units = 0;
        break;
    case 'c':
        units = 1;
        break;
    case 'i':
        units = 2;
        break;
    case 'p':
        units = 3;
        break;
    default:
        goto error;
    }
    i = (int) d;
    if ((units < 0) && (i == d)) {
        value = d;
    } else {
        value /= bias[units];
    }
    Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
    return TCL_OK;

  error:
    if (interp != NULL) {
        Tcl_SetObjResult(interp, Tcl_ObjPrintf(
            "bad screen distance \"%.50s\"", string));
        Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL);
    }
    return TCL_ERROR;
}

/*
 * ------------------------------------------------------------------------
 *  ColorValue2RGBA()
 *
 *  convert a color value like #d9d9d9 to a rgba list of values
 * ------------------------------------------------------------------------
553
554
555
556
557
558
559


















































































































































560
561
562
563
564
565
566
fprintf(stderr, "GetElementPositions could not append z value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetElementPositions could not append  pos4 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }



















































































































































    return listObj;
}

/*
 *
 * ------------------------------------------------------------------------







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
fprintf(stderr, "GetElementPositions could not append z value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetElementPositions could not append  pos4 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    return listObj;
}

/*
 *
 * ------------------------------------------------------------------------
 *  GetDiamondPositions()
 *
 *  convert a parcel coordinates to graphics context positions
 * ------------------------------------------------------------------------
 */

Tcl_Obj *
GetDiamondPositions(
    Tcl_Interp *interp,      /* current interpreter */
    Tcl_Obj *obj,            /* value to convert */
    int diameter)            /* diameter of diamond */
{
    int pos_objc;
    Tcl_Obj **pos_objv;
    Tcl_Obj *listObj;
    Tcl_Obj *list1Obj;
    int x;
    int y;
    int width;
    int height;
    GLfloat f_x;
    GLfloat f_y;
    GLfloat f_z;
    GLfloat f_width;
    GLfloat f_height;
    GLfloat radius;
    GLfloat w_radius;
    GLfloat h_radius;

    radius = diameter / 2.0;
    w_radius = Pixel2Coord(interp, radius, 1);
    h_radius = Pixel2Coord(interp, radius, 0);
    if (Tcl_ListObjGetElements(interp, obj, &pos_objc, &pos_objv) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions: bad input format: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    f_z = 1.0;
    /* x */
    if (Tcl_GetIntFromObj(interp, pos_objv[0], &x) != TCL_OK) {
fprintf(stderr, "bad value for x!%s!\n", Tcl_GetString(pos_objv[0]));
        return NULL;
    }
    f_x = Pixel2Coord(interp, x, 1);
    /* y */
    if (Tcl_GetIntFromObj(interp, pos_objv[1], &y) != TCL_OK) {
fprintf(stderr, "bad value for y!%s!\n", Tcl_GetString(pos_objv[1]));
        return NULL;
    }
    f_y = Pixel2Coord(interp, y, 0);
    /* width */
    if (Tcl_GetIntFromObj(interp, pos_objv[2], &width) != TCL_OK) {
fprintf(stderr, "bad value for width!%s!\n", Tcl_GetString(pos_objv[2]));
        return NULL;
    }
    f_width = Pixel2Coord(interp, width, 1);
fprintf(stderr, "RADIUS!%f!%f!%f!\n", w_radius, h_radius, f_width);
    /* height */
    if (Tcl_GetIntFromObj(interp, pos_objv[3], &height) != TCL_OK) {
fprintf(stderr, "bad value for height!%s!\n", Tcl_GetString(pos_objv[3]));
        return NULL;
    }
    f_height = Pixel2Coord(interp, height, 0);
    listObj = Tcl_NewListObj(0, NULL); /* the return obj */

    /* pos1 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_x)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append x value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_y + h_radius)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append y value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_z)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append z value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append  pos1 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* pos2 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_x + w_radius)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append x value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_y + 2*h_radius)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append y value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_z)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append z value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append  pos2 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* pos3 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_x + 2*w_radius)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append x value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_y + h_radius)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append y value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_z)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append z value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append  pos3 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* pos4 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_x + w_radius)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append x value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_y)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append y value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_z)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append z value: %s\n", Tcl_GetString(obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append  pos4 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    return listObj;
}

/*
 *
 * ------------------------------------------------------------------------
Changes to generic/gles2Int.h.
60
61
62
63
64
65
66

67
68

69
70
MODULE_SCOPE int Gles2_GetFreeTypeInfo(Tcl_Interp *interp,
        Gles2WidgetImageInfo *infoPtr, const char *fontName, int fontSize,
        RgbaInfo *rgbaPtr, Tcl_Obj *textPtr, Gles2WidgetImage *wgtPtr,
        int measureOnly);
MODULE_SCOPE int Gles2_GetFreeTypeOffsetMap(Tcl_Interp *interp,
        Gles2WidgetImage *wgtPtr, Tcl_Obj *listPtr);
MODULE_SCOPE GLfloat Pixel2Coord(Tcl_Interp *interp, int pixels, int useWidth);

MODULE_SCOPE Tcl_Obj * ColorValue2RGBA(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * GetElementPositions(Tcl_Interp *interp, Tcl_Obj *obj);

MODULE_SCOPE Tcl_Obj * GetShadows(Tcl_Interp *interp, Tcl_Obj *backgroundColorObj);








>


>


60
61
62
63
64
65
66
67
68
69
70
71
72
MODULE_SCOPE int Gles2_GetFreeTypeInfo(Tcl_Interp *interp,
        Gles2WidgetImageInfo *infoPtr, const char *fontName, int fontSize,
        RgbaInfo *rgbaPtr, Tcl_Obj *textPtr, Gles2WidgetImage *wgtPtr,
        int measureOnly);
MODULE_SCOPE int Gles2_GetFreeTypeOffsetMap(Tcl_Interp *interp,
        Gles2WidgetImage *wgtPtr, Tcl_Obj *listPtr);
MODULE_SCOPE GLfloat Pixel2Coord(Tcl_Interp *interp, int pixels, int useWidth);
MODULE_SCOPE int Value2Pixel(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * ColorValue2RGBA(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * GetElementPositions(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * GetDiamondPositions(Tcl_Interp *interp, Tcl_Obj *obj, int diameter);
MODULE_SCOPE Tcl_Obj * GetShadows(Tcl_Interp *interp, Tcl_Obj *backgroundColorObj);

Changes to generic/window.c.
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

87
88
89
90
91
92
93
94
	return sWindow;
}

/*
 * process_window(): This function handles Windows callbacks.
 */
LRESULT CALLBACK process_window(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) {
	switch(uiMsg) {
		case WM_CLOSE:
				PostQuitMessage(0);
				return 0;

		case WM_ACTIVATE:
		case WM_KEYDOWN:
		case WM_KEYUP:
		case WM_SIZE:
				return 0;
	}

	return DefWindowProc(hWnd, uiMsg, wParam, lParam);
}

#else

/* Waits for map notification */
Bool wait_for_map(Display *d, XEvent *e, char *win_ptr) {

	return (e->type == MapNotify && e->xmap.window == (*((Window*)win_ptr)));
}

/* Creates an X window */
Window create_window(const char *title, int width, int height, Display* display, 
	EGLDisplay sEGLDisplay, EGLConfig FBConfig, Colormap *pColormap, 
	XVisualInfo **ppVisual) 
{







|
|
|
|

|
|
|
|
|
|

|






>
|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
	return sWindow;
}

/*
 * process_window(): This function handles Windows callbacks.
 */
LRESULT CALLBACK process_window(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) {
    switch(uiMsg) {
    case WM_CLOSE:
        PostQuitMessage(0);
        return 0;

    case WM_ACTIVATE:
    case WM_KEYDOWN:
    case WM_KEYUP:
    case WM_SIZE:
        return 0;
    }

    return DefWindowProc(hWnd, uiMsg, wParam, lParam);
}

#else

/* Waits for map notification */
Bool wait_for_map(Display *d, XEvent *e, char *win_ptr) {
fprintf(stderr, "§§§§§§       wait_for_map!0x%08x!\n", e->type);
    return (e->type == MapNotify && e->xmap.window == (*((Window*)win_ptr)));
}

/* Creates an X window */
Window create_window(const char *title, int width, int height, Display* display, 
	EGLDisplay sEGLDisplay, EGLConfig FBConfig, Colormap *pColormap, 
	XVisualInfo **ppVisual) 
{
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124







125

126
127
128
129
130
131
132
    Window window;

    screen = DefaultScreen(display);
    eglGetConfigAttrib(sEGLDisplay, FBConfig, EGL_NATIVE_VISUAL_ID, &vID);
    template.visualid = vID;
    visual = XGetVisualInfo(display, VisualIDMask, &template, &n);

	if (!visual) {
		printf("Couldn't get X visual info\n");
		exit(-1);
	}

    colormap = XCreateColormap(display, RootWindow(display, screen), visual->visual, AllocNone);

    wa.colormap = colormap;
    wa.background_pixel = 0xFFFFFFFF;
    wa.border_pixel = 0;

    wa.event_mask = StructureNotifyMask | ExposureMask;









    mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;

    window = XCreateWindow(display, RootWindow(display, screen), 0, 0, width, height, 
		0, visual->depth, InputOutput, visual->visual, mask, &wa);

    sh.flags = USPosition;
    sh.x = 10;







|
|
|
|






>

>
>
>
>
>
>
>

>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
    Window window;

    screen = DefaultScreen(display);
    eglGetConfigAttrib(sEGLDisplay, FBConfig, EGL_NATIVE_VISUAL_ID, &vID);
    template.visualid = vID;
    visual = XGetVisualInfo(display, VisualIDMask, &template, &n);

    if (!visual) {
        printf("Couldn't get X visual info\n");
        exit(-1);
    }

    colormap = XCreateColormap(display, RootWindow(display, screen), visual->visual, AllocNone);

    wa.colormap = colormap;
    wa.background_pixel = 0xFFFFFFFF;
    wa.border_pixel = 0;

    wa.event_mask = StructureNotifyMask | ExposureMask;
    wa.event_mask |= KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask;
    wa.event_mask |= EnterWindowMask | LeaveWindowMask;
    wa.event_mask |= PointerMotionMask | PointerMotionHintMask;
    wa.event_mask |= Button1MotionMask | Button2MotionMask | Button3MotionMask;
    wa.event_mask |= Button4MotionMask | Button5MotionMask | ButtonMotionMask;
    wa.event_mask |= KeymapStateMask | ExposureMask | VisibilityChangeMask;
    wa.event_mask |= StructureNotifyMask | ResizeRedirectMask;

fprintf(stderr, "event_mask!0x%08x!\n", wa.event_mask);
    mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;

    window = XCreateWindow(display, RootWindow(display, screen), 0, 0, width, height, 
		0, visual->depth, InputOutput, visual->visual, mask, &wa);

    sh.flags = USPosition;
    sh.x = 10;