GLES2

Check-in [207683acc1]
Login

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

Overview
Comment:fixes and new code
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:207683acc15546a7debba2021f4f4698ef98a2aa
User & Date: arnulf 2013-08-12 12:26:05
Context
2013-08-18
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
12:25
initial version check-in: 26f6ad956d user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/gles2Builtin.c.

36
37
38
39
40
41
42

43
44
45
46
47
48
49
...
169
170
171
172
173
174
175






176
177
178
179
180
181
182
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210





211
212
213
214
215
216
217
...
256
257
258
259
260
261
262
263
264
265
266
267
268
269



270
271
272



273
274
275
276
277
278
279
....
1584
1585
1586
1587
1588
1589
1590

1591
1592
1593
1594
1595
1596
1597
....
1625
1626
1627
1628
1629
1630
1631










1632
1633
1634
1635
1636
1637
1638
....
1846
1847
1848
1849
1850
1851
1852
1853





























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;


/*
 *  Standard list of built-in methods for all objects.
 */
typedef struct BiMethod {
    const char* name;        /* method name */
    const char* usage;       /* string describing usage */
................................................................................
    },
    { "getshadows",
        "",
        "@gles2-builtin-getshadows",
        Gles2_BiGetShadowsCmd,
	0
    },






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

typedef struct {
    double dark_red;
    double dark_green;
    double dark_blue;
................................................................................
GLuint _colorRenderBuffer;
GLuint framebuffer;
GLuint vertexBuffer;
GLuint indexBuffer;
GLuint _positionSlot;
GLuint _colorSlot;
GLuint _projectionSlot;
GLuint programHandle;
GLuint texName;
GLuint _floorTexture;
GLuint _fishTexture;
GLuint _texCoordSlot;
GLuint _textureUniform;






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];
................................................................................

int compileShaders(int texture_flag)
{
    const char *vertexStr = "/home/arnulf/SOURCES/GLES2/library/SimpleVertex.glsl";
    const char *textureVertexStr = "/home/arnulf/SOURCES/GLES2/library/SimpleTextureVertex.glsl";
    const char *fragmentStr = "/home/arnulf/SOURCES/GLES2/library/SimpleFragment.glsl";
    const char *textureFragmentStr ="/home/arnulf/SOURCES/GLES2/library/SimpleTextureFragment.glsl";
    GLuint vertexShader;
    GLuint fragmentShader;
    GLuint textureVertexShader;
    GLuint textureFragmentShader;

    glGetError();
    if (!texture_flag) {



        vertexShader = compileShader(GL_VERTEX_SHADER, vertexStr);
        fragmentShader = compileShader(GL_FRAGMENT_SHADER, fragmentStr);
    } else {



        textureVertexShader = compileShader(GL_VERTEX_SHADER, textureVertexStr);
        textureFragmentShader = compileShader(GL_FRAGMENT_SHADER, textureFragmentStr);
    }

    programHandle = GL_CHECK(glCreateProgram());
    if (!texture_flag) {
        GL_CHECK(glAttachShader(programHandle, vertexShader));
................................................................................
 */
int Gles2_BiGetFontInfoCmd(
    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 font_size;
    int measure_only;
    Gles2WidgetImage wgt;
    Gles2WidgetImage *wgtPtr;
    RgbaInfo rgba;

................................................................................
fprintf(stderr, "measure_only!%d!\n", measure_only);
    if (Gles2_GetFreeTypeInfo(interp, NULL, Tcl_GetString(objv[2]), font_size,
        &rgba, objv[1], wgtPtr, measure_only) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo ERROR\n");
        return TCL_ERROR;
    }
fprintf(stderr, "width!%d, height!%d! dataSize!%d!\n", wgtPtr->width, wgtPtr->height, wgtPtr->dataSize);










    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiMakeTextTextureCmd()
 *
................................................................................
fprintf(stderr, "SHADOWS!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}





































>







 







>
>
>
>
>
>







 







|






>
>
>
>
>







 







<
<
<
<



>
>
>



>
>
>







 







>







 







>
>
>
>
>
>
>
>
>
>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
...
268
269
270
271
272
273
274




275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
....
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
....
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
....
1871
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
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 {
    const char* name;        /* method name */
    const char* usage;       /* string describing usage */
................................................................................
    },
    { "getshadows",
        "",
        "@gles2-builtin-getshadows",
        Gles2_BiGetShadowsCmd,
	0
    },
    { "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;
................................................................................
GLuint _colorRenderBuffer;
GLuint framebuffer;
GLuint vertexBuffer;
GLuint indexBuffer;
GLuint _positionSlot;
GLuint _colorSlot;
GLuint _projectionSlot;
GLuint programHandle = -1;
GLuint texName;
GLuint _floorTexture;
GLuint _fishTexture;
GLuint _texCoordSlot;
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];
................................................................................

int compileShaders(int texture_flag)
{
    const char *vertexStr = "/home/arnulf/SOURCES/GLES2/library/SimpleVertex.glsl";
    const char *textureVertexStr = "/home/arnulf/SOURCES/GLES2/library/SimpleTextureVertex.glsl";
    const char *fragmentStr = "/home/arnulf/SOURCES/GLES2/library/SimpleFragment.glsl";
    const char *textureFragmentStr ="/home/arnulf/SOURCES/GLES2/library/SimpleTextureFragment.glsl";





    glGetError();
    if (!texture_flag) {
        if (programHandle != -1) {
            GL_CHECK(glDeleteProgram(programHandle));
	}
        vertexShader = compileShader(GL_VERTEX_SHADER, vertexStr);
        fragmentShader = compileShader(GL_FRAGMENT_SHADER, fragmentStr);
    } else {
        if (programHandle != -1) {
            GL_CHECK(glDeleteProgram(programHandle));
	}
        textureVertexShader = compileShader(GL_VERTEX_SHADER, textureVertexStr);
        textureFragmentShader = compileShader(GL_FRAGMENT_SHADER, textureFragmentStr);
    }

    programHandle = GL_CHECK(glCreateProgram());
    if (!texture_flag) {
        GL_CHECK(glAttachShader(programHandle, vertexShader));
................................................................................
 */
int Gles2_BiGetFontInfoCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
	Tcl_Obj *listObj;
    int result = TCL_OK;
    int font_size;
    int measure_only;
    Gles2WidgetImage wgt;
    Gles2WidgetImage *wgtPtr;
    RgbaInfo rgba;

................................................................................
fprintf(stderr, "measure_only!%d!\n", measure_only);
    if (Gles2_GetFreeTypeInfo(interp, NULL, Tcl_GetString(objv[2]), font_size,
        &rgba, objv[1], wgtPtr, measure_only) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo ERROR\n");
        return TCL_ERROR;
    }
fprintf(stderr, "width!%d, height!%d! dataSize!%d!\n", wgtPtr->width, wgtPtr->height, wgtPtr->dataSize);
    listObj = Tcl_NewListObj(0, NULL);
    if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(wgtPtr->width)) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo could not append width value %d\n", wgtPtr->width);
        return TCL_ERROR;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(wgtPtr->height)) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo could not append height value %d\n", wgtPtr->height);
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, listObj);
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiMakeTextTextureCmd()
 *
................................................................................
fprintf(stderr, "SHADOWS!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiSwapShadersCmd()
 *
 *  Invoked to handle the "swapshaders" command
 *  Handles the
 *  following syntax:
 *
 *    swapshaders
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiSwapShadersCmd(
    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(0, "Gles_BiSwapShadersCmd", objc, objv);
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
fprintf(stderr, "swapshaders not yet implemented!!\n");
    return result;
}

Changes to generic/gles2FreeType.c.

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
        if (CachedFont.fontNamePtr != NULL) {
	    FT_Done_Face(CachedFont.face);
        } else {
	    CachedFont.fontNamePtr = Tcl_NewStringObj("", 0);
	}
        Tcl_SetStringObj(CachedFont.fontNamePtr, fontName, -1);
	CachedFont.fontSize = fontSize;
fontName = "library/Vera.ttf";
//fontName = "/home/arnulf/SOURCES/TCL/OLD/itcl1/itk/ntk/library/Vera.ttf";
fprintf(stderr, "FONT name!%s!%d!\n", fontName, fontSize);
	result = FT_New_Face(library, fontName, 0, &CachedFont.face);
	if (result == FT_Err_Unknown_File_Format) {
	    Tcl_SetResult(interp, "invalid font file format", TCL_STATIC);
	    return TCL_ERROR;
	}







|







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
        if (CachedFont.fontNamePtr != NULL) {
	    FT_Done_Face(CachedFont.face);
        } else {
	    CachedFont.fontNamePtr = Tcl_NewStringObj("", 0);
	}
        Tcl_SetStringObj(CachedFont.fontNamePtr, fontName, -1);
	CachedFont.fontSize = fontSize;
fontName = "/home/arnulf/SOURCES/GLES2/library/Vera.ttf";
//fontName = "/home/arnulf/SOURCES/TCL/OLD/itcl1/itk/ntk/library/Vera.ttf";
fprintf(stderr, "FONT name!%s!%d!\n", fontName, fontSize);
	result = FT_New_Face(library, fontName, 0, &CachedFont.face);
	if (result == FT_Err_Unknown_File_Format) {
	    Tcl_SetResult(interp, "invalid font file format", TCL_STATIC);
	    return TCL_ERROR;
	}