feat():initial version
This commit is contained in:
413
insDavi2.0/src/lib/InsFont.c
Normal file
413
insDavi2.0/src/lib/InsFont.c
Normal file
@@ -0,0 +1,413 @@
|
||||
#include <InsCfg.h>
|
||||
#include <lib/InsFont.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
|
||||
#define DBG_LEVEL DBG_INFO
|
||||
#define DBG_TAG "LibFont"
|
||||
#include <InsDbg.h>
|
||||
|
||||
static FT_Library mFtLib = NULL;
|
||||
static FT_Face mFtFace[MAX_FT_FACE_NUM];
|
||||
static Int32 mFtFaceIdCnt = 0;
|
||||
|
||||
/*
|
||||
根据指定的字体文件初始化ftLib,
|
||||
成功返回Ins_TRUE, libIDs数组中存放初始化完成的ftLib ID
|
||||
失败或者部分成功返回Ins_FALSE, libIDs数组中可能会被赋值为INS_INVALID_RES_ID
|
||||
*/
|
||||
Bool InitFtLibs
|
||||
(
|
||||
const char *ftFiles[], /*[in] 字体文件路径名字符串数组*/
|
||||
Int32 *libIDs, /*[out] ftLib id数组, 从0开始[0,n]*/
|
||||
Int32 num /*[in] 字体文件数量, ftLib数量*/
|
||||
)
|
||||
{
|
||||
Int32 i;
|
||||
Bool retv = INS_TRUE;
|
||||
|
||||
if(mFtLib == NULL && FT_Init_FreeType(&mFtLib) != 0)
|
||||
{
|
||||
for(i = 0; i < num; i++)libIDs[i] = INS_INVALID_RES_ID;
|
||||
printf("FT_Init_FreeType fail\n");
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
for(i = 0; i < num && i < MAX_FT_FACE_NUM; i++)
|
||||
{
|
||||
if(FT_New_Face(mFtLib, ftFiles[i], 0, &mFtFace[mFtFaceIdCnt]) != 0)
|
||||
{
|
||||
mFtFace[mFtFaceIdCnt] = NULL;
|
||||
retv = INS_FALSE;
|
||||
libIDs[i] = INS_INVALID_RES_ID;
|
||||
printf("FT_New_Face %s fail\n", ftFiles[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
libIDs[i] = mFtFaceIdCnt;
|
||||
mFtFaceIdCnt++;
|
||||
}
|
||||
}
|
||||
for(; i < num; i++) /*(num >= MAX_FT_FACE_NUM)out of range?*/
|
||||
{
|
||||
retv = INS_FALSE;
|
||||
libIDs[i] = INS_INVALID_RES_ID;
|
||||
}
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
||||
/*释放ftLib占用的资源*/
|
||||
void DeInitFtLibs
|
||||
(
|
||||
Int32 *libIDs, /*[in] 需要释放的ftLib ID数组*/
|
||||
Int32 num /*[in]数组大小*/
|
||||
)
|
||||
{
|
||||
if(mFtLib == NULL)return;
|
||||
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAX_FT_FACE_NUM; i++)
|
||||
{
|
||||
if(mFtFace[i] != NULL)
|
||||
{
|
||||
FT_Done_Face(mFtFace[i]);
|
||||
mFtFace[i] = NULL;
|
||||
}
|
||||
}
|
||||
FT_Done_FreeType(mFtLib);
|
||||
mFtLib = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
根据指定的ftLib ID及字符编码生成字形图
|
||||
*/
|
||||
Bool GenFontBmps
|
||||
(
|
||||
Int32 libID, /*[in] ftLib ID*/
|
||||
Int32 charSize, /*[in] 单个字符最大宽度(最大高度为最大宽度的1.5倍)*/
|
||||
Int32 texWidth, /*[in] 自行图宽度(=2^n)*/
|
||||
Int32 codeNum, /*[in] 字符编码数组大小*/
|
||||
const UInt32 *ucsCode, /*[in] 字符编码数组*/
|
||||
Int32 *texHigh, /*[out] 字形图中包含有效字形的像素高度*/
|
||||
UInt08 **pixelBuff, /*[out] 自行图像素(灰度/Alpha)数据(一个字节对应一个像素的Alpha值), 字节数大于texWidth x texHigh */
|
||||
Flt32 **widthRate, /*[out] 字形实际宽度比值数组(实际宽度/charSize)*/
|
||||
Flt32 **texcoord, /*[out] 与字符编码数组对应的OpenGL纹理坐标(左上角、右下角两组坐标)*/
|
||||
Bool tight /*[in] 左右相邻的两个字形是否紧密排列, Ins_FALSE则按每个字形占charSize个像素宽度排列,无论字形的"肥瘦"*/
|
||||
)
|
||||
{
|
||||
Int32 x, y, n, column, row;
|
||||
Int32 texX0, texY0;
|
||||
UInt08 *tmpBuff;
|
||||
|
||||
if(charSize > texWidth
|
||||
|| pixelBuff == NULL
|
||||
|| texHigh == NULL
|
||||
|| codeNum < 1
|
||||
|| libID >= mFtFaceIdCnt
|
||||
|| libID < 0)
|
||||
{
|
||||
return INS_FALSE;
|
||||
}
|
||||
FT_Set_Pixel_Sizes(mFtFace[libID], charSize, charSize);
|
||||
texX0 = 0;
|
||||
texY0 = 0;
|
||||
column = texWidth/charSize; /*glyph_num per line */
|
||||
row = (codeNum+column-1)/column; /*line count*/
|
||||
tmpBuff = (UInt08*)malloc(row*3*charSize/2*texWidth); /*glyph high is [3 x charSize / 2]*/
|
||||
if(widthRate != NULL)widthRate[0] = (Flt32*)malloc(codeNum*sizeof(Flt32));
|
||||
if(texcoord != NULL)texcoord[0] = (Flt32*)malloc(codeNum*4*sizeof(Flt32));
|
||||
memset(tmpBuff, 0, row*3*charSize/2*texWidth);
|
||||
for(n = 0; n < codeNum; n++)
|
||||
{
|
||||
FT_Glyph glyph;
|
||||
UInt08 *bmpBuff;
|
||||
Int32 left, top, innx, inny, w, h;
|
||||
|
||||
FT_Load_Glyph(mFtFace[libID], FT_Get_Char_Index(mFtFace[libID], ucsCode[n]), FT_LOAD_DEFAULT);
|
||||
if(FT_Get_Glyph(mFtFace[libID]->glyph, &glyph) != 0)
|
||||
{
|
||||
if(texcoord != NULL)
|
||||
{
|
||||
texcoord[0][4*n+0] = 0.0f;
|
||||
texcoord[0][4*n+1] = 0.0f;
|
||||
texcoord[0][4*n+2] = 0.0f;
|
||||
texcoord[0][4*n+3] = 0.0f;
|
||||
}
|
||||
if(widthRate != NULL)widthRate[0][n] = 0.0f;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(glyph->format != FT_GLYPH_FORMAT_BITMAP)
|
||||
{
|
||||
FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1);
|
||||
}
|
||||
FT_BitmapGlyph bmpGlyph = (FT_BitmapGlyph)glyph;
|
||||
|
||||
w = bmpGlyph->bitmap.width;
|
||||
h = bmpGlyph->bitmap.rows;
|
||||
left = bmpGlyph->left;
|
||||
top = bmpGlyph->top;
|
||||
if(top > charSize)
|
||||
top = charSize;
|
||||
|
||||
bmpBuff = bmpGlyph->bitmap.buffer;
|
||||
if(w == 0) /*space*/
|
||||
{
|
||||
w = charSize/2;
|
||||
h = 0;
|
||||
left = 0;
|
||||
top = 0;
|
||||
bmpBuff = NULL;
|
||||
}
|
||||
if(tight)
|
||||
{
|
||||
if(widthRate != NULL)widthRate[0][n] = 1.0f*w/charSize;
|
||||
if(texX0 + w > texWidth)
|
||||
{
|
||||
texX0 = 0;
|
||||
texY0 += 3*charSize/2;
|
||||
}
|
||||
x = texX0;
|
||||
y = texY0 + charSize - top;
|
||||
if(texcoord != NULL)
|
||||
{
|
||||
texcoord[0][4*n+0] = 1.0f*texX0/texWidth;
|
||||
texcoord[0][4*n+1] = texY0;
|
||||
texcoord[0][4*n+2] = 1.0f*(texX0+w)/texWidth;
|
||||
texcoord[0][4*n+3] = texY0+3.0f*charSize/2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(widthRate != NULL)widthRate[0][n] = 1.0f;
|
||||
if(texX0 + charSize > texWidth)
|
||||
{
|
||||
texX0 = 0;
|
||||
texY0 += 3*charSize/2;
|
||||
}
|
||||
x = texX0 + left;
|
||||
y = texY0 + charSize - top;
|
||||
if(texcoord != NULL)
|
||||
{
|
||||
texcoord[0][4*n+0] = 1.0f*texX0/texWidth;
|
||||
texcoord[0][4*n+1] = texY0;
|
||||
texcoord[0][4*n+2] = 1.0f*(texX0+charSize)/texWidth;
|
||||
texcoord[0][4*n+3] = texY0+3.0f*charSize/2;
|
||||
}
|
||||
}
|
||||
|
||||
for(inny = 0; inny < h; inny++)
|
||||
{
|
||||
for(innx = 0; innx < w; innx++)
|
||||
{
|
||||
tmpBuff[(y+inny)*texWidth + x + innx] = bmpBuff[inny*w+innx];
|
||||
}
|
||||
}
|
||||
|
||||
if(tight)
|
||||
{
|
||||
texX0 += w+2;/* +2 to make a gap between glyphs*/
|
||||
}
|
||||
else
|
||||
{
|
||||
texX0 += charSize;
|
||||
}
|
||||
//printf("texX0:%d\n", texX0);
|
||||
FT_Done_Glyph(glyph);
|
||||
}
|
||||
pixelBuff[0] = tmpBuff;
|
||||
*texHigh = texY0 + 3.0f*charSize/2;
|
||||
if(texcoord != NULL)for(n = 0; n < codeNum; n++)
|
||||
{
|
||||
texcoord[0][4*n+1] = *texHigh - texcoord[0][4*n+1];
|
||||
texcoord[0][4*n+3] = *texHigh - texcoord[0][4*n+3];
|
||||
texcoord[0][4*n+1] /= *texHigh;
|
||||
texcoord[0][4*n+3] /= *texHigh;
|
||||
//printf("(%f, %f), (%f, %f)\n", texcoord[0][4*n+0], texcoord[0][4*n+1], texcoord[0][4*n+2], texcoord[0][4*n+3]);
|
||||
}
|
||||
/*
|
||||
if(widthRate != NULL)for(n = 0; n < codeNum; n++)
|
||||
{
|
||||
printf("%f\n", widthRate[0][n]);
|
||||
}
|
||||
for(y = 0; y < 0; y++)// *texHigh; y++)
|
||||
{
|
||||
for(x = 0; x < texWidth; x++)
|
||||
{
|
||||
if(pixelBuff[0][y*texWidth+x] < 10)printf("00%d ", pixelBuff[0][y*texWidth+x]);
|
||||
else if(pixelBuff[0][y*texWidth+x] < 100)printf("0%d ", pixelBuff[0][y*texWidth+x]);
|
||||
else printf("%d ", pixelBuff[0][y*texWidth+x]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
*/
|
||||
for(y = 0; y < *texHigh/2; y++)
|
||||
{
|
||||
for(x = 0; x < texWidth; x++)
|
||||
{
|
||||
texY0 = *texHigh-y-1;
|
||||
n = pixelBuff[0][y*texWidth + x];
|
||||
pixelBuff[0][y*texWidth + x] = pixelBuff[0][texY0*texWidth + x];
|
||||
pixelBuff[0][texY0*texWidth + x] = n;
|
||||
}
|
||||
}
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
Bool DrawSingleLineTxtBmp
|
||||
(
|
||||
Int32 libID,
|
||||
Int32 charSize,
|
||||
Int32 *bmpWidth,
|
||||
Int32 *bmpHigh,
|
||||
const UInt32 *ucsCode,
|
||||
UInt08 *bmpPixel,
|
||||
Bool tight,
|
||||
Int32 *numDrawn
|
||||
)
|
||||
{
|
||||
Int32 x, y, n, cursorX, failWidth;
|
||||
FT_Glyph glyph[1];
|
||||
|
||||
if(charSize > *bmpWidth
|
||||
|| bmpPixel == NULL
|
||||
|| libID >= mFtFaceIdCnt
|
||||
|| libID < 0)
|
||||
{
|
||||
if(numDrawn != NULL)*numDrawn = 0;
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
FT_Set_Pixel_Sizes(mFtFace[libID], charSize, charSize);
|
||||
|
||||
/* use '_' rectangle info for invalid(fail) character */
|
||||
if(FT_Load_Glyph(mFtFace[libID], FT_Get_Char_Index(mFtFace[libID], '_'), FT_LOAD_DEFAULT) != 0
|
||||
|| FT_Get_Glyph(mFtFace[libID]->glyph, glyph) != 0)
|
||||
{
|
||||
failWidth = charSize/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(glyph[0]->format != FT_GLYPH_FORMAT_BITMAP)
|
||||
{
|
||||
FT_Glyph_To_Bitmap(glyph, FT_RENDER_MODE_NORMAL, 0, 1);
|
||||
}
|
||||
FT_BitmapGlyph bmpGlyph = (FT_BitmapGlyph)glyph[0];
|
||||
|
||||
failWidth = bmpGlyph->bitmap.width;
|
||||
}
|
||||
|
||||
FT_Done_Glyph(glyph[0]);
|
||||
glyph[0] = NULL;
|
||||
|
||||
cursorX = 0;
|
||||
for(n = 0; ucsCode[n] != 0; n++)
|
||||
{
|
||||
UInt08 *buff = NULL;
|
||||
UInt32 idx, innx, inny;
|
||||
Int32 glyphLeft, glyphTop, glyphWidth, glyphHeight;
|
||||
|
||||
if((idx = FT_Get_Char_Index(mFtFace[libID], ucsCode[n])) == 0 /*invalid character*/
|
||||
|| FT_Load_Glyph(mFtFace[libID], idx, FT_LOAD_DEFAULT) != 0 /*load fail*/
|
||||
|| FT_Get_Glyph(mFtFace[libID]->glyph, glyph) != 0) /*get fail*/
|
||||
{
|
||||
printf("load glyph fail[ucs:0x%x]\n", ucsCode[n]);
|
||||
glyphWidth = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(glyph[0]->format != FT_GLYPH_FORMAT_BITMAP)
|
||||
{
|
||||
FT_Glyph_To_Bitmap(glyph, FT_RENDER_MODE_NORMAL, 0, 1);
|
||||
}
|
||||
FT_BitmapGlyph bmpGlyph = (FT_BitmapGlyph)glyph[0];
|
||||
|
||||
glyphWidth = bmpGlyph->bitmap.width;
|
||||
glyphHeight = bmpGlyph->bitmap.rows;
|
||||
glyphLeft = bmpGlyph->left;
|
||||
glyphTop = bmpGlyph->top;
|
||||
// printf("load glyph ok[ucs:0x%x]\n", ucsCode[n]);
|
||||
// printf("(%d, %d, %d, %d)\n", glyphLeft, glyphTop, glyphWidth, glyphHeight);
|
||||
|
||||
buff = bmpGlyph->bitmap.buffer;
|
||||
}
|
||||
if(glyphWidth == 0)
|
||||
{
|
||||
glyphWidth = failWidth;
|
||||
glyphHeight = 0;
|
||||
glyphLeft = 0;
|
||||
glyphTop = 0;
|
||||
}
|
||||
if(tight)
|
||||
{
|
||||
if(cursorX + glyphWidth > (*bmpWidth))
|
||||
{
|
||||
FT_Done_Glyph(glyph[0]);
|
||||
glyph[0] = NULL;
|
||||
break;
|
||||
}
|
||||
x = cursorX;
|
||||
y = charSize - glyphTop;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cursorX + charSize > (*bmpWidth))
|
||||
{
|
||||
FT_Done_Glyph(glyph[0]);
|
||||
glyph[0] = NULL;
|
||||
break;
|
||||
}
|
||||
x = cursorX + glyphLeft;
|
||||
y = charSize - glyphTop;
|
||||
}
|
||||
if(y < 0)y = 0;
|
||||
|
||||
// printf("cursorX:%d, bmpWidth:%d, bmpHeight:%d, (%d,%d)\n", cursorX, *bmpWidth, *bmpHigh, x, y);
|
||||
for(inny = 0; inny < glyphHeight; inny++)
|
||||
{
|
||||
for(innx = 0; innx < glyphWidth; innx++)
|
||||
{
|
||||
// printf("%x%x,", buff[inny*glyphWidth+innx]/16, buff[inny*glyphWidth+innx]%16);
|
||||
if((*bmpHigh) <= y+inny)continue;
|
||||
bmpPixel[((*bmpHigh)-y-inny-1)*(*bmpWidth) + x + innx] = buff[inny*glyphWidth+innx];
|
||||
// bmpPixel[(y+inny)*(*bmpWidth) + x + innx] = buff[inny*glyphWidth+innx];
|
||||
}
|
||||
// printf("\n");
|
||||
}
|
||||
|
||||
if(tight)
|
||||
{
|
||||
cursorX += glyphWidth+2;/* +2 to make a gap between glyphs*/
|
||||
}
|
||||
else
|
||||
{
|
||||
cursorX += charSize;
|
||||
}
|
||||
FT_Done_Glyph(glyph[0]);
|
||||
glyph[0] = NULL;
|
||||
}
|
||||
if(numDrawn != NULL)*numDrawn = n;
|
||||
|
||||
if(tight)cursorX -= 2;
|
||||
for(y = 1; y < *bmpHigh; y++)
|
||||
{
|
||||
for(x = 0; x < cursorX; x++)
|
||||
{
|
||||
bmpPixel[y*cursorX+x] = bmpPixel[y*(*bmpWidth)+x];
|
||||
}
|
||||
}
|
||||
|
||||
x = (*bmpHigh)*cursorX;
|
||||
y = (*bmpHigh)*(*bmpWidth);
|
||||
while(x < y)bmpPixel[(x++)] = 0;
|
||||
|
||||
*(bmpWidth) = cursorX;
|
||||
// printf("width:%d, height:%d\n", (*bmpWidth), (*bmpHigh));
|
||||
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
59
insDavi2.0/src/lib/InsFont.d
Normal file
59
insDavi2.0/src/lib/InsFont.d
Normal file
@@ -0,0 +1,59 @@
|
||||
src/lib/InsFont.o: src/lib/InsFont.c include/InsCfg.h \
|
||||
include/lib/InsFont.h include/BaseTypes.h \
|
||||
/home/lst/workspace/rootfs//usr/include/ft2build.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/config/ftheader.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/freetype.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/config/ftconfig.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/config/ftoption.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/config/ftstdlib.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stddef.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include-fixed/limits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include-fixed/syslimits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/limits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/features.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/cdefs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wordsize.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/gnu/stubs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/posix1_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/local_lim.h \
|
||||
/home/lst/workspace/rootfs//usr/src/linux/include/linux/limits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/posix2_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/string.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/xlocale.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/string.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/string2.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdlib.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/typesizes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/libio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/_G_config.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/wchar.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stdarg.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sys_errlist.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitflags.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitstatus.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/byteswap.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sigset.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/sysmacros.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/pthreadtypes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/alloca.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/setjmp.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/setjmp.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/fterrors.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/ftmoderr.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/fterrdef.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/fttypes.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/ftsystem.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/ftimage.h \
|
||||
/home/lst/workspace/rootfs//usr/include/freetype2/freetype/ftglyph.h \
|
||||
include/InsDbg.h
|
||||
BIN
insDavi2.0/src/lib/InsFont.o
Normal file
BIN
insDavi2.0/src/lib/InsFont.o
Normal file
Binary file not shown.
527
insDavi2.0/src/lib/InsGL.c
Normal file
527
insDavi2.0/src/lib/InsGL.c
Normal file
@@ -0,0 +1,527 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <InsCfg.h>
|
||||
#include <lib/InsGL.h>
|
||||
|
||||
#define DBG_LEVEL DBG_INFO
|
||||
#define DBG_TAG "LibGL"
|
||||
#include <InsDbg.h>
|
||||
|
||||
#ifdef COMPILE_IN_WINDOWS
|
||||
|
||||
#include <windows.h>
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
static HDC mHDc;
|
||||
static HGLRC mHGlrc;
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha)
|
||||
#define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key)
|
||||
|
||||
struct mxcfb_gbl_alpha {
|
||||
int enable;
|
||||
int alpha;
|
||||
};
|
||||
|
||||
struct mxcfb_color_key {
|
||||
int enable;
|
||||
unsigned int color_key;
|
||||
};
|
||||
|
||||
//static const EGLint egl_config_attribs[] =
|
||||
//{
|
||||
// EGL_RED_SIZE, 8,
|
||||
// EGL_GREEN_SIZE, 8,
|
||||
// EGL_BLUE_SIZE, 8,
|
||||
// EGL_ALPHA_SIZE, EGL_DONT_CARE,
|
||||
// EGL_DEPTH_SIZE, 16,
|
||||
// EGL_SAMPLES, 0,
|
||||
// EGL_SAMPLE_BUFFERS, 0,
|
||||
// EGL_STENCIL_SIZE, 3,
|
||||
// EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
// EGL_NONE,
|
||||
//};
|
||||
|
||||
static const EGLint egl_config_attribs[] =
|
||||
{
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_SAMPLES, 0,
|
||||
EGL_SAMPLE_BUFFERS, 0,
|
||||
EGL_STENCIL_SIZE, 0,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
//static const EGLint egl_config_attribs[] =
|
||||
//{
|
||||
// EGL_RED_SIZE, 8,
|
||||
// EGL_GREEN_SIZE, 8,
|
||||
// EGL_BLUE_SIZE, 8,
|
||||
// EGL_ALPHA_SIZE, 0,
|
||||
// EGL_DEPTH_SIZE, 16,
|
||||
// EGL_SAMPLES, 1,
|
||||
// EGL_SAMPLE_BUFFERS, 4,
|
||||
// EGL_STENCIL_SIZE, 0,
|
||||
// EGL_NONE,
|
||||
//};
|
||||
|
||||
//static const EGLint egl_config_attribs[] =
|
||||
//{
|
||||
// EGL_RED_SIZE, 8,
|
||||
// EGL_GREEN_SIZE, 8,
|
||||
// EGL_BLUE_SIZE, 8,
|
||||
// EGL_ALPHA_SIZE, 0,
|
||||
// EGL_DEPTH_SIZE, 16,
|
||||
// EGL_SAMPLES, 1,
|
||||
// EGL_SAMPLE_BUFFERS, 4,
|
||||
// EGL_STENCIL_SIZE, 0,
|
||||
// EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
// EGL_NONE,
|
||||
//};
|
||||
|
||||
static EGLDisplay egldisplay;
|
||||
static EGLSurface eglsurface;
|
||||
static EGLContext eglcontext;
|
||||
static Bool egl_init_flg = INS_FALSE;
|
||||
|
||||
#ifndef COMPILE_IN_WINDOWS
|
||||
static EGLDisplay egldisplay_fb1;
|
||||
static EGLSurface eglsurface_fb1;
|
||||
static EGLContext eglcontext_fb1;
|
||||
static Bool egl_init_flg_fb1 = INS_FALSE;
|
||||
#endif // COMPILE_IN_WINDOWS
|
||||
|
||||
#endif // COMPILE_IN_WINDOWS
|
||||
|
||||
#ifdef COMPILE_IN_WINDOWS
|
||||
Bool InitGL()
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
int iFormat;
|
||||
GLenum glewInitFlg;
|
||||
|
||||
/* get the device context (DC) */
|
||||
mHDc = GetDC(InsRenderHwnd);
|
||||
|
||||
/* set the pixel format for the DC */
|
||||
ZeroMemory(&pfd, sizeof(pfd));
|
||||
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | /// 支持在窗口中绘图
|
||||
PFD_SUPPORT_OPENGL | /// 支持 OpenGL
|
||||
PFD_DOUBLEBUFFER; /// 双缓存模式
|
||||
pfd.iPixelType = PFD_TYPE_RGBA; /// RGBA 颜色模式
|
||||
pfd.cColorBits = 24; /// 24 位颜色深度
|
||||
pfd.cDepthBits = 16; /// 16 位深度缓存
|
||||
pfd.iLayerType = PFD_MAIN_PLANE; /// 主层
|
||||
|
||||
iFormat = ChoosePixelFormat(mHDc, &pfd);
|
||||
|
||||
SetPixelFormat(mHDc, iFormat, &pfd);
|
||||
|
||||
/* create and enable the render context (RC) */
|
||||
mHGlrc = wglCreateContext(mHDc);
|
||||
|
||||
wglMakeCurrent(mHDc, mHGlrc);
|
||||
|
||||
glewInitFlg = glewInit();
|
||||
if(glewInitFlg != GLEW_OK)
|
||||
{
|
||||
const GLubyte *errinfo;
|
||||
errinfo = glewGetErrorString(glewInitFlg);
|
||||
DBG_Log(DBG_ERROR, "GLEW init error:\n%s\n", errinfo);
|
||||
}
|
||||
return INS_TRUE;
|
||||
}
|
||||
#else
|
||||
|
||||
Bool InitGL(Int32 x, Int32 y, Int32 w, Int32 h, Int32 *rtw, Int32 *rth)
|
||||
{
|
||||
#define MAX_CFG_NUM 100
|
||||
EGLint numconfigs;
|
||||
EGLConfig eglconfig[MAX_CFG_NUM];
|
||||
EGLNativeWindowType eglNativeWindow;
|
||||
EGLNativeDisplayType eglNativeDisplayType;
|
||||
|
||||
#if 1
|
||||
UInt08 fb;
|
||||
|
||||
struct mxcfb_color_key key;
|
||||
struct mxcfb_gbl_alpha gbl_alpha;
|
||||
|
||||
fb = open("/dev/fb0", O_RDWR, 0);
|
||||
if(fb < 0)
|
||||
{
|
||||
printf("open /dev/fb0 fail.\n");
|
||||
}
|
||||
|
||||
key.enable = 1;
|
||||
key.color_key = 0x0;//0xff000000;
|
||||
if(ioctl(fb, MXCFB_SET_CLR_KEY, &key) < 0)
|
||||
{
|
||||
printf("MXCFB_SET_CLR_KEY fail.\n");
|
||||
}
|
||||
|
||||
gbl_alpha.enable = 1;
|
||||
gbl_alpha.alpha = 0xff;
|
||||
if(ioctl(fb, MXCFB_SET_GBL_ALPHA, &gbl_alpha) < 0)
|
||||
{
|
||||
printf("MXCFB_SET_GBL_ALPHA fail.\n");
|
||||
}
|
||||
|
||||
close(fb);
|
||||
#endif
|
||||
|
||||
eglNativeDisplayType = fbGetDisplayByIndex(0);
|
||||
egldisplay = eglGetDisplay(eglNativeDisplayType);
|
||||
|
||||
EGLint major, minor;
|
||||
if(eglInitialize(egldisplay, &major, &minor) == EGL_TRUE)
|
||||
{
|
||||
DBG_Log(DBG_INFO, "EGL initialize success, version %d.%d\n", major, minor);
|
||||
}
|
||||
else if(eglGetError() == EGL_BAD_DISPLAY)
|
||||
{
|
||||
DBG_Log(DBG_ERROR, "EGL initialize failure, [EGL_BAD_DISPLAY]\n");
|
||||
}
|
||||
else if(eglGetError() == EGL_NOT_INITIALIZED)
|
||||
{
|
||||
DBG_Log(DBG_ERROR, "EGL initialize failure, [EGL_NOT_INITIALIZED]\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_Log(DBG_ERROR, "EGL initialize failure, [unknown error]\n");
|
||||
}
|
||||
//assert(eglGetError() == EGL_SUCCESS);
|
||||
///启用OpenGL ES Api
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
// EGLConfig cfgs[100];
|
||||
EGLint i, value;
|
||||
// EGLint num = 0;
|
||||
// eglGetConfigs(egldisplay, cfgs, 100, &num);
|
||||
// printf("List:\n");
|
||||
// for(i = 0; i < num; i++)
|
||||
// {
|
||||
// printf("CFG[%3d]: ", i);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_RED_SIZE, &value);
|
||||
// printf("EGL_RED_SIZE[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_GREEN_SIZE, &value);
|
||||
// printf("EGL_GREEN_SIZE[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_BLUE_SIZE, &value);
|
||||
// printf("EGL_BLUE_SIZE[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_ALPHA_SIZE, &value);
|
||||
// printf("EGL_ALPHA_SIZE[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_BUFFER_SIZE, &value);
|
||||
// printf("EGL_BUFFER_SIZE[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_DEPTH_SIZE, &value);
|
||||
// printf("EGL_DEPTH_SIZE[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_SAMPLE_BUFFERS, &value);
|
||||
// printf("EGL_SAMPLE_BUFFERS[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_SAMPLES, &value);
|
||||
// printf("EGL_SAMPLES[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_STENCIL_SIZE, &value);
|
||||
// printf("EGL_STENCIL_SIZE[%2d] ", value);
|
||||
// eglGetConfigAttrib(egldisplay, cfgs[i], EGL_SURFACE_TYPE, &value);
|
||||
// printf("EGL_SURFACE_TYPE[%2d] ", value);
|
||||
// printf("\n");
|
||||
// }
|
||||
|
||||
eglChooseConfig(egldisplay, egl_config_attribs, eglconfig, MAX_CFG_NUM, &numconfigs);
|
||||
printf("Configurations:[%d]\n", numconfigs);
|
||||
for(i = 0; i < numconfigs; i++)
|
||||
{
|
||||
printf("CFG[%3d]: ", i);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_RED_SIZE, &value);
|
||||
printf("EGL_RED_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_GREEN_SIZE, &value);
|
||||
printf("EGL_GREEN_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_BLUE_SIZE, &value);
|
||||
printf("EGL_BLUE_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_ALPHA_SIZE, &value);
|
||||
printf("EGL_ALPHA_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_BUFFER_SIZE, &value);
|
||||
printf("EGL_BUFFER_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_DEPTH_SIZE, &value);
|
||||
printf("EGL_DEPTH_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SAMPLE_BUFFERS, &value);
|
||||
printf("EGL_SAMPLE_BUFFERS[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SAMPLES, &value);
|
||||
printf("EGL_SAMPLES[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_STENCIL_SIZE, &value);
|
||||
printf("EGL_STENCIL_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SURFACE_TYPE, &value);
|
||||
printf("EGL_SURFACE_TYPE[%2d] ", value);
|
||||
printf("\n");
|
||||
}
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
assert(numconfigs != 0);
|
||||
for(i = 0; i < numconfigs; i++)
|
||||
{
|
||||
// eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_ALPHA_SIZE, &value);
|
||||
// if(value != 0)continue;
|
||||
// eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_BUFFER_SIZE, &value);
|
||||
// if(value != 24)continue;
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_STENCIL_SIZE, &value);
|
||||
if(value != 0)continue;
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SAMPLE_BUFFERS, &value);
|
||||
if(value != 1)continue;
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SAMPLES, &value);
|
||||
if(value != 4)continue;
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_DEPTH_SIZE, &value);
|
||||
if(value != 16)continue;
|
||||
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
assert(i != 0);
|
||||
i--;
|
||||
printf("Use Configuration:[%d]\n", i);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_RED_SIZE, &value);
|
||||
printf("EGL_RED_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_GREEN_SIZE, &value);
|
||||
printf("EGL_GREEN_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_BLUE_SIZE, &value);
|
||||
printf("EGL_BLUE_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_ALPHA_SIZE, &value);
|
||||
printf("EGL_ALPHA_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_BUFFER_SIZE, &value);
|
||||
printf("EGL_BUFFER_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_DEPTH_SIZE, &value);
|
||||
printf("EGL_DEPTH_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SAMPLE_BUFFERS, &value);
|
||||
printf("EGL_SAMPLE_BUFFERS[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SAMPLES, &value);
|
||||
printf("EGL_SAMPLES[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_STENCIL_SIZE, &value);
|
||||
printf("EGL_STENCIL_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay, eglconfig[i], EGL_SURFACE_TYPE, &value);
|
||||
printf("EGL_SURFACE_TYPE[%2d] ", value);
|
||||
printf("\n");
|
||||
|
||||
eglNativeWindow = fbCreateWindow(eglNativeDisplayType, x, y, w, h);
|
||||
assert(eglNativeWindow);
|
||||
|
||||
eglsurface = eglCreateWindowSurface(egldisplay, eglconfig[i], eglNativeWindow, NULL);
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
///指定使用OpenGL ES的版本
|
||||
EGLint ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
||||
|
||||
eglcontext = eglCreateContext(egldisplay, eglconfig[i], EGL_NO_CONTEXT, ContextAttribList);
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
|
||||
eglMakeCurrent(egldisplay, eglsurface, eglsurface, eglcontext);
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
|
||||
///fb区域大小,在EGL初始化中query获取
|
||||
if(rtw != NULL)
|
||||
{
|
||||
eglQuerySurface(egldisplay, eglsurface, EGL_WIDTH, rtw);
|
||||
DBG_Log(DBG_INFO, "EGL_WIDTH:%d, width:%d\n", EGL_WIDTH, *rtw);
|
||||
}
|
||||
if(rth != NULL)
|
||||
{
|
||||
eglQuerySurface(egldisplay, eglsurface, EGL_HEIGHT, rth);
|
||||
DBG_Log(DBG_INFO, "EGL_HEIGHT:%d, width:%d\n", EGL_HEIGHT, *rth);
|
||||
}
|
||||
|
||||
printf("InitGL end\n");
|
||||
egl_init_flg = INS_TRUE;
|
||||
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
Bool InitGL_FB1(Int32 x, Int32 y, Int32 w, Int32 h, Int32 *rtw, Int32 *rth)
|
||||
{
|
||||
#define MAX_CFG_NUM 100
|
||||
EGLint numconfigs;
|
||||
EGLConfig eglconfig[MAX_CFG_NUM];
|
||||
EGLNativeWindowType eglNativeWindow;
|
||||
EGLNativeDisplayType eglNativeDisplayType;
|
||||
EGLint i, value;
|
||||
|
||||
eglNativeDisplayType = fbGetDisplayByIndex(1);
|
||||
egldisplay_fb1 = eglGetDisplay(eglNativeDisplayType);
|
||||
|
||||
EGLint major, minor;
|
||||
if(eglInitialize(egldisplay_fb1, &major, &minor) == EGL_TRUE)
|
||||
{
|
||||
DBG_Log(DBG_INFO, "EGL initialize success, version %d.%d\n", major, minor);
|
||||
}
|
||||
else if(eglGetError() == EGL_BAD_DISPLAY)
|
||||
{
|
||||
DBG_Log(DBG_ERROR, "EGL initialize failure, [EGL_BAD_DISPLAY]\n");
|
||||
}
|
||||
else if(eglGetError() == EGL_NOT_INITIALIZED)
|
||||
{
|
||||
DBG_Log(DBG_ERROR, "EGL initialize failure, [EGL_NOT_INITIALIZED]\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_Log(DBG_ERROR, "EGL initialize failure, [unknown error]\n");
|
||||
}
|
||||
//assert(eglGetError() == EGL_SUCCESS);
|
||||
///启用OpenGL ES Api
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
eglChooseConfig(egldisplay_fb1, egl_config_attribs, eglconfig, MAX_CFG_NUM, &numconfigs);
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
assert(numconfigs != 0);
|
||||
|
||||
for(i = 0; i < numconfigs; i++)
|
||||
{
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_ALPHA_SIZE, &value);
|
||||
if(value != 0)continue;
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_BUFFER_SIZE, &value);
|
||||
if(value != 24)continue;
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_STENCIL_SIZE, &value);
|
||||
if(value != 0)continue;
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_SAMPLE_BUFFERS, &value);
|
||||
if(value != 1)continue;
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_SAMPLES, &value);
|
||||
if(value != 4)continue;
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_DEPTH_SIZE, &value);
|
||||
if(value != 16)continue;
|
||||
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
assert(i != 0);
|
||||
i = i-1;
|
||||
printf("Use Configuration:[%d]\n", i);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_RED_SIZE, &value);
|
||||
printf("EGL_RED_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_GREEN_SIZE, &value);
|
||||
printf("EGL_GREEN_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_BLUE_SIZE, &value);
|
||||
printf("EGL_BLUE_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_ALPHA_SIZE, &value);
|
||||
printf("EGL_ALPHA_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_BUFFER_SIZE, &value);
|
||||
printf("EGL_BUFFER_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_DEPTH_SIZE, &value);
|
||||
printf("EGL_DEPTH_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_SAMPLE_BUFFERS, &value);
|
||||
printf("EGL_SAMPLE_BUFFERS[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_SAMPLES, &value);
|
||||
printf("EGL_SAMPLES[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_STENCIL_SIZE, &value);
|
||||
printf("EGL_STENCIL_SIZE[%2d] ", value);
|
||||
eglGetConfigAttrib(egldisplay_fb1, eglconfig[i], EGL_SURFACE_TYPE, &value);
|
||||
printf("EGL_SURFACE_TYPE[%2d] ", value);
|
||||
printf("\n");
|
||||
|
||||
eglNativeWindow = fbCreateWindow(eglNativeDisplayType, x, y, w, h);
|
||||
assert(eglNativeWindow);
|
||||
|
||||
eglsurface_fb1 = eglCreateWindowSurface(egldisplay_fb1, eglconfig[i], eglNativeWindow, NULL);
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
///指定使用OpenGL ES的版本
|
||||
EGLint ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
||||
|
||||
eglcontext_fb1 = eglCreateContext(egldisplay_fb1, eglconfig[i], EGL_NO_CONTEXT, ContextAttribList);
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
|
||||
eglMakeCurrent(egldisplay_fb1, eglsurface_fb1, eglsurface_fb1, eglcontext_fb1);
|
||||
assert(eglGetError() == EGL_SUCCESS);
|
||||
|
||||
///fb区域大小,在EGL初始化中query获取
|
||||
if(rtw != NULL)
|
||||
{
|
||||
eglQuerySurface(egldisplay_fb1, eglsurface_fb1, EGL_WIDTH, rtw);
|
||||
DBG_Log(DBG_INFO, "EGL_WIDTH:%d, width:%d\n", EGL_WIDTH, *rtw);
|
||||
}
|
||||
if(rth != NULL)
|
||||
{
|
||||
eglQuerySurface(egldisplay_fb1, eglsurface_fb1, EGL_HEIGHT, rth);
|
||||
DBG_Log(DBG_INFO, "EGL_HEIGHT:%d, width:%d\n", EGL_HEIGHT, *rth);
|
||||
}
|
||||
|
||||
egl_init_flg_fb1 = INS_TRUE;
|
||||
printf("InitGL_FB1 end\n");
|
||||
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
Bool SwapGLBuffer_FB1()
|
||||
{
|
||||
glFinish();
|
||||
eglSwapBuffers(egldisplay_fb1, eglsurface_fb1);
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
void DeInitGL_FB1()
|
||||
{
|
||||
if(egl_init_flg_fb1 == INS_FALSE)
|
||||
{
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
eglSwapBuffers(egldisplay_fb1, eglsurface_fb1);
|
||||
eglMakeCurrent(egldisplay_fb1, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
//assert(eglGetError() == EGL_SUCCESS);
|
||||
eglDestroyContext(egldisplay_fb1, eglcontext_fb1);
|
||||
eglDestroySurface(egldisplay_fb1, eglsurface_fb1);
|
||||
eglTerminate(egldisplay_fb1);
|
||||
//assert(eglGetError() == EGL_SUCCESS);
|
||||
eglReleaseThread();
|
||||
egl_init_flg_fb1 = INS_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COMPILE_IN_WINDOWS
|
||||
|
||||
Bool SwapGLBuffer()
|
||||
{
|
||||
glFinish();
|
||||
#ifdef COMPILE_IN_WINDOWS
|
||||
SwapBuffers(mHDc);
|
||||
#else
|
||||
eglSwapBuffers(egldisplay, eglsurface);
|
||||
#endif // COMPILE_IN_WINDOWS
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
void DeInitGL()
|
||||
{
|
||||
#ifdef COMPILE_IN_WINDOWS
|
||||
/* get the device context (DC) */
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(mHGlrc);
|
||||
ReleaseDC(InsRenderHwnd, mHDc);
|
||||
#else
|
||||
if(egl_init_flg == INS_FALSE)
|
||||
{
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
eglSwapBuffers(egldisplay, eglsurface);
|
||||
eglMakeCurrent(egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
//assert(eglGetError() == EGL_SUCCESS);
|
||||
eglDestroyContext(egldisplay, eglcontext);
|
||||
eglDestroySurface(egldisplay, eglsurface);
|
||||
eglTerminate(egldisplay);
|
||||
//assert(eglGetError() == EGL_SUCCESS);
|
||||
eglReleaseThread();
|
||||
egl_init_flg = INS_TRUE;
|
||||
}
|
||||
#endif // COMPILE_IN_WINDOWS
|
||||
}
|
||||
65
insDavi2.0/src/lib/InsGL.d
Normal file
65
insDavi2.0/src/lib/InsGL.d
Normal file
@@ -0,0 +1,65 @@
|
||||
src/lib/InsGL.o: src/lib/InsGL.c \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/features.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/cdefs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wordsize.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/gnu/stubs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stddef.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/typesizes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/libio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/_G_config.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/wchar.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stdarg.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sys_errlist.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdlib.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitflags.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitstatus.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/byteswap.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sigset.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/sysmacros.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/pthreadtypes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/alloca.h \
|
||||
include/InsCfg.h include/lib/InsGL.h include/BaseTypes.h \
|
||||
include/InsDbg.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/stat.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stat.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/ioctl.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/ioctls.h \
|
||||
/home/lst/workspace/rootfs//usr/src/linux/include/asm/ioctls.h \
|
||||
/home/lst/workspace/rootfs//usr/src/linux/include/asm-generic/ioctls.h \
|
||||
/home/lst/workspace/rootfs//usr/src/linux/include/linux/ioctl.h \
|
||||
/home/lst/workspace/rootfs//usr/src/linux/include/asm/ioctl.h \
|
||||
/home/lst/workspace/rootfs//usr/src/linux/include/asm-generic/ioctl.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/ioctl-types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/ttydefaults.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/fcntl.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/fcntl.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/unistd.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/posix_opt.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/environments.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/confname.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/getopt.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/assert.h \
|
||||
/home/lst/workspace/rootfs//usr/include/EGL/egl.h \
|
||||
/home/lst/workspace/rootfs//usr/include/EGL/eglplatform.h \
|
||||
/home/lst/workspace/rootfs//usr/include/KHR/khrplatform.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stdint.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdint.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wchar.h \
|
||||
/home/lst/workspace/rootfs//usr/include/EGL/eglvivante.h \
|
||||
/home/lst/workspace/rootfs//usr/include/EGL/eglrename.h \
|
||||
/home/lst/workspace/rootfs//usr/include/EGL/eglext.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2platform.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2rename.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2ext.h
|
||||
BIN
insDavi2.0/src/lib/InsGL.o
Normal file
BIN
insDavi2.0/src/lib/InsGL.o
Normal file
Binary file not shown.
104
insDavi2.0/src/lib/InsJpeg.c
Normal file
104
insDavi2.0/src/lib/InsJpeg.c
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <lib/InsJpeg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <jpeglib.h>
|
||||
|
||||
struct my_error_mgr {
|
||||
struct jpeg_error_mgr pub; /* "public" fields */
|
||||
|
||||
jmp_buf setjmp_buffer; /* for return to caller */
|
||||
};
|
||||
|
||||
typedef struct my_error_mgr * my_error_ptr;
|
||||
|
||||
static void my_error_exit (j_common_ptr cinfo)
|
||||
{
|
||||
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
|
||||
my_error_ptr myerr = (my_error_ptr) cinfo->err;
|
||||
|
||||
/* Always display the message. */
|
||||
/* We could postpone this until after returning, if we chose. */
|
||||
(*cinfo->err->output_message) (cinfo);
|
||||
|
||||
/* Return control to the setjmp point */
|
||||
longjmp(myerr->setjmp_buffer, 1);
|
||||
}
|
||||
|
||||
/*RGB888 only*/
|
||||
Bool LoadJpegFromMem(void *mem, UInt32 memSz, Int32 *width, Int32 *height, UInt32 *format, void **bmp, UInt32 bmpSize)
|
||||
{
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
JSAMPARRAY buffer;
|
||||
Int32 seek, row_stride;
|
||||
#define GL_RGB 0x1907
|
||||
#define GL_RGBA 0x1908
|
||||
|
||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
if (setjmp(jerr.setjmp_buffer)) {
|
||||
/* If we get here, the JPEG code has signaled an error.
|
||||
* We need to clean up the JPEG object, close the input file, and return.
|
||||
*/
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
jpeg_create_decompress(&cinfo);
|
||||
jpeg_mem_src(&cinfo, mem, memSz);
|
||||
(void) jpeg_read_header(&cinfo, TRUE);
|
||||
(void) jpeg_start_decompress(&cinfo);
|
||||
|
||||
if(cinfo.output_components != 3)
|
||||
{
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
// printf("LoadJpegFromMem:[%d x %d]\n", *width, *height);
|
||||
row_stride = cinfo.output_width * cinfo.output_components;
|
||||
if(bmp[0] != NULL && bmpSize > 0)
|
||||
{
|
||||
if(cinfo.output_height * row_stride > bmpSize)
|
||||
{
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return INS_FALSE;
|
||||
}
|
||||
}
|
||||
else if(bmp[0] == NULL)
|
||||
{
|
||||
bmp[0] = malloc(cinfo.output_height * row_stride);
|
||||
}
|
||||
else
|
||||
{
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
*width = cinfo.output_width;
|
||||
*height = cinfo.output_height;
|
||||
*format = GL_RGB;
|
||||
buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||
|
||||
seek = (cinfo.output_height-1) * row_stride;
|
||||
while(cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
// printf("jpeg_read_scanlines[%u]\n", seek);
|
||||
(void)jpeg_read_scanlines(&cinfo, buffer, 1);
|
||||
// printf("memcpy[%u]\n", seek);
|
||||
memcpy(bmp[0]+seek, buffer[0], row_stride);
|
||||
seek -= row_stride;
|
||||
// printf("(%d, %d, %d)\n", buffer[0][0], buffer[0][1], buffer[0][2]);
|
||||
}
|
||||
(void)jpeg_finish_decompress(&cinfo);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
|
||||
#undef GL_RGB
|
||||
#undef GL_RGBA
|
||||
|
||||
return INS_TRUE;
|
||||
}
|
||||
41
insDavi2.0/src/lib/InsJpeg.d
Normal file
41
insDavi2.0/src/lib/InsJpeg.d
Normal file
@@ -0,0 +1,41 @@
|
||||
src/lib/InsJpeg.o: src/lib/InsJpeg.c include/lib/InsJpeg.h \
|
||||
include/BaseTypes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/features.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/cdefs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wordsize.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/gnu/stubs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stddef.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/typesizes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/libio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/_G_config.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/wchar.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stdarg.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sys_errlist.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdlib.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitflags.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitstatus.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/byteswap.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sigset.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/sysmacros.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/pthreadtypes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/alloca.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/setjmp.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/setjmp.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/string.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/xlocale.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/string.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/string2.h \
|
||||
/home/lst/workspace/jpeg/jpeg-9c/install/include/jpeglib.h \
|
||||
/home/lst/workspace/jpeg/jpeg-9c/install/include/jconfig.h \
|
||||
/home/lst/workspace/jpeg/jpeg-9c/install/include/jmorecfg.h
|
||||
BIN
insDavi2.0/src/lib/InsJpeg.o
Normal file
BIN
insDavi2.0/src/lib/InsJpeg.o
Normal file
Binary file not shown.
307
insDavi2.0/src/lib/InsMatrix.c
Normal file
307
insDavi2.0/src/lib/InsMatrix.c
Normal file
@@ -0,0 +1,307 @@
|
||||
#include <lib/InsMatrix.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define PI_OVER_180 0.01745329251994329444f
|
||||
#define EPSILON_E3 (float)(1E-3)
|
||||
#define CompareFloat(a, b) ((fabs(a-b)<EPSILON_E3)?1:0) //比较两个浮点数是否相等,相等为1,不等为0
|
||||
|
||||
GLfloat *MultMatrix4x4(GLfloat *matC, GLfloat *matA, GLfloat *matB)
|
||||
{
|
||||
GLfloat matT[4*4];
|
||||
matT[ 0] = matA[ 0] * matB[ 0] + matA[ 1] * matB[ 4] + matA[ 2] * matB[ 8] + matA[ 3] * matB[12];
|
||||
matT[ 1] = matA[ 0] * matB[ 1] + matA[ 1] * matB[ 5] + matA[ 2] * matB[ 9] + matA[ 3] * matB[13];
|
||||
matT[ 2] = matA[ 0] * matB[ 2] + matA[ 1] * matB[ 6] + matA[ 2] * matB[10] + matA[ 3] * matB[14];
|
||||
matT[ 3] = matA[ 0] * matB[ 3] + matA[ 1] * matB[ 7] + matA[ 2] * matB[11] + matA[ 3] * matB[15];
|
||||
matT[ 4] = matA[ 4] * matB[ 0] + matA[ 5] * matB[ 4] + matA[ 6] * matB[ 8] + matA[ 7] * matB[12];
|
||||
matT[ 5] = matA[ 4] * matB[ 1] + matA[ 5] * matB[ 5] + matA[ 6] * matB[ 9] + matA[ 7] * matB[13];
|
||||
matT[ 6] = matA[ 4] * matB[ 2] + matA[ 5] * matB[ 6] + matA[ 6] * matB[10] + matA[ 7] * matB[14];
|
||||
matT[ 7] = matA[ 4] * matB[ 3] + matA[ 5] * matB[ 7] + matA[ 6] * matB[11] + matA[ 7] * matB[15];
|
||||
matT[ 8] = matA[ 8] * matB[ 0] + matA[ 9] * matB[ 4] + matA[10] * matB[ 8] + matA[11] * matB[12];
|
||||
matT[ 9] = matA[ 8] * matB[ 1] + matA[ 9] * matB[ 5] + matA[10] * matB[ 9] + matA[11] * matB[13];
|
||||
matT[10] = matA[ 8] * matB[ 2] + matA[ 9] * matB[ 6] + matA[10] * matB[10] + matA[11] * matB[14];
|
||||
matT[11] = matA[ 8] * matB[ 3] + matA[ 9] * matB[ 7] + matA[10] * matB[11] + matA[11] * matB[15];
|
||||
matT[12] = matA[12] * matB[ 0] + matA[13] * matB[ 4] + matA[14] * matB[ 8] + matA[15] * matB[12];
|
||||
matT[13] = matA[12] * matB[ 1] + matA[13] * matB[ 5] + matA[14] * matB[ 9] + matA[15] * matB[13];
|
||||
matT[14] = matA[12] * matB[ 2] + matA[13] * matB[ 6] + matA[14] * matB[10] + matA[15] * matB[14];
|
||||
matT[15] = matA[12] * matB[ 3] + matA[13] * matB[ 7] + matA[14] * matB[11] + matA[15] * matB[15];
|
||||
|
||||
matC[ 0] = matT[ 0]; matC[ 1] = matT[ 1]; matC[ 2] = matT[ 2]; matC[ 3] = matT[ 3];
|
||||
matC[ 4] = matT[ 4]; matC[ 5] = matT[ 5]; matC[ 6] = matT[ 6]; matC[ 7] = matT[ 7];
|
||||
matC[ 8] = matT[ 8]; matC[ 9] = matT[ 9]; matC[10] = matT[10]; matC[11] = matT[11];
|
||||
matC[12] = matT[12]; matC[13] = matT[13]; matC[14] = matT[14]; matC[15] = matT[15];
|
||||
|
||||
return matC;
|
||||
}
|
||||
|
||||
GLfloat *MultMatrix4x4Vec4x1(GLfloat *vecB, GLfloat *matA, GLfloat *vecA)
|
||||
{
|
||||
GLfloat vecTmp[4];
|
||||
|
||||
vecTmp[0] = vecA[0]*matA[0*4+0] + vecA[1]*matA[1*4+0] + vecA[2]*matA[2*4+0] + vecA[3]*matA[3*4+0];
|
||||
vecTmp[1] = vecA[0]*matA[0*4+1] + vecA[1]*matA[1*4+1] + vecA[2]*matA[2*4+1] + vecA[3]*matA[3*4+1];
|
||||
vecTmp[2] = vecA[0]*matA[0*4+2] + vecA[1]*matA[1*4+2] + vecA[2]*matA[2*4+2] + vecA[3]*matA[3*4+2];
|
||||
vecTmp[3] = vecA[0]*matA[0*4+3] + vecA[1]*matA[1*4+3] + vecA[2]*matA[2*4+3] + vecA[3]*matA[3*4+3];
|
||||
|
||||
vecB[0] = vecTmp[0];
|
||||
vecB[1] = vecTmp[1];
|
||||
vecB[2] = vecTmp[2];
|
||||
vecB[3] = vecTmp[3];
|
||||
|
||||
return vecB;
|
||||
}
|
||||
|
||||
GLfloat *CopyMatrix4x4(GLfloat *matDes, GLfloat *matSrc)
|
||||
{
|
||||
matDes[0] = matSrc[0]; matDes[1] = matSrc[1];
|
||||
matDes[2] = matSrc[2]; matDes[3] = matSrc[3];
|
||||
matDes[4] = matSrc[4]; matDes[5] = matSrc[5];
|
||||
matDes[6] = matSrc[6]; matDes[7] = matSrc[7];
|
||||
matDes[8] = matSrc[8]; matDes[9] = matSrc[9];
|
||||
matDes[10] = matSrc[10]; matDes[11] = matSrc[11];
|
||||
matDes[12] = matSrc[12]; matDes[13] = matSrc[13];
|
||||
matDes[14] = matSrc[14]; matDes[15] = matSrc[15];
|
||||
|
||||
return matDes;
|
||||
}
|
||||
|
||||
Bool InvertMatrix4x4(GLfloat *inverse, GLfloat *src)
|
||||
{
|
||||
int i, j, k;
|
||||
double t;
|
||||
double temp[4][4];
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
for (j=0; j<4; j++) {
|
||||
temp[i][j] = src[i*4+j];
|
||||
}
|
||||
}
|
||||
|
||||
LoadIdentityMatrix(inverse);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
/*
|
||||
** Look for largest element in column
|
||||
*/
|
||||
int swap = i;
|
||||
for (j = i + 1; j < 4; j++) {
|
||||
if (fabs(temp[j][i]) > fabs(temp[i][i])) {
|
||||
swap = j;
|
||||
}
|
||||
}
|
||||
|
||||
if (swap != i) {
|
||||
/*
|
||||
** Swap rows.
|
||||
*/
|
||||
for (k = 0; k < 4; k++) {
|
||||
t = temp[i][k];
|
||||
temp[i][k] = temp[swap][k];
|
||||
temp[swap][k] = t;
|
||||
|
||||
t = inverse[i*4+k];
|
||||
inverse[i*4+k] = inverse[swap*4+k];
|
||||
inverse[swap*4+k] = t;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp[i][i] == 0) {
|
||||
/*
|
||||
** No non-zero pivot. The matrix is singular, which shouldn't
|
||||
** happen. This means the user gave us a bad matrix.
|
||||
*/
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
t = temp[i][i];
|
||||
for (k = 0; k < 4; k++) {
|
||||
temp[i][k] /= t;
|
||||
inverse[i*4+k] /= t;
|
||||
}
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (j != i) {
|
||||
t = temp[j][i];
|
||||
for (k = 0; k < 4; k++) {
|
||||
temp[j][k] -= temp[i][k]*t;
|
||||
inverse[j*4+k] -= inverse[i*4+k]*t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
GLfloat *SetRotateMatrix4x4_X_Axis(GLfloat *m, GLfloat angle)
|
||||
{
|
||||
float radians = PI_OVER_180*angle;
|
||||
|
||||
LoadIdentityMatrix(m);
|
||||
|
||||
m[5] = cosf(radians);
|
||||
m[6] = sinf(radians);
|
||||
m[9] = -m[6];//-sinf(radians);
|
||||
m[10] = m[5];//cosf(radians);
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *RotateMatrix4x4_X_Axis(GLfloat *m, GLfloat angle)
|
||||
{
|
||||
GLfloat tm[4*4];
|
||||
|
||||
SetRotateMatrix4x4_X_Axis(tm, angle);
|
||||
MultMatrix4x4(m, tm, m);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *SetRotateMatrix4x4_Y_Axis(GLfloat *m, GLfloat angle)
|
||||
{
|
||||
float radians = PI_OVER_180*angle;
|
||||
|
||||
LoadIdentityMatrix(m);
|
||||
|
||||
m[0] = cosf(radians);
|
||||
m[2] = -sinf(radians);
|
||||
m[8] = -m[2];//sinf(radians);
|
||||
m[10] = m[0];//cosf(radians);
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *RotateMatrix4x4_Y_Axis(GLfloat *m, GLfloat angle)
|
||||
{
|
||||
GLfloat tm[4*4];
|
||||
|
||||
SetRotateMatrix4x4_Y_Axis(tm, angle);
|
||||
MultMatrix4x4(m, tm, m);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *SetRotateMatrix4x4_Z_Axis(GLfloat *m, GLfloat angle)
|
||||
{
|
||||
float radians = PI_OVER_180*angle;
|
||||
|
||||
LoadIdentityMatrix(m);
|
||||
|
||||
m[0] = cosf(radians);
|
||||
m[1] = sinf(radians);
|
||||
m[4] = -m[1];//-sinf(radians);
|
||||
m[5] = m[0];//cosf(radians);
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *RotateMatrix4x4_Z_Axis(GLfloat *m, GLfloat angle)
|
||||
{
|
||||
GLfloat tm[4*4];
|
||||
|
||||
SetRotateMatrix4x4_Z_Axis(tm, angle);
|
||||
MultMatrix4x4(m, tm, m);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/*
|
||||
* 绕任意轴向量axis_nor逆时针旋转angle度
|
||||
*/
|
||||
GLfloat *SetRotateMat4x4(GLfloat *mat4x4, Vec3f *axis_nor, GLfloat angle)
|
||||
{
|
||||
float c, s, one_c;
|
||||
|
||||
float xx, yy, zz;
|
||||
float xs, ys, zs;
|
||||
float xy, xz, yz;
|
||||
|
||||
c = cosf(angle*PI_OVER_180);
|
||||
s = sinf(angle*PI_OVER_180);
|
||||
one_c = 1.0 - c;
|
||||
|
||||
xx = axis_nor->x * axis_nor->x;
|
||||
yy = axis_nor->y * axis_nor->y;
|
||||
zz = axis_nor->z * axis_nor->z;
|
||||
|
||||
xs = axis_nor->x * s;
|
||||
ys = axis_nor->y * s;
|
||||
zs = axis_nor->z * s;
|
||||
|
||||
xy = axis_nor->x * axis_nor->y;
|
||||
xz = axis_nor->x * axis_nor->z;
|
||||
yz = axis_nor->y * axis_nor->z;
|
||||
|
||||
mat4x4[ 0] = (one_c * xx) + c;
|
||||
mat4x4[ 1] = (one_c * xy) + zs;
|
||||
mat4x4[ 2] = (one_c * xz) - ys;
|
||||
mat4x4[ 3] = 0.0;
|
||||
|
||||
mat4x4[ 4] = (one_c * xy) - zs;
|
||||
mat4x4[ 5] = (one_c * yy) + c;
|
||||
mat4x4[ 6] = (one_c * yz) + xs;
|
||||
mat4x4[ 7] = 0.0;
|
||||
|
||||
mat4x4[ 8] = (one_c * xz) + ys;
|
||||
mat4x4[ 9] = (one_c * yz) - xs;
|
||||
mat4x4[10] = (one_c * zz) + c;
|
||||
mat4x4[11] = 0.0;
|
||||
|
||||
mat4x4[12] = 0.0;
|
||||
mat4x4[13] = 0.0;
|
||||
mat4x4[14] = 0.0;
|
||||
mat4x4[15] = 1.0;
|
||||
|
||||
return mat4x4;
|
||||
}
|
||||
|
||||
/*
|
||||
* 绕任意轴向量axis_nor逆时针旋转angle度
|
||||
*/
|
||||
GLfloat *RotateMat4x4(GLfloat *mat4x4, Vec3f *axis_nor, GLfloat angle)
|
||||
{
|
||||
GLfloat tm[4*4];
|
||||
|
||||
SetRotateMat4x4(tm, axis_nor, angle);
|
||||
MultMatrix4x4(mat4x4, tm, mat4x4);
|
||||
|
||||
return mat4x4;
|
||||
}
|
||||
|
||||
GLfloat *SetTranslateMatrix4x4 (GLfloat *m, GLfloat trX, GLfloat trY, GLfloat trZ)
|
||||
{
|
||||
LoadIdentityMatrix(m);
|
||||
|
||||
m[12] = trX;
|
||||
m[13] = trY;
|
||||
m[14] = trZ;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *TranslateMatrix4x4 (GLfloat *m, GLfloat trX, GLfloat trY, GLfloat trZ)
|
||||
{
|
||||
GLfloat tm[4*4];
|
||||
|
||||
SetTranslateMatrix4x4(tm, trX, trY, trZ);
|
||||
MultMatrix4x4(m, tm, m);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *SetScaleMatrix4x4 (GLfloat *m, GLfloat scaleX, GLfloat scaleY, GLfloat scaleZ)
|
||||
{
|
||||
LoadIdentityMatrix(m);
|
||||
|
||||
m[ 0] = scaleX;
|
||||
m[ 5] = scaleY;
|
||||
m[10] = scaleZ;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
GLfloat *ScaleMatrix4x4 (GLfloat *m, GLfloat scaleX, GLfloat scaleY, GLfloat scaleZ)
|
||||
{
|
||||
GLfloat tm[4*4];
|
||||
|
||||
SetScaleMatrix4x4(tm, scaleX, scaleY, scaleZ);
|
||||
MultMatrix4x4(m, tm, m);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
23
insDavi2.0/src/lib/InsMatrix.d
Normal file
23
insDavi2.0/src/lib/InsMatrix.d
Normal file
@@ -0,0 +1,23 @@
|
||||
src/lib/InsMatrix.o: src/lib/InsMatrix.c include/lib/InsMatrix.h \
|
||||
include/InsCfg.h include/BaseTypes.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2platform.h \
|
||||
/home/lst/workspace/rootfs//usr/include/KHR/khrplatform.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stdint.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdint.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/features.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/cdefs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wordsize.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/gnu/stubs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wchar.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2rename.h \
|
||||
/home/lst/workspace/rootfs//usr/include/GLES2/gl2ext.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/math.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/huge_val.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/huge_valf.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/huge_vall.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/inf.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/nan.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/mathdef.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/mathcalls.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/mathinline.h
|
||||
BIN
insDavi2.0/src/lib/InsMatrix.o
Normal file
BIN
insDavi2.0/src/lib/InsMatrix.o
Normal file
Binary file not shown.
164
insDavi2.0/src/lib/InsPng.c
Normal file
164
insDavi2.0/src/lib/InsPng.c
Normal file
@@ -0,0 +1,164 @@
|
||||
#include <lib/InsPng.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <zlib.h>
|
||||
#include <png.h>
|
||||
#include <pngstruct.h>
|
||||
#include <pnginfo.h>
|
||||
|
||||
typedef struct Struct_MemPng
|
||||
{
|
||||
UInt08 *data;
|
||||
Int32 size;
|
||||
Int32 offset;
|
||||
} MemPng;
|
||||
|
||||
static void callback_ReadMemPng(png_structp ptrPng, png_bytep data, png_size_t length)
|
||||
{
|
||||
MemPng *mPngSrc = (MemPng*)ptrPng->io_ptr;
|
||||
if(mPngSrc == NULL)
|
||||
{
|
||||
png_error(ptrPng, "not mem png source define");
|
||||
}
|
||||
else if(mPngSrc->offset + length <= mPngSrc->size)
|
||||
{
|
||||
memcpy(data, mPngSrc->data+mPngSrc->offset, length);
|
||||
mPngSrc->offset += length;
|
||||
}
|
||||
else
|
||||
{
|
||||
png_error(ptrPng, "more mem png data is needed");
|
||||
}
|
||||
}
|
||||
|
||||
/*RGB888 only*/
|
||||
Bool LoadPngFromMem(void *mem, UInt32 memSz, Int32 *width, Int32 *height, UInt32 *format, void **bmp, UInt32 bmpSize)
|
||||
{
|
||||
Int32 i, j, w, h, type;
|
||||
UInt32 fmt;
|
||||
MemPng mSrc =
|
||||
{
|
||||
.data = mem,
|
||||
.size = memSz,
|
||||
.offset = 0
|
||||
};
|
||||
UInt08 *buff;
|
||||
#define GL_RGB 0x1907
|
||||
#define GL_RGBA 0x1908
|
||||
|
||||
png_structp ptrPng = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
|
||||
if(ptrPng == 0)return INS_FALSE;
|
||||
|
||||
png_infop ptrInfo = png_create_info_struct(ptrPng);
|
||||
if(ptrInfo == 0)
|
||||
{
|
||||
png_destroy_read_struct(&ptrPng, 0, 0);
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
if(setjmp(png_jmpbuf(ptrPng)))
|
||||
{
|
||||
png_destroy_read_struct(&ptrPng, 0, 0);
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
png_set_read_fn(ptrPng, &mSrc, callback_ReadMemPng);
|
||||
png_read_png(ptrPng, ptrInfo, PNG_TRANSFORM_EXPAND, 0);
|
||||
|
||||
w = ptrInfo->width;
|
||||
h = ptrInfo->height;
|
||||
// depth = ptrInfo->pixel_depth;
|
||||
png_bytep *PtrRow = png_get_rows(ptrPng, ptrInfo);
|
||||
type = ptrInfo->color_type;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
if(bmp[0] != NULL && bmpSize > 0)
|
||||
{
|
||||
if(w*h*3 > bmpSize)
|
||||
{
|
||||
png_destroy_read_struct(&ptrPng, 0, 0);
|
||||
return INS_FALSE;
|
||||
}
|
||||
}
|
||||
else if(bmp[0] == NULL)
|
||||
{
|
||||
bmp[0] = malloc(w*h*3);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_destroy_read_struct(&ptrPng, 0, 0);
|
||||
return INS_FALSE;
|
||||
}
|
||||
buff = bmp[0];
|
||||
fmt = GL_RGB;
|
||||
for(i = 0; i < h; i++)
|
||||
{
|
||||
for(j = 0; j < w; j++)
|
||||
{
|
||||
buff[3*((h-1-i)*w+j)+0] = PtrRow[i][3*j+0];
|
||||
buff[3*((h-1-i)*w+j)+1] = PtrRow[i][3*j+1];
|
||||
buff[3*((h-1-i)*w+j)+2] = PtrRow[i][3*j+2];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGBA:
|
||||
if(bmp[0] != NULL && bmpSize > 0)
|
||||
{
|
||||
if(w*h*4 > bmpSize)
|
||||
{
|
||||
png_destroy_read_struct(&ptrPng, 0, 0);
|
||||
return INS_FALSE;
|
||||
}
|
||||
}
|
||||
else if(bmp[0] == NULL)
|
||||
{
|
||||
bmp[0] = malloc(w*h*4);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_destroy_read_struct(&ptrPng, 0, 0);
|
||||
return INS_FALSE;
|
||||
}
|
||||
buff = bmp[0];
|
||||
fmt = GL_RGBA;
|
||||
for(i = 0; i < h; i++)
|
||||
{
|
||||
for(j = 0; j < w; j++)
|
||||
{
|
||||
buff[4*((h-1-i)*w+j)+0] = PtrRow[i][4*j+0];
|
||||
buff[4*((h-1-i)*w+j)+1] = PtrRow[i][4*j+1];
|
||||
buff[4*((h-1-i)*w+j)+2] = PtrRow[i][4*j+2];
|
||||
buff[4*((h-1-i)*w+j)+3] = PtrRow[i][4*j+3];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
png_destroy_read_struct(&ptrPng, 0, 0);
|
||||
return INS_FALSE;
|
||||
}
|
||||
|
||||
*width = w;
|
||||
*height = h;
|
||||
*format = fmt;
|
||||
|
||||
return INS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
57
insDavi2.0/src/lib/InsPng.d
Normal file
57
insDavi2.0/src/lib/InsPng.d
Normal file
@@ -0,0 +1,57 @@
|
||||
src/lib/InsPng.o: src/lib/InsPng.c include/lib/InsPng.h \
|
||||
include/BaseTypes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/features.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/cdefs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wordsize.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/gnu/stubs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stddef.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/typesizes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/libio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/_G_config.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/wchar.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stdarg.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sys_errlist.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/stdio.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdlib.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitflags.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitstatus.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/byteswap.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sigset.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/sysmacros.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/pthreadtypes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/alloca.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/setjmp.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/setjmp.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/string.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/xlocale.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/string.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/string2.h \
|
||||
/home/lst/workspace/zlib/zlib_build/zlib.h \
|
||||
/home/lst/workspace/zlib/zlib_build/zconf.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include-fixed/limits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include-fixed/syslimits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/limits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/posix1_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/local_lim.h \
|
||||
/home/lst/workspace/rootfs//usr/src/linux/include/linux/limits.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/posix2_lim.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/unistd.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/posix_opt.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/environments.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/confname.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/getopt.h \
|
||||
/home/lst/workspace/libpng/libpng_build/png.h \
|
||||
/home/lst/workspace/libpng/libpng_build/pnglibconf.h \
|
||||
/home/lst/workspace/libpng/libpng_build/pngconf.h \
|
||||
/home/lst/workspace/libpng/libpng_build/pngstruct.h \
|
||||
/home/lst/workspace/libpng/libpng_build/pnginfo.h
|
||||
BIN
insDavi2.0/src/lib/InsPng.o
Normal file
BIN
insDavi2.0/src/lib/InsPng.o
Normal file
Binary file not shown.
74
insDavi2.0/src/lib/InsQueue.c
Normal file
74
insDavi2.0/src/lib/InsQueue.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <stdlib.h>
|
||||
#include <lib/InsQueue.h>
|
||||
|
||||
/**************************************************************************************
|
||||
名称:pushQ(const InsNode *pItem, InsQueue *pQ)
|
||||
说明:
|
||||
入列,加到队尾
|
||||
输入:无
|
||||
输出:无
|
||||
**************************************************************************************/
|
||||
void pushQ(const InsNode *pItem, InsQueue *pQ)
|
||||
{
|
||||
InsNode *pTmp;
|
||||
if(pQ->length < 1)
|
||||
{
|
||||
pQ->head = (InsNode*)malloc(sizeof(InsNode));
|
||||
pQ->head->data = pItem->data;
|
||||
pQ->head->next = NULL;
|
||||
pQ->tail = pQ->head;
|
||||
pQ->length = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pTmp = pQ->tail;
|
||||
pTmp->next = (InsNode*)malloc(sizeof(InsNode));
|
||||
pTmp->next->next = NULL;
|
||||
pTmp->next->data = pItem->data;
|
||||
pQ->tail = pTmp->next;
|
||||
pQ->length++;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
名称:popQ(InsQueue *pQ)
|
||||
说明:
|
||||
出列,从队首删除
|
||||
输入:无
|
||||
输出:无
|
||||
**************************************************************************************/
|
||||
void popQ(InsQueue *pQ)
|
||||
{
|
||||
InsNode *pInsNode;
|
||||
if(pQ->length > 0 && pQ->head != NULL)
|
||||
{
|
||||
pInsNode = pQ->head->next;
|
||||
free(pQ->head);
|
||||
pQ->head = pInsNode;
|
||||
pQ->length--;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
名称:head(InsQueue * pQ)
|
||||
说明:
|
||||
取队首元素
|
||||
输入:无
|
||||
输出:无
|
||||
**************************************************************************************/
|
||||
InsNode *head(InsQueue * pQ)
|
||||
{
|
||||
return pQ->head;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
名称:tail(InsQueue *pQ)
|
||||
说明:
|
||||
取队尾元素
|
||||
输入:无
|
||||
输出:无
|
||||
**************************************************************************************/
|
||||
InsNode *tail(InsQueue *pQ)
|
||||
{
|
||||
return pQ->tail;
|
||||
}
|
||||
24
insDavi2.0/src/lib/InsQueue.d
Normal file
24
insDavi2.0/src/lib/InsQueue.d
Normal file
@@ -0,0 +1,24 @@
|
||||
src/lib/InsQueue.o: src/lib/InsQueue.c \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/stdlib.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/features.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/cdefs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/wordsize.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/gnu/stubs.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/include/stddef.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitflags.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/waitstatus.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/endian.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/byteswap.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/types.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/typesizes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/select.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/sigset.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/time.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/sys/sysmacros.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/bits/pthreadtypes.h \
|
||||
/opt/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../arm-fsl-linux-gnueabi/multi-libs/usr/include/alloca.h \
|
||||
include/lib/InsQueue.h include/BaseTypes.h
|
||||
BIN
insDavi2.0/src/lib/InsQueue.o
Normal file
BIN
insDavi2.0/src/lib/InsQueue.o
Normal file
Binary file not shown.
BIN
insDavi2.0/src/lib/libcjson_linux.a
Normal file
BIN
insDavi2.0/src/lib/libcjson_linux.a
Normal file
Binary file not shown.
BIN
insDavi2.0/src/lib/libcjson_win.dll.a
Normal file
BIN
insDavi2.0/src/lib/libcjson_win.dll.a
Normal file
Binary file not shown.
BIN
insDavi2.0/src/lib/libjpeg_win.a
Normal file
BIN
insDavi2.0/src/lib/libjpeg_win.a
Normal file
Binary file not shown.
BIN
insDavi2.0/src/lib/libpng16.dll.a
Normal file
BIN
insDavi2.0/src/lib/libpng16.dll.a
Normal file
Binary file not shown.
BIN
insDavi2.0/src/lib/libzlib.dll.a
Normal file
BIN
insDavi2.0/src/lib/libzlib.dll.a
Normal file
Binary file not shown.
Reference in New Issue
Block a user