GLES2

Check-in [44bf939a3d]
Login

Check-in [44bf939a3d]

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

Overview
Comment:code for diamond bevels
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 44bf939a3d809a9940aeb532ce0b99a46276f9f7
User & Date: arnulf 2013-08-22 21:21:11.355
Context
2013-08-23
07:30
commented out some debug output check-in: 825fb5bc38 user: arnulf tags: trunk
2013-08-22
21:21
code for diamond bevels check-in: 44bf939a3d user: arnulf tags: trunk
2013-08-20
15:29
fixes check-in: 3f269e25b1 user: arnulf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/gles2Builtin.c.
24
25
26
27
28
29
30

31
32
33
34
35
36
37
static Tcl_ObjCmdProc Gles2_BiDrawLineCmd;
static Tcl_ObjCmdProc Gles2_BiFillTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiFillTextureTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawTextureTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawRectangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawRectangleBorderCmd;

static Tcl_ObjCmdProc Gles2_BiFillRectangleCmd;
static Tcl_ObjCmdProc Gles2_BiFillTextureRectangleCmd;
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;







>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
static Tcl_ObjCmdProc Gles2_BiDrawLineCmd;
static Tcl_ObjCmdProc Gles2_BiFillTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiFillTextureTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawTextureTriangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawRectangleCmd;
static Tcl_ObjCmdProc Gles2_BiDrawRectangleBorderCmd;
static Tcl_ObjCmdProc Gles2_BiDrawDiamondBorderCmd;
static Tcl_ObjCmdProc Gles2_BiFillRectangleCmd;
static Tcl_ObjCmdProc Gles2_BiFillTextureRectangleCmd;
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;
105
106
107
108
109
110
111






112
113
114
115
116
117
118
	0
    },
    { "drawrectangleborder",
        "box borderWidth relief shadows",
        "@gles2-builtin-drawrectangleborder",
        Gles2_BiDrawRectangleBorderCmd,
	0






    },
    { "filltexturerectangle",
        "vertex1 vertex2 vertex3 vertex4",
        "@gles2-builtin-filltexturerectangle",
        Gles2_BiFillTextureRectangleCmd,
	0
    },







>
>
>
>
>
>







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
	0
    },
    { "drawrectangleborder",
        "box borderWidth relief shadows",
        "@gles2-builtin-drawrectangleborder",
        Gles2_BiDrawRectangleBorderCmd,
	0
    },
    { "drawdiamondborder",
        "box borderWidth relief shadows",
        "@gles2-builtin-drawdiamondborder",
        Gles2_BiDrawDiamondBorderCmd,
	0
    },
    { "filltexturerectangle",
        "vertex1 vertex2 vertex3 vertex4",
        "@gles2-builtin-filltexturerectangle",
        Gles2_BiFillTextureRectangleCmd,
	0
    },
365
366
367
368
369
370
371






























































































































































































































































































































372
373
374
375
376
377
378
379
380
381
382
383
384
385
    perspective_matrix(45.0, (double)uiWidth/(double)uiHeight, 0.00001, 10000.0, g_Perspective);
//showMatrix("per1", g_Perspective);
    multiply_matrix(g_Perspective, g_ModelView, g_MVP);
//showMatrix("mul3", g_MVP);

    GL_CHECK(glUniformMatrix4fv(_projectionSlot, 1, GL_FALSE, g_MVP));
}































































































































































































































































































































void VerticalBevel(Tcl_Interp *interp, int x, int y, int width, int height, int leftBevel, char *relief, shadowColors shadow_colors) {
    Tcl_Obj *obj;
    Tcl_Obj *cmd_obj;
    Tcl_Obj *cmd_objv[1];

//fprintf(stderr, "VerticalBevel!x!%d!y!%d!width!%d!height!%d!relief!%s!\n", x, y, width, height, relief);
    if (strcmp(relief, "raised") == 0) {
	if (leftBevel) {
            obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.light_red,
                shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha);  
	} else {
            obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.dark_red,
                shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha);  







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






|







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
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
    perspective_matrix(45.0, (double)uiWidth/(double)uiHeight, 0.00001, 10000.0, g_Perspective);
//showMatrix("per1", g_Perspective);
    multiply_matrix(g_Perspective, g_ModelView, g_MVP);
//showMatrix("mul3", g_MVP);

    GL_CHECK(glUniformMatrix4fv(_projectionSlot, 1, GL_FALSE, g_MVP));
}

void LeftTopBevel(Tcl_Interp *interp, int x, int y, int width, int height, int leftBevel, char *relief, shadowColors shadow_colors) {
    GLfloat f_x;
    GLfloat f_y;
    GLfloat f_z;
    GLfloat w_diameter;
    GLfloat h_diameter;

//fprintf(stderr, "LeftTopBevel!x!%d!y!%d!width!%d!height!%d!lb!%d!relief!%s!\n", x, y, width, height, leftBevel, relief);
    f_x = Pixel2Coord(interp, x, 1);
    f_y = Pixel2Coord(interp, y, 0);
    f_z = 0.0;
//    w_radius = Pixel2Coord(interp, width/2, 1);
//    h_radius = Pixel2Coord(interp, height/2, 0);
    w_diameter = Pixel2Coord(interp, width, 1);
    h_diameter = Pixel2Coord(interp, height, 0);
//fprintf(stderr, "abs f_x!%f!f_y!%f!f_z!%f!wr!%f!hr!%f!\n", f_x, f_y, f_z, w_radius, h_radius);
//fprintf(stderr, "rel f_x!%f!f_y!%f!f_z!%f!wr!%f!hr!%f!\n", -1.0+f_x, -1.0+f_y, f_z, w_radius, h_radius);
    if (strcmp(relief, "raised") == 0) {
	if (leftBevel) {
            line_vertices[0].Position[0] = -1.0+f_x;
            line_vertices[0].Position[1] = -1.0+f_y+h_diameter/2.0;
            line_vertices[0].Position[2] = f_z;
            line_vertices[1].Position[0] = -1.0+f_x+w_diameter/2.0;
            line_vertices[1].Position[1] = -1.0+f_y+h_diameter;
            line_vertices[1].Position[2] = f_z;
//fprintf(stderr, "LTB POS1!%f!%f!%f %f!%f!%f\n", line_vertices[0].Position[0], line_vertices[0].Position[1], line_vertices[0].Position[2], line_vertices[1].Position[0], line_vertices[1].Position[1], line_vertices[1].Position[2]);

            line_vertices[0].Color[0] = shadow_colors.light_red;
            line_vertices[0].Color[1] = shadow_colors.light_green;
            line_vertices[0].Color[2] = shadow_colors.light_blue;
            line_vertices[0].Color[3] = shadow_colors.light_alpha;
            line_vertices[1].Color[0] = shadow_colors.light_red;
            line_vertices[1].Color[1] = shadow_colors.light_green;
            line_vertices[1].Color[2] = shadow_colors.light_blue;
            line_vertices[1].Color[3] = shadow_colors.light_alpha;
//fprintf(stderr, "LTB COL1!%f!%f! %f!%f!\n", line_vertices[0].Color[0], line_vertices[0].Color[1], line_vertices[0].Color[2], line_vertices[0].Color[3]);
	} else {
            line_vertices[0].Position[0] = -1.0+f_x;
            line_vertices[0].Position[1] = -1.0+f_y+h_diameter/2.0;
            line_vertices[0].Position[2] = 0.0;
            line_vertices[1].Position[0] = -1.0+f_x+w_diameter/2.0;
            line_vertices[1].Position[1] = -1.0+f_y+h_diameter;
            line_vertices[1].Position[2] = 0.0;
//fprintf(stderr, "LTB POS2!%f!%f! %f!%f!\n", line_vertices[0].Position[0], line_vertices[0].Position[1], line_vertices[1].Position[0], line_vertices[1].Position[1]);

            line_vertices[0].Color[0] = shadow_colors.dark_red;
            line_vertices[0].Color[1] = shadow_colors.dark_green;
            line_vertices[0].Color[2] = shadow_colors.dark_blue;
            line_vertices[0].Color[3] = shadow_colors.dark_alpha;
            line_vertices[1].Color[0] = shadow_colors.dark_red;
            line_vertices[1].Color[1] = shadow_colors.dark_green;
            line_vertices[1].Color[2] = shadow_colors.dark_blue;
            line_vertices[1].Color[3] = shadow_colors.dark_alpha;
//fprintf(stderr, "LTB COL2!%f!%f! %f!%f!\n", line_vertices[0].Color[0], line_vertices[0].Color[1], line_vertices[0].Color[2], line_vertices[0].Color[3]);
	}
        line_indices[0] = 0;
        line_indices[1] = 1;
    
        GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0));
        GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
            sizeof(Vertex), (GLvoid*) (sizeof(float) * 3)));

        handleMatrices(0, 0);

        GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(line_vertices), &line_vertices, GL_STATIC_DRAW));
        GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(line_indices), &line_indices, GL_STATIC_DRAW));
        GL_CHECK(glDrawElements(GL_LINES, sizeof(line_indices)/sizeof(line_indices[0]), GL_UNSIGNED_BYTE, 0));
    } else {
        if (strcmp(relief, "sunken") == 0) {
	    if (leftBevel) {
                line_vertices[0].Position[0] = -1+Pixel2Coord(interp, x, 1);
                line_vertices[0].Position[1] = -1+Pixel2Coord(interp, y, 0);
                line_vertices[0].Position[2] = -1+Pixel2Coord(interp, 0, 0);
                line_vertices[1].Position[0] = -1+Pixel2Coord(interp, x+width, 1);
                line_vertices[1].Position[1] = -1+Pixel2Coord(interp, y+width, 0);
                line_vertices[1].Position[2] = -1+Pixel2Coord(interp, 0, 0);
    
                line_vertices[0].Color[0] = shadow_colors.dark_red;
                line_vertices[0].Color[1] = shadow_colors.dark_green;
                line_vertices[0].Color[2] = shadow_colors.dark_blue;
                line_vertices[0].Color[3] = shadow_colors.dark_alpha;
                line_vertices[1].Color[0] = shadow_colors.dark_red;
                line_vertices[1].Color[1] = shadow_colors.dark_green;
                line_vertices[1].Color[2] = shadow_colors.dark_blue;
                line_vertices[1].Color[3] = shadow_colors.dark_alpha;
	    } else {
                line_vertices[0].Position[0] = -1+Pixel2Coord(interp, x, 1);
                line_vertices[0].Position[1] = -1+Pixel2Coord(interp, y, 0);
                line_vertices[0].Position[2] = -1+Pixel2Coord(interp, 0, 0);
                line_vertices[1].Position[0] = -1+Pixel2Coord(interp, x+width, 1);
                line_vertices[1].Position[1] = -1+Pixel2Coord(interp, y+width, 0);
                line_vertices[1].Position[2] = -1+Pixel2Coord(interp, 0, 0);
    
                line_vertices[0].Color[0] = shadow_colors.light_red;
                line_vertices[0].Color[1] = shadow_colors.light_green;
                line_vertices[0].Color[2] = shadow_colors.light_blue;
                line_vertices[0].Color[3] = shadow_colors.light_alpha;
                line_vertices[1].Color[0] = shadow_colors.light_red;
                line_vertices[1].Color[1] = shadow_colors.light_green;
                line_vertices[1].Color[2] = shadow_colors.light_blue;
                line_vertices[1].Color[3] = shadow_colors.light_alpha;
	    }
            line_indices[0] = 0;
            line_indices[1] = 1;
    
            GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0));
            GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
                sizeof(Vertex), (GLvoid*) (sizeof(float) * 3)));

            handleMatrices(0, 0);

            GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(line_vertices), &line_vertices, GL_STATIC_DRAW));
            GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(line_indices), &line_indices, GL_STATIC_DRAW));
            GL_CHECK(glDrawElements(GL_LINES, sizeof(line_indices)/sizeof(line_indices[0]), GL_UNSIGNED_BYTE, 0));
        } else {
#ifdef NOTDEF
            if (strcmp(relief, "ridge") == =) {
                int half;

                left = borderPtr->lightGC;
                right = borderPtr->darkGC;
ridgeGroove:
                half = width/2;
                if (!leftBevel && (width & 1)) {
	            half++;
	        }
	        XFillRectangle(display, drawable, left, x, y, (unsigned) half,
	           (unsigned) height);
	        XFillRectangle(display, drawable, right, x+half, y,
	           (unsigned) (width-half), (unsigned) height);
	    } else {
                if (stcmp(relief, "groove") == 0) {
                    left = borderPtr->darkGC;
	            right = borderPtr->lightGC;
	            goto ridgeGroove;
		} else {
                    if (strcmp(relief, "flat") == 0) {
                        XFillRectangle(display, drawable, borderPtr->bgGC, x, y,
	                  (unsigned) width, (unsigned) height);
	            } else {
                        if (strcmp(relief, "solid") == 0) {
                            UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr;
                            if (unixBorderPtr->solidGC == None) {
                                XGCValues gcValues;

                                gcValues.foreground = BlackPixelOfScreen(borderPtr->screen);
		                unixBorderPtr->solidGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
		            }
		            XFillRectangle(display, drawable, unixBorderPtr->solidGC, x, y,
			        (unsigned) width, (unsigned) height);
			}
		    }
		}
	    }
#endif
	}
    }
}

void LeftBottomBevel(Tcl_Interp *interp, int x, int y, int width, int height, int leftBevel, char *relief, shadowColors shadow_colors) {
    GLfloat f_x;
    GLfloat f_y;
    GLfloat f_z;
    GLfloat w_diameter;
    GLfloat h_diameter;

//fprintf(stderr, "LeftBottomBevel!x!%d!y!%d!width!%d!height!%d!lb!%d!relief!%s!\n", x, y, width, height, leftBevel, relief);
    f_x = Pixel2Coord(interp, x, 1);
    f_y = Pixel2Coord(interp, y, 0);
    f_z = 0.0;
//    w_radius = Pixel2Coord(interp, width/2, 1);
//    h_radius = Pixel2Coord(interp, height/2, 0);
    w_diameter = Pixel2Coord(interp, width, 1);
    h_diameter = Pixel2Coord(interp, height, 0);
//fprintf(stderr, "abs f_x!%f!f_y!%f!f_z!%f!wr!%f!hr!%f!\n", f_x, f_y, f_z, w_radius, h_radius);
//fprintf(stderr, "rel f_x!%f!f_y!%f!f_z!%f!wr!%f!hr!%f!\n", -1.0+f_x, -1.0+f_y, f_z, w_radius, h_radius);
    if (strcmp(relief, "raised") == 0) {
	if (leftBevel) {
            line_vertices[0].Position[0] = -1.0+f_x;
            line_vertices[0].Position[1] = -1.0+f_y+h_diameter/2.0;
            line_vertices[0].Position[2] = f_z;
            line_vertices[1].Position[0] = -1.0+f_x+w_diameter/2.0;
            line_vertices[1].Position[1] = -1.0+f_y;
            line_vertices[1].Position[2] = f_z;
//fprintf(stderr, "LBB POS1!%f!%f!%f %f!%f!%f\n", line_vertices[0].Position[0], line_vertices[0].Position[1], line_vertices[0].Position[2], line_vertices[1].Position[0], line_vertices[1].Position[1], line_vertices[1].Position[2]);

            line_vertices[0].Color[0] = shadow_colors.light_red;
            line_vertices[0].Color[1] = shadow_colors.light_green;
            line_vertices[0].Color[2] = shadow_colors.light_blue;
            line_vertices[0].Color[3] = shadow_colors.light_alpha;
            line_vertices[1].Color[0] = shadow_colors.light_red;
            line_vertices[1].Color[1] = shadow_colors.light_green;
            line_vertices[1].Color[2] = shadow_colors.light_blue;
            line_vertices[1].Color[3] = shadow_colors.light_alpha;
//fprintf(stderr, "LBB COL1!%f!%f! %f!%f!\n", line_vertices[0].Color[0], line_vertices[0].Color[1], line_vertices[0].Color[2], line_vertices[0].Color[3]);
	} else {
            line_vertices[0].Position[0] = -1.0+f_x;
            line_vertices[0].Position[1] = -1.0+f_y+h_diameter/2.0;
            line_vertices[0].Position[2] = 0.0;
            line_vertices[1].Position[0] = -1.0+f_x+w_diameter/2.0;
            line_vertices[1].Position[1] = -1.0+f_y;
            line_vertices[1].Position[2] = 0.0;
//fprintf(stderr, "LBB POS2!%f!%f! %f!%f!\n", line_vertices[0].Position[0], line_vertices[0].Position[1], line_vertices[1].Position[0], line_vertices[1].Position[1]);

            line_vertices[0].Color[0] = shadow_colors.dark_red;
            line_vertices[0].Color[1] = shadow_colors.dark_green;
            line_vertices[0].Color[2] = shadow_colors.dark_blue;
            line_vertices[0].Color[3] = shadow_colors.dark_alpha;
            line_vertices[1].Color[0] = shadow_colors.dark_red;
            line_vertices[1].Color[1] = shadow_colors.dark_green;
            line_vertices[1].Color[2] = shadow_colors.dark_blue;
            line_vertices[1].Color[3] = shadow_colors.dark_alpha;
//fprintf(stderr, "LBB COL2!%f!%f! %f!%f!\n", line_vertices[0].Color[0], line_vertices[0].Color[1], line_vertices[0].Color[2], line_vertices[0].Color[3]);
	}
        line_indices[0] = 0;
        line_indices[1] = 1;
    
        GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0));
        GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
            sizeof(Vertex), (GLvoid*) (sizeof(float) * 3)));

        handleMatrices(0, 0);

        GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(line_vertices), &line_vertices, GL_STATIC_DRAW));
        GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(line_indices), &line_indices, GL_STATIC_DRAW));
        GL_CHECK(glDrawElements(GL_LINES, sizeof(line_indices)/sizeof(line_indices[0]), GL_UNSIGNED_BYTE, 0));
    } else {
        if (strcmp(relief, "sunken") == 0) {
	    if (leftBevel) {
                line_vertices[0].Position[0] = -1+Pixel2Coord(interp, x, 1);
                line_vertices[0].Position[1] = -1+Pixel2Coord(interp, y, 0);
                line_vertices[0].Position[2] = -1+Pixel2Coord(interp, 0, 0);
                line_vertices[1].Position[0] = -1+Pixel2Coord(interp, x+width, 1);
                line_vertices[1].Position[1] = -1+Pixel2Coord(interp, y+width, 0);
                line_vertices[1].Position[2] = -1+Pixel2Coord(interp, 0, 0);
    
                line_vertices[0].Color[0] = shadow_colors.dark_red;
                line_vertices[0].Color[1] = shadow_colors.dark_green;
                line_vertices[0].Color[2] = shadow_colors.dark_blue;
                line_vertices[0].Color[3] = shadow_colors.dark_alpha;
                line_vertices[1].Color[0] = shadow_colors.dark_red;
                line_vertices[1].Color[1] = shadow_colors.dark_green;
                line_vertices[1].Color[2] = shadow_colors.dark_blue;
                line_vertices[1].Color[3] = shadow_colors.dark_alpha;
	    } else {
                line_vertices[0].Position[0] = -1+Pixel2Coord(interp, x, 1);
                line_vertices[0].Position[1] = -1+Pixel2Coord(interp, y, 0);
                line_vertices[0].Position[2] = -1+Pixel2Coord(interp, 0, 0);
                line_vertices[1].Position[0] = -1+Pixel2Coord(interp, x+width, 1);
                line_vertices[1].Position[1] = -1+Pixel2Coord(interp, y+width, 0);
                line_vertices[1].Position[2] = -1+Pixel2Coord(interp, 0, 0);
    
                line_vertices[0].Color[0] = shadow_colors.light_red;
                line_vertices[0].Color[1] = shadow_colors.light_green;
                line_vertices[0].Color[2] = shadow_colors.light_blue;
                line_vertices[0].Color[3] = shadow_colors.light_alpha;
                line_vertices[1].Color[0] = shadow_colors.light_red;
                line_vertices[1].Color[1] = shadow_colors.light_green;
                line_vertices[1].Color[2] = shadow_colors.light_blue;
                line_vertices[1].Color[3] = shadow_colors.light_alpha;
	    }
            line_indices[0] = 0;
            line_indices[1] = 1;
    
            GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0));
            GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
                sizeof(Vertex), (GLvoid*) (sizeof(float) * 3)));

            handleMatrices(0, 0);

            GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(line_vertices), &line_vertices, GL_STATIC_DRAW));
            GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(line_indices), &line_indices, GL_STATIC_DRAW));
            GL_CHECK(glDrawElements(GL_LINES, sizeof(line_indices)/sizeof(line_indices[0]), GL_UNSIGNED_BYTE, 0));
        } else {
#ifdef NOTDEF
            if (strcmp(relief, "ridge") == =) {
                int half;

                left = borderPtr->lightGC;
                right = borderPtr->darkGC;
ridgeGroove:
                half = width/2;
                if (!leftBevel && (width & 1)) {
	            half++;
	        }
	        XFillRectangle(display, drawable, left, x, y, (unsigned) half,
	           (unsigned) height);
	        XFillRectangle(display, drawable, right, x+half, y,
	           (unsigned) (width-half), (unsigned) height);
	    } else {
                if (stcmp(relief, "groove") == 0) {
                    left = borderPtr->darkGC;
	            right = borderPtr->lightGC;
	            goto ridgeGroove;
		} else {
                    if (strcmp(relief, "flat") == 0) {
                        XFillRectangle(display, drawable, borderPtr->bgGC, x, y,
	                  (unsigned) width, (unsigned) height);
	            } else {
                        if (strcmp(relief, "solid") == 0) {
                            UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr;
                            if (unixBorderPtr->solidGC == None) {
                                XGCValues gcValues;

                                gcValues.foreground = BlackPixelOfScreen(borderPtr->screen);
		                unixBorderPtr->solidGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
		            }
		            XFillRectangle(display, drawable, unixBorderPtr->solidGC, x, y,
			        (unsigned) width, (unsigned) height);
			}
		    }
		}
	    }
#endif
	}
    }
}

void VerticalBevel(Tcl_Interp *interp, int x, int y, int width, int height, int leftBevel, char *relief, shadowColors shadow_colors) {
    Tcl_Obj *obj;
    Tcl_Obj *cmd_obj;
    Tcl_Obj *cmd_objv[1];

fprintf(stderr, "VerticalBevel!x!%d!y!%d!width!%d!height!%d!relief!%s!\n", x, y, width, height, relief);
    if (strcmp(relief, "raised") == 0) {
	if (leftBevel) {
            obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.light_red,
                shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha);  
	} else {
            obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.dark_red,
                shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha);  
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
    int bottomGC;
    int myGC;
#define GC_DARK 1
#define GC_LITE 2
#define GC_BRDR 3
#define GC_BLAK 4

//fprintf(stderr, "HorizontalBevel!x!%d!y!%d!width!%d!height!%d!relief!%s!\n", x, y, width, height, relief);
    topGC = GC_BLAK;
    bottomGC = GC_BLAK;
    if (strcmp(relief, "raised") == 0) {
        if (topBevel) {
            topGC = GC_LITE;
            bottomGC = GC_LITE;
	} else {







|







804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
    int bottomGC;
    int myGC;
#define GC_DARK 1
#define GC_LITE 2
#define GC_BRDR 3
#define GC_BLAK 4

fprintf(stderr, "HorizontalBevel!x!%d!y!%d!width!%d!height!%d!relief!%s!\n", x, y, width, height, relief);
    topGC = GC_BLAK;
    bottomGC = GC_BLAK;
    if (strcmp(relief, "raised") == 0) {
        if (topBevel) {
            topGC = GC_LITE;
            bottomGC = GC_LITE;
	} else {
1090
1091
1092
1093
1094
1095
1096


1097
1098
1099
1100
1101
1102
1103
    rectangle_indices[0] = 0;
    rectangle_indices[1] = 1;
    rectangle_indices[2] = 2;
    rectangle_indices[3] = 2;
    rectangle_indices[4] = 3;
    rectangle_indices[5] = 0;



    GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0));
    GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
        sizeof(Vertex), (GLvoid*) (sizeof(float) * 3)));

    handleMatrices(0, 0);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(rectangle_vertices), &rectangle_vertices, GL_STATIC_DRAW));







>
>







1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
    rectangle_indices[0] = 0;
    rectangle_indices[1] = 1;
    rectangle_indices[2] = 2;
    rectangle_indices[3] = 2;
    rectangle_indices[4] = 3;
    rectangle_indices[5] = 0;

fprintf(stderr, "FILLRECT!%f!%f!%f %f!%f!%f\n", rectangle_vertices[0].Position[0], rectangle_vertices[0].Position[1], rectangle_vertices[0].Position[2], rectangle_vertices[1].Position[0], rectangle_vertices[1].Position[1], rectangle_vertices[1].Position[2]);

    GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0));
    GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
        sizeof(Vertex), (GLvoid*) (sizeof(float) * 3)));

    handleMatrices(0, 0);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(rectangle_vertices), &rectangle_vertices, GL_STATIC_DRAW));
1323
1324
1325
1326
1327
1328
1329



































































































































































1330
1331
1332
1333
1334
1335
1336
    HorizontalBevel(interp, position_box.x, position_box.y, position_box.width, borderWidth, 1, 1, 1, relief, shadow_colors);
    HorizontalBevel(interp, position_box.x, position_box.y, position_box.width, borderWidth, 1, 1, 1, relief, shadow_colors);

    HorizontalBevel(interp, position_box.x, position_box.y+position_box.height-borderWidth, position_box.width, borderWidth, 0, 0, 0, relief, shadow_colors);

    return result;
}




































































































































































/*
 * ------------------------------------------------------------------------
 *  Gles2_BiFillTextureRectangleCmd()
 *
 *  Invoked to handle the "filltexturerectangle" command
 *  Handles the







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







1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
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
1820
1821
1822
1823
1824
1825
1826
    HorizontalBevel(interp, position_box.x, position_box.y, position_box.width, borderWidth, 1, 1, 1, relief, shadow_colors);
    HorizontalBevel(interp, position_box.x, position_box.y, position_box.width, borderWidth, 1, 1, 1, relief, shadow_colors);

    HorizontalBevel(interp, position_box.x, position_box.y+position_box.height-borderWidth, position_box.width, borderWidth, 0, 0, 0, relief, shadow_colors);

    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiDrawDiamondBorderCmd()
 *
 *  Invoked to handle the "drawdiamondborder" command
 *  Handles the
 *  following syntax:
 *
 *    drawdamondborder [list x y width height] borderWidth relief diameter
 *        [list darkColor lightColor]
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiDrawDiamondBorderCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    int box_objc;
    Tcl_Obj **boxObjv;
    int shadow_objc;
    Tcl_Obj **shadowObjv;
    int dark_objc;
    Tcl_Obj **darkObjv;
    int light_objc;
    Tcl_Obj **lightObjv;
    positionBox position_box;
    int borderWidth;
    int diameter;
    GLfloat radius;
    char *relief;
    shadowColors shadow_colors;

    Gles2ShowArgs(1, "Gles2_BiDrawDiamondBorderCmd", objc, objv);
    if (objc != 6) {
        Tcl_WrongNumArgs(interp, 1, objv, "box borderWidth relief diameter shadowColors");
        return TCL_ERROR;
    }
fprintf(stderr, "11\n");
    if (Tcl_ListObjGetElements(interp, objv[1], &box_objc, &boxObjv) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd1: bad input format: %s\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
    }
    if (box_objc != 4) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd2: bad input format: %s %d\n", Tcl_GetString(objv[1]), box_objc);
        return TCL_ERROR;
    }

    /* x */
    if (Tcl_GetIntFromObj(interp, boxObjv[0], &position_box.x) != TCL_OK) {
fprintf(stderr, "bad value for x!%s!\n", Tcl_GetString(boxObjv[0]));
        return TCL_ERROR;
    }
    /* y */
    if (Tcl_GetIntFromObj(interp, boxObjv[1], &position_box.y) != TCL_OK) {
fprintf(stderr, "bad value for y!%s!\n", Tcl_GetString(boxObjv[1]));
        return TCL_ERROR;
    }
    /* width */
    if (Tcl_GetIntFromObj(interp, boxObjv[2], &position_box.width) != TCL_OK) {
fprintf(stderr, "bad value for width!%s!\n", Tcl_GetString(boxObjv[2]));
        return TCL_ERROR;
    }
    /* height */
    if (Tcl_GetIntFromObj(interp, boxObjv[3], &position_box.height) != TCL_OK) {
fprintf(stderr, "bad value for height!%s!\n", Tcl_GetString(boxObjv[3]));
        return TCL_ERROR;
    }
    /* borderWidth */
    if (Tcl_GetIntFromObj(interp, objv[2], &borderWidth) != TCL_OK) {
fprintf(stderr, "bad value for borderWidth!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    relief = Tcl_GetString(objv[3]);
    /* diameter */
    if (Tcl_GetIntFromObj(interp, objv[4], &diameter) != TCL_OK) {
fprintf(stderr, "bad value for diameter!%s!\n", Tcl_GetString(objv[4]));
        return TCL_ERROR;
    }

fprintf(stderr, "22\n");
    if (Tcl_ListObjGetElements(interp, objv[5], &shadow_objc, &shadowObjv) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd3: bad input format: %s\n", Tcl_GetString(objv[5]));
        return TCL_ERROR;
    }
    if (shadow_objc != 2) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd4: bad input format: %s %d\n", Tcl_GetString(objv[4]), shadow_objc);
        return TCL_ERROR;
    }
    if (Tcl_ListObjGetElements(interp, shadowObjv[0], &dark_objc, &darkObjv) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd5: bad input format: %s\n", Tcl_GetString(shadowObjv[0]));
        return TCL_ERROR;
    }
    if (dark_objc != 4) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd6: bad input format: %s %d\n", Tcl_GetString(shadowObjv[0]), dark_objc);
        return TCL_ERROR;
    }
    /* dark_red */
    if (Tcl_GetDoubleFromObj(interp, darkObjv[0], &shadow_colors.dark_red) != TCL_OK) {
fprintf(stderr, "bad value for dark_red!%s!\n", Tcl_GetString(darkObjv[0]));
        return TCL_ERROR;
    }
    /* dark_green */
    if (Tcl_GetDoubleFromObj(interp, darkObjv[1], &shadow_colors.dark_green) != TCL_OK) {
fprintf(stderr, "bad value for dark_green!%s!\n", Tcl_GetString(darkObjv[1]));
        return TCL_ERROR;
    }
    /* dark_blue */
    if (Tcl_GetDoubleFromObj(interp, darkObjv[2], &shadow_colors.dark_blue) != TCL_OK) {
fprintf(stderr, "bad value for dark_blue!%s!\n", Tcl_GetString(darkObjv[2]));
        return TCL_ERROR;
    }
    /* dark_alpha */
    if (Tcl_GetDoubleFromObj(interp, darkObjv[3], &shadow_colors.dark_alpha) != TCL_OK) {
fprintf(stderr, "bad value for dark_alpha!%s!\n", Tcl_GetString(darkObjv[3]));
        return TCL_ERROR;
    }

    if (Tcl_ListObjGetElements(interp, shadowObjv[1], &light_objc, &lightObjv) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd7: bad input format: %s\n", Tcl_GetString(shadowObjv[1]));
        return TCL_ERROR;
    }
    if (light_objc != 4) {
fprintf(stderr, "Gles2_BiDrawDiamondBorderCmd8: bad input format: %s %d\n", Tcl_GetString(shadowObjv[1]), light_objc);
        return TCL_ERROR;
    }
    /* light_red */
    if (Tcl_GetDoubleFromObj(interp, lightObjv[0], &shadow_colors.light_red) != TCL_OK) {
fprintf(stderr, "bad value for light_red!%s!\n", Tcl_GetString(lightObjv[0]));
        return TCL_ERROR;
    }
    /* light_green */
    if (Tcl_GetDoubleFromObj(interp, lightObjv[1], &shadow_colors.light_green) != TCL_OK) {
fprintf(stderr, "bad value for light_green!%s!\n", Tcl_GetString(lightObjv[1]));
        return TCL_ERROR;
    }
    /* light_blue */
    if (Tcl_GetDoubleFromObj(interp, lightObjv[2], &shadow_colors.light_blue) != TCL_OK) {
fprintf(stderr, "bad value for light_blue!%s!\n", Tcl_GetString(lightObjv[2]));
        return TCL_ERROR;
    }
    /* light_alpha */
    if (Tcl_GetDoubleFromObj(interp, lightObjv[3], &shadow_colors.light_alpha) != TCL_OK) {
fprintf(stderr, "bad value for light_alpha!%s!\n", Tcl_GetString(lightObjv[3]));
        return TCL_ERROR;
    }

    radius = diameter / 2.0;
    if (position_box.width < 2*borderWidth) {
        borderWidth = position_box.width/2;
    }
    if (position_box.height < 2*borderWidth) {
        borderWidth = position_box.height/2;
    }
    LeftTopBevel(interp, position_box.x, position_box.y, diameter, diameter, 0, relief, shadow_colors);
    LeftTopBevel(interp, position_box.x+radius, position_box.y-radius, diameter, diameter, 1, relief, shadow_colors);
    LeftBottomBevel(interp, position_box.x, position_box.y, diameter, diameter, 1, relief, shadow_colors);
    LeftBottomBevel(interp, position_box.x+radius, position_box.y+radius, diameter, diameter, 0, relief, shadow_colors);
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiFillTextureRectangleCmd()
 *
 *  Invoked to handle the "filltexturerectangle" command
 *  Handles the