GLES2

Check-in [5081502c76]
Login

Check-in [5081502c76]

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

Overview
Comment:fixes for rotate
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5081502c76aa7d69d6dab790a35cb2c12c1f03ff
User & Date: arnulf 2013-08-24 19:02:24.690
Context
2013-08-25
16:38
fixes for value2pixel check-in: b5dab237b7 user: arnulf tags: trunk
2013-08-24
19:02
fixes for rotate check-in: 5081502c76 user: arnulf tags: trunk
14:06
fixes check-in: 8b437402ec user: arnulf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/gles2Base.c.
269
270
271
272
273
274
275


276
277
278
279
280
281
282
		                NULL, NULL);
    Tcl_CreateObjCommand(interp, GLES2_NAMESPACE"::x11eventloop", X11EventLoop,
		                NULL, NULL);

    SDL_SetVideoMode(800, 480, 16, 0);
    ret = InitOpenGL(interp);
//fprintf(stderr, "ret!%d!\n", ret);


    /* reset the gl* error !! */
    glGetError();

    /*
     *  Set up the variables containing version info.
     */








>
>







269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
		                NULL, NULL);
    Tcl_CreateObjCommand(interp, GLES2_NAMESPACE"::x11eventloop", X11EventLoop,
		                NULL, NULL);

    SDL_SetVideoMode(800, 480, 16, 0);
    ret = InitOpenGL(interp);
//fprintf(stderr, "ret!%d!\n", ret);
    if (ret) {
    }
    /* reset the gl* error !! */
    glGetError();

    /*
     *  Set up the variables containing version info.
     */

342
343
344
345
346
347
348

    Tcl_Interp *interp)
{
    if (Initialize(interp) != TCL_OK) {
        return TCL_ERROR;
    }
    return TCL_OK;
}








>
344
345
346
347
348
349
350
351
    Tcl_Interp *interp)
{
    if (Initialize(interp) != TCL_OK) {
        return TCL_ERROR;
    }
    return TCL_OK;
}

Changes to generic/gles2Builtin.c.
40
41
42
43
44
45
46

47
48
49
50
51
52
53
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 {
    const char* name;        /* method name */
    const char* usage;       /* string describing usage */







>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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;
static Tcl_ObjCmdProc Gles2_BiRotateCmd;

/*
 *  Standard list of built-in methods for all objects.
 */
typedef struct BiMethod {
    const char* name;        /* method name */
    const char* usage;       /* string describing usage */
197
198
199
200
201
202
203






204
205
206
207
208
209
210
    },
    { "swapshaders",
        "textureflag",
        "@gles2-builtin-swapshaders",
        Gles2_BiSwapShadersCmd,
	0
    },






};
static int BiMethodListLen = sizeof(BiMethodList)/sizeof(BiMethod);

typedef struct {
    double dark_red;
    double dark_green;
    double dark_blue;







>
>
>
>
>
>







198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
    },
    { "swapshaders",
        "textureflag",
        "@gles2-builtin-swapshaders",
        Gles2_BiSwapShadersCmd,
	0
    },
    { "rotate",
        "xangle yangle zangle",
        "@gles2-builtin-rotate",
        Gles2_BiRotateCmd,
	0
    },
};
static int BiMethodListLen = sizeof(BiMethodList)/sizeof(BiMethod);

typedef struct {
    double dark_red;
    double dark_green;
    double dark_blue;
237
238
239
240
241
242
243



244
245
246
247
248
249
250
GLuint _textureUniform;

GLuint vertexShader;
GLuint fragmentShader;
GLuint textureVertexShader;
GLuint textureFragmentShader;




float g_Perspective[16];
float g_Rotate[16];
float g_ModelView[16];
float g_MVP[16];
static Vertex line_vertices[2];
static Vertex triangle_vertices[3];
static TextureVertex texture_triangle_vertices[3];







>
>
>







244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
GLuint _textureUniform;

GLuint vertexShader;
GLuint fragmentShader;
GLuint textureVertexShader;
GLuint textureFragmentShader;

double xangle = 0;
double yangle = 0;
double zangle = 0;
float g_Perspective[16];
float g_Rotate[16];
float g_ModelView[16];
float g_MVP[16];
static Vertex line_vertices[2];
static Vertex triangle_vertices[3];
static TextureVertex texture_triangle_vertices[3];
352
353
354
355
356
357
358
359


360
361
362
363




364
365
366
367
368
369
370
		 
    GL_CHECK(glGenBuffers(1, &indexBuffer));
    GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(line_indices), line_indices, GL_STATIC_DRAW));

}

void handleMatrices(int xangle, int yangle) {


    rotate_matrix(xangle, 1.0, 0.0, 0.0, g_ModelView);
//showMatrix("rot1", g_ModelView);

    rotate_matrix(yangle, 0.0, 1.0, 0.0, g_Rotate);




//showMatrix("rot2", g_Rotate);

    multiply_matrix(g_Rotate, g_ModelView, g_ModelView);
//showMatrix("mul1", g_ModelView);

    /* Pull the camera back from the rectangle */
    g_ModelView[14] -= 2.5;







|
>
>
|


|
>
>
>
>







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
		 
    GL_CHECK(glGenBuffers(1, &indexBuffer));
    GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(line_indices), line_indices, GL_STATIC_DRAW));

}

void handleMatrices(double pxangle, double pyangle, double pzangle) {
//fprintf(stderr, "handleMatrices!%f!%f!%f!\n", pxangle, pyangle, pzangle);
//showMatrix("before rot1", g_ModelView);
    rotate_matrix(pxangle, 1.0, 0.0, 0.0, g_ModelView);
//showMatrix("rot1", g_ModelView);

    rotate_matrix(pyangle, 0.0, 1.0, 0.0, g_Rotate);
//showMatrix("rot2", g_Rotate);
    multiply_matrix(g_Rotate, g_ModelView, g_ModelView);

    rotate_matrix(pzangle, 0.0, 0.0, 1.0, g_Rotate);
//showMatrix("rot2", g_Rotate);

    multiply_matrix(g_Rotate, g_ModelView, g_ModelView);
//showMatrix("mul1", g_ModelView);

    /* Pull the camera back from the rectangle */
    g_ModelView[14] -= 2.5;
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
        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) {







|







451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
        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(xangle, yangle, zangle);

        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) {
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
            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") == =) {







|







498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
            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(xangle, yangle, zangle);

            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") == =) {
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
        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) {







|







610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
        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(xangle, yangle, zangle);

        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) {
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
            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") == =) {







|







657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
            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(xangle, yangle, zangle);

            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") == =) {
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
    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));
    return result;
}








|







1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
    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(xangle, yangle, zangle);

    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));
    return result;
}

1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
    triangle_indices[1] = 1;
    triangle_indices[2] = 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(triangle_vertices), &triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(triangle_indices), &triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glDrawElements(GL_TRIANGLES, sizeof(triangle_indices)/sizeof(triangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;







|







1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
    triangle_indices[1] = 1;
    triangle_indices[2] = 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(xangle, yangle, zangle);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(triangle_vertices), &triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(triangle_indices), &triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glDrawElements(GL_TRIANGLES, sizeof(triangle_indices)/sizeof(triangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
    draw_triangle_indices[6] = 3;
    draw_triangle_indices[7] = 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(triangle_vertices), &triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_triangle_indices), &draw_triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glDrawElements(GL_LINES, sizeof(draw_triangle_indices)/sizeof(draw_triangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;







|







1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
    draw_triangle_indices[6] = 3;
    draw_triangle_indices[7] = 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(xangle, yangle, zangle);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(triangle_vertices), &triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_triangle_indices), &draw_triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glDrawElements(GL_LINES, sizeof(draw_triangle_indices)/sizeof(draw_triangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
    triangle_indices[1] = 1;
    triangle_indices[2] = 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(texture_triangle_vertices), &texture_triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(triangle_indices), &triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 







|







1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
    triangle_indices[1] = 1;
    triangle_indices[2] = 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(xangle, yangle, zangle);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_triangle_vertices), &texture_triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(triangle_indices), &triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
    draw_triangle_indices[6] = 3;
    draw_triangle_indices[7] = 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(texture_triangle_vertices), &texture_triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_triangle_indices), &draw_triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 







|







1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
    draw_triangle_indices[6] = 3;
    draw_triangle_indices[7] = 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(xangle, yangle, zangle);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_triangle_vertices), &texture_triangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_triangle_indices), &draw_triangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 
1421
1422
1423
1424
1425
1426
1427

1428
1429
1430
1431
1432
1433
1434
1435

//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));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rectangle_indices), &rectangle_indices, GL_STATIC_DRAW));
    GL_CHECK(glDrawElements(GL_TRIANGLES, sizeof(rectangle_indices)/sizeof(rectangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
}







>
|







1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452

//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)));

//fprintf(stderr, "fillRectangle before %f %f %f\n", xangle, yangle, zangle);
    handleMatrices(xangle, yangle, zangle);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(rectangle_vertices), &rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rectangle_indices), &rectangle_indices, GL_STATIC_DRAW));
    GL_CHECK(glDrawElements(GL_TRIANGLES, sizeof(rectangle_indices)/sizeof(rectangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
}
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
    draw_rectangle_indices[6] = 3;
    draw_rectangle_indices[7] = 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));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_rectangle_indices), &draw_rectangle_indices, GL_STATIC_DRAW));
    GL_CHECK(glDrawElements(GL_LINES, sizeof(draw_rectangle_indices)/sizeof(draw_rectangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
}







|







1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
    draw_rectangle_indices[6] = 3;
    draw_rectangle_indices[7] = 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(xangle, yangle, zangle);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(rectangle_vertices), &rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_rectangle_indices), &draw_rectangle_indices, GL_STATIC_DRAW));
    GL_CHECK(glDrawElements(GL_LINES, sizeof(draw_rectangle_indices)/sizeof(draw_rectangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
}
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_rectangle_vertices), &texture_rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rectangle_indices), &rectangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texName));
    GL_CHECK(glUniform1i(_textureUniform, 0));

    handleMatrices(0, 0);

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

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));







|







1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_rectangle_vertices), &texture_rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rectangle_indices), &rectangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texName));
    GL_CHECK(glUniform1i(_textureUniform, 0));

    handleMatrices(xangle, yangle, zangle);

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

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
    draw_rectangle_indices[6] = 3;
    draw_rectangle_indices[7] = 0;

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

    handleMatrices(0, 0);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_rectangle_vertices), &texture_rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_rectangle_indices), &draw_rectangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 







|







1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
    draw_rectangle_indices[6] = 3;
    draw_rectangle_indices[7] = 0;

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

    handleMatrices(xangle, yangle, zangle);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_rectangle_vertices), &texture_rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(draw_rectangle_indices), &draw_rectangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 
2680
2681
2682
2683
2684
2685
2686
2687








































    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
fprintf(stderr, "swapshaders not yet implemented!!\n");
    return result;
}

















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
fprintf(stderr, "swapshaders not yet implemented!!\n");
    return result;
}

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

    Gles2ShowArgs(1, "Gles_BiRotateCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "xangle yangle zangle");
        return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[1], &xangle) != TCL_OK) {
fprintf(stderr, "bad value for xangle!%s!\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[2], &yangle) != TCL_OK) {
fprintf(stderr, "bad value for yangle!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[3], &zangle) != TCL_OK) {
fprintf(stderr, "bad value for zangle!%s!\n", Tcl_GetString(objv[3]));
        return TCL_ERROR;
    }
    return result;
}

Changes to generic/gles2Helpers.c.
1209
1210
1211
1212
1213
1214
1215




















1216
        return NULL;
    }


    return obj;

}




























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

1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
        return NULL;
    }


    return obj;

}

/*
 * ------------------------------------------------------------------------
 *  showMatrix()
 *
 * ------------------------------------------------------------------------
 */

void showMatrix(const char * info, float *mat) {
    int i;

    fprintf(stderr, "%s", info);
    for (i = 0; i < 16; i++) {
        if (i % 4 == 0) {
            fprintf(stderr, "\n");
        }
        fprintf(stderr, "%f ", mat[i]);
    }
    fprintf(stderr, "\n\n");
}

Changes to generic/gles2Int.h.
70
71
72
73
74
75
76


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);
MODULE_SCOPE int GetX11Window();
MODULE_SCOPE Display * GetX11Display();









>
>
70
71
72
73
74
75
76
77
78
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);
MODULE_SCOPE int GetX11Window();
MODULE_SCOPE Display * GetX11Display();
MODULE_SCOPE void showMatrix(const char * info, float *mat);