|
@@ -16,6 +16,8 @@
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+#define _GNU_SOURCE 1
|
|
|
|
+
|
|
#include "la_5.h"
|
|
#include "la_5.h"
|
|
|
|
|
|
#include <math.h>
|
|
#include <math.h>
|
|
@@ -140,6 +142,11 @@ void tnsContextMakeFBOCurrent(tnsOffscreen* off){
|
|
tnsContextMakeCurrent(off->FboContext,off->FboWindow,off->FboSurface);
|
|
tnsContextMakeCurrent(off->FboContext,off->FboWindow,off->FboSurface);
|
|
}
|
|
}
|
|
void tnsContextMakeWindowCurrent(laWindow* w){
|
|
void tnsContextMakeWindowCurrent(laWindow* w){
|
|
|
|
+#ifdef LAGUI_ANDROID
|
|
|
|
+ T->CurrentContext=MAIN.glc;
|
|
|
|
+ if (eglMakeCurrent(MAIN.egl_dpy, MAIN.egl_surf, MAIN.egl_surf, MAIN.glc) == EGL_FALSE) { logPrint("Android can't make current"); return; }
|
|
|
|
+ return;
|
|
|
|
+#endif
|
|
tnsContextMakeCurrent(w->glc,w->win,w->egl_surf);
|
|
tnsContextMakeCurrent(w->glc,w->win,w->egl_surf);
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
@@ -405,6 +412,7 @@ int tnsNewFragmentShader(char *Content){
|
|
return tnsNewFragmentShaderMaterial(Content,0,0);
|
|
return tnsNewFragmentShaderMaterial(Content,0,0);
|
|
}
|
|
}
|
|
int tnsNewGeometryShader(char *Content){
|
|
int tnsNewGeometryShader(char *Content){
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
int status = 0;
|
|
int status = 0;
|
|
char error[8192]={0};
|
|
char error[8192]={0};
|
|
GLuint GeometryShaderObject;
|
|
GLuint GeometryShaderObject;
|
|
@@ -427,6 +435,8 @@ int tnsNewGeometryShader(char *Content){
|
|
free(UseContent);
|
|
free(UseContent);
|
|
|
|
|
|
return GeometryShaderObject;
|
|
return GeometryShaderObject;
|
|
|
|
+#endif
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
tnsShader *tnsNewShaderProgram(int VertexShaderID, int FragmentShaderID, int GeometryShaderID){
|
|
tnsShader *tnsNewShaderProgram(int VertexShaderID, int FragmentShaderID, int GeometryShaderID){
|
|
@@ -1225,8 +1235,6 @@ void tnsPreTranslate3d(real x, real y, real z){
|
|
real *mat = tnsGetModelMatrix();
|
|
real *mat = tnsGetModelMatrix();
|
|
tnsMatrix44d transmat, result;
|
|
tnsMatrix44d transmat, result;
|
|
|
|
|
|
- //glTranslatef(x, y, z);
|
|
|
|
-
|
|
|
|
tnsMakeTranslationMatrix44d(transmat, x, y, z);
|
|
tnsMakeTranslationMatrix44d(transmat, x, y, z);
|
|
tnsMultiply44d(result, mat, transmat);
|
|
tnsMultiply44d(result, mat, transmat);
|
|
memcpy(mat, result, sizeof(tnsMatrix44d));
|
|
memcpy(mat, result, sizeof(tnsMatrix44d));
|
|
@@ -1258,8 +1266,6 @@ void tnsScale3d(real x, real y, real z){
|
|
real *mat = tnsGetModelMatrix();
|
|
real *mat = tnsGetModelMatrix();
|
|
tnsMatrix44d scalemat, normal_scaler, result;
|
|
tnsMatrix44d scalemat, normal_scaler, result;
|
|
|
|
|
|
- glScalef(x, y, z);
|
|
|
|
-
|
|
|
|
tnsMakeScaleMatrix44d(scalemat, x, y, z);
|
|
tnsMakeScaleMatrix44d(scalemat, x, y, z);
|
|
|
|
|
|
tnsMultiply44d(result, mat, scalemat);
|
|
tnsMultiply44d(result, mat, scalemat);
|
|
@@ -1274,8 +1280,6 @@ void tnsPreScale3d(real x, real y, real z){
|
|
real *mat = tnsGetModelMatrix();
|
|
real *mat = tnsGetModelMatrix();
|
|
tnsMatrix44d scalemat, normal_scaler, result;
|
|
tnsMatrix44d scalemat, normal_scaler, result;
|
|
|
|
|
|
- glScalef(x, y, z);
|
|
|
|
-
|
|
|
|
tnsMakeScaleMatrix44d(scalemat, x, y, z);
|
|
tnsMakeScaleMatrix44d(scalemat, x, y, z);
|
|
|
|
|
|
tnsMultiply44d(result, mat, scalemat);
|
|
tnsMultiply44d(result, mat, scalemat);
|
|
@@ -1620,7 +1624,7 @@ void tnsDrawBatchInitArrayStates(tnsBatch* batch){
|
|
tnsUniformUseTexture(cs, 0, 0);
|
|
tnsUniformUseTexture(cs, 0, 0);
|
|
}
|
|
}
|
|
int tnsDrawBatch(tnsBatch* batch, const char* OverrideCommand, real* OverrideUniformColor, int OverrideAsArray) {
|
|
int tnsDrawBatch(tnsBatch* batch, const char* OverrideCommand, real* OverrideUniformColor, int OverrideAsArray) {
|
|
- if (!batch) return;
|
|
|
|
|
|
+ if (!batch) return 0;
|
|
int Drawn=0; tnsShader *LastShader=T->BindedShader,*SaveShader=T->BindedShader; int NeedInit=1;
|
|
int Drawn=0; tnsShader *LastShader=T->BindedShader,*SaveShader=T->BindedShader; int NeedInit=1;
|
|
|
|
|
|
int IsOverrideColor=0; int PointSizeChanged=0,LineWidthChanged=0;
|
|
int IsOverrideColor=0; int PointSizeChanged=0,LineWidthChanged=0;
|
|
@@ -1701,8 +1705,12 @@ int tnsInit2DTexture(tnsTexture *t, GLint glInternalFormat, int w, int h, int Mu
|
|
t->Width = w;
|
|
t->Width = w;
|
|
t->Height = h;
|
|
t->Height = h;
|
|
t->GLTexBitsType = glInternalFormat;
|
|
t->GLTexBitsType = glInternalFormat;
|
|
|
|
+#ifdef LAGUI_ANDROID
|
|
|
|
+ t->GLTexType = GL_TEXTURE_2D;
|
|
|
|
+#else
|
|
t->GLTexType = Multisample?GL_TEXTURE_2D_MULTISAMPLE:GL_TEXTURE_2D;
|
|
t->GLTexType = Multisample?GL_TEXTURE_2D_MULTISAMPLE:GL_TEXTURE_2D;
|
|
t->Multisample = Multisample;
|
|
t->Multisample = Multisample;
|
|
|
|
+#endif
|
|
glGenTextures(1, &t->GLTexHandle);
|
|
glGenTextures(1, &t->GLTexHandle);
|
|
|
|
|
|
tnsConfigure2DTexture(t);
|
|
tnsConfigure2DTexture(t);
|
|
@@ -1731,8 +1739,10 @@ void tnsConfigure2DTexture(tnsTexture *t){
|
|
t->GLTexBitsType==GL_DEPTH_COMPONENT24||t->GLTexBitsType==GL_DEPTH_COMPONENT32F;
|
|
t->GLTexBitsType==GL_DEPTH_COMPONENT24||t->GLTexBitsType==GL_DEPTH_COMPONENT32F;
|
|
int format=isDepth?GL_DEPTH_COMPONENT:(t->GLTexBitsType==GL_R8?GL_RED:(t->GLTexBitsType==GL_RG8?GL_RG:(t->GLTexBitsType==GL_RGB8?GL_RGB:GL_RGBA)));
|
|
int format=isDepth?GL_DEPTH_COMPONENT:(t->GLTexBitsType==GL_R8?GL_RED:(t->GLTexBitsType==GL_RG8?GL_RG:(t->GLTexBitsType==GL_RGB8?GL_RGB:GL_RGBA)));
|
|
int type=GL_UNSIGNED_BYTE;
|
|
int type=GL_UNSIGNED_BYTE;
|
|
- if(t->GLTexBitsType==GL_DEPTH_STENCIL){ format=GL_DEPTH_STENCIL; type=GL_UNSIGNED_INT_24_8_EXT; }
|
|
|
|
|
|
+ if(t->GLTexBitsType==GL_DEPTH_STENCIL){ format=GL_DEPTH_STENCIL; type=GL_UNSIGNED_INT_24_8; }
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
if(t->Multisample) glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, t->Multisample, t->GLTexBitsType, t->Width, t->Height, GL_TRUE);
|
|
if(t->Multisample) glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, t->Multisample, t->GLTexBitsType, t->Width, t->Height, GL_TRUE);
|
|
|
|
+#endif
|
|
else{ glTexImage2D(GL_TEXTURE_2D, 0, t->GLTexBitsType, t->Width, t->Height, 0, format, type, 0);
|
|
else{ glTexImage2D(GL_TEXTURE_2D, 0, t->GLTexBitsType, t->Width, t->Height, 0, format, type, 0);
|
|
int a=glGetError();
|
|
int a=glGetError();
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
@@ -1747,9 +1757,9 @@ void tnsConfigure2DTexture(tnsTexture *t){
|
|
void tnsConfigure3DTexture(tnsTexture *t){
|
|
void tnsConfigure3DTexture(tnsTexture *t){
|
|
tnsBindTexture(t);
|
|
tnsBindTexture(t);
|
|
glTexImage3D(GL_TEXTURE_3D, 0, t->GLTexBitsType, t->Width, t->Height, t->Slices, 0, GL_RGBA, GL_FLOAT, 0);
|
|
glTexImage3D(GL_TEXTURE_3D, 0, t->GLTexBitsType, t->Width, t->Height, t->Slices, 0, GL_RGBA, GL_FLOAT, 0);
|
|
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
|
|
|
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
|
|
|
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
|
|
|
|
|
|
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
|
|
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
|
|
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
//glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
//glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
@@ -1762,10 +1772,12 @@ void tnsReconfigureTextureParameters(int Multisample){
|
|
for(int i=0;i<4;i++){
|
|
for(int i=0;i<4;i++){
|
|
t=o->pColor[i];
|
|
t=o->pColor[i];
|
|
if(t){
|
|
if(t){
|
|
- t->Multisample = Multisample;
|
|
|
|
int recreate=0;
|
|
int recreate=0;
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
|
|
+ t->Multisample = Multisample;
|
|
if(t->Multisample){ if(t->GLTexType==GL_TEXTURE_2D){t->GLTexType=GL_TEXTURE_2D_MULTISAMPLE; recreate=1;}}
|
|
if(t->Multisample){ if(t->GLTexType==GL_TEXTURE_2D){t->GLTexType=GL_TEXTURE_2D_MULTISAMPLE; recreate=1;}}
|
|
else { if(t->GLTexType==GL_TEXTURE_2D_MULTISAMPLE){t->GLTexType=GL_TEXTURE_2D; recreate=1;}}
|
|
else { if(t->GLTexType==GL_TEXTURE_2D_MULTISAMPLE){t->GLTexType=GL_TEXTURE_2D; recreate=1;}}
|
|
|
|
+#endif
|
|
if(recreate){
|
|
if(recreate){
|
|
glDeleteTextures(1, &t->GLTexHandle);
|
|
glDeleteTextures(1, &t->GLTexHandle);
|
|
glGenTextures(1, &t->GLTexHandle);
|
|
glGenTextures(1, &t->GLTexHandle);
|
|
@@ -1776,10 +1788,13 @@ void tnsReconfigureTextureParameters(int Multisample){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
t=o->pDepth;
|
|
t=o->pDepth;
|
|
- if(t){ int recreate=0;
|
|
|
|
|
|
+ if(t){
|
|
|
|
+ int recreate=0;
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
if((!t->Multisample && Multisample)||(t->Multisample && !Multisample)){ recreate=1; }
|
|
if((!t->Multisample && Multisample)||(t->Multisample && !Multisample)){ recreate=1; }
|
|
if(Multisample){ t->GLTexType=GL_TEXTURE_2D_MULTISAMPLE; }else{ t->GLTexType=GL_TEXTURE_2D; }
|
|
if(Multisample){ t->GLTexType=GL_TEXTURE_2D_MULTISAMPLE; }else{ t->GLTexType=GL_TEXTURE_2D; }
|
|
t->Multisample = Multisample;
|
|
t->Multisample = Multisample;
|
|
|
|
+#endif
|
|
if(recreate){
|
|
if(recreate){
|
|
glDeleteTextures(1, &t->GLTexHandle);
|
|
glDeleteTextures(1, &t->GLTexHandle);
|
|
glGenTextures(1, &t->GLTexHandle);
|
|
glGenTextures(1, &t->GLTexHandle);
|
|
@@ -1823,7 +1838,9 @@ void tnsUseMaskTexture(tnsTexture *t){
|
|
void tnsUseTexture(tnsTexture *t){
|
|
void tnsUseTexture(tnsTexture *t){
|
|
if(!t){T->StateTextureMode=0; return;}
|
|
if(!t){T->StateTextureMode=0; return;}
|
|
if(t->GLTexType == GL_TEXTURE_2D){ T->StateTexColor = t; T->StateTextureMode=2; }
|
|
if(t->GLTexType == GL_TEXTURE_2D){ T->StateTexColor = t; T->StateTextureMode=2; }
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
else if(t->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){ T->StateTexColor = t; T->StateTextureMode=3; }
|
|
else if(t->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){ T->StateTexColor = t; T->StateTextureMode=3; }
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
void tnsUseNoTexture(){
|
|
void tnsUseNoTexture(){
|
|
tnsUseTexture(0);
|
|
tnsUseTexture(0);
|
|
@@ -1851,7 +1868,9 @@ void tnsActiveTexture(GLenum tex){
|
|
void tnsBindTexture(tnsTexture *t){
|
|
void tnsBindTexture(tnsTexture *t){
|
|
if ((!t) || T->TexColor==t) return;
|
|
if ((!t) || T->TexColor==t) return;
|
|
if(t->GLTexType == GL_TEXTURE_2D){ tnsActiveTexture(GL_TEXTURE0); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor=t;}
|
|
if(t->GLTexType == GL_TEXTURE_2D){ tnsActiveTexture(GL_TEXTURE0); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor=t;}
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
elif(t->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){ tnsActiveTexture(GL_TEXTURE1); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor=t;}
|
|
elif(t->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){ tnsActiveTexture(GL_TEXTURE1); glBindTexture(t->GLTexType, t->GLTexHandle); T->TexColor=t;}
|
|
|
|
+#endif
|
|
#ifndef LA_USE_GLES
|
|
#ifndef LA_USE_GLES
|
|
elif(t->GLTexType == GL_RENDERBUFFER){ glBindRenderbufferEXT(GL_RENDERBUFFER, t->GLTexHandle); T->TexRenderbuffer = t;}
|
|
elif(t->GLTexType == GL_RENDERBUFFER){ glBindRenderbufferEXT(GL_RENDERBUFFER, t->GLTexHandle); T->TexRenderbuffer = t;}
|
|
#endif
|
|
#endif
|
|
@@ -1863,7 +1882,9 @@ void tnsUnbindTexture(){
|
|
#endif
|
|
#endif
|
|
if(T->TexColor){
|
|
if(T->TexColor){
|
|
if(T->TexColor->GLTexType == GL_TEXTURE_2D){tnsActiveTexture(GL_TEXTURE0);}
|
|
if(T->TexColor->GLTexType == GL_TEXTURE_2D){tnsActiveTexture(GL_TEXTURE0);}
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
else if(T->TexColor->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){tnsActiveTexture(GL_TEXTURE1);}
|
|
else if(T->TexColor->GLTexType == GL_TEXTURE_2D_MULTISAMPLE){tnsActiveTexture(GL_TEXTURE1);}
|
|
|
|
+#endif
|
|
else if(T->TexColor->GLTexType == GL_TEXTURE_3D){tnsActiveTexture(GL_TEXTURE0);}
|
|
else if(T->TexColor->GLTexType == GL_TEXTURE_3D){tnsActiveTexture(GL_TEXTURE0);}
|
|
glBindTexture(T->TexColor->GLTexType, 0); T->TexColor=0;
|
|
glBindTexture(T->TexColor->GLTexType, 0); T->TexColor=0;
|
|
}
|
|
}
|
|
@@ -2303,7 +2324,9 @@ void tnsPackAs(GLenum Mode){
|
|
|
|
|
|
memcpy(c->UniformColor, T->StateColor, sizeof(GLfloat) * 4);
|
|
memcpy(c->UniformColor, T->StateColor, sizeof(GLfloat) * 4);
|
|
|
|
|
|
|
|
+#ifndef LAGUI_ANDROID
|
|
if (Mode == GL_QUAD_STRIP || Mode == GL_QUADS) Mode=GL_TRIANGLE_STRIP;
|
|
if (Mode == GL_QUAD_STRIP || Mode == GL_QUADS) Mode=GL_TRIANGLE_STRIP;
|
|
|
|
+#endif
|
|
//if (Mode == GL_QUADS) Mode=GL_TRIANGLE_STRIP;
|
|
//if (Mode == GL_QUADS) Mode=GL_TRIANGLE_STRIP;
|
|
c->Mode = Mode;
|
|
c->Mode = Mode;
|
|
c->ReplaceShader = T->StateShader;
|
|
c->ReplaceShader = T->StateShader;
|
|
@@ -2449,7 +2472,7 @@ const GLuint TNS_ATTACHMENT_ARRAY_0_1_2[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTA
|
|
const GLenum TNS_WINDOW_DRAWBUFFER_ARRAY[] = {GL_BACK};
|
|
const GLenum TNS_WINDOW_DRAWBUFFER_ARRAY[] = {GL_BACK};
|
|
|
|
|
|
tnsOffscreen *tnsCreateOffscreenHandle(){
|
|
tnsOffscreen *tnsCreateOffscreenHandle(){
|
|
- if(!T->CurrentContext){ printf("tnsCreateOffscreenHandle() called without GL Context. Exiting"); exit(0); }
|
|
|
|
|
|
+ if(!T->CurrentContext){ logPrintNew("tnsCreateOffscreenHandle() called without GL Context. Exiting"); exit(0); }
|
|
tnsOffscreen *toff = CreateNew(tnsOffscreen); toff->FboContext=T->CurrentContext;
|
|
tnsOffscreen *toff = CreateNew(tnsOffscreen); toff->FboContext=T->CurrentContext;
|
|
#ifdef LA_USE_GLES
|
|
#ifdef LA_USE_GLES
|
|
toff->FboSurface=T->CurrentSurface;
|
|
toff->FboSurface=T->CurrentSurface;
|
|
@@ -2679,7 +2702,7 @@ int tnsInvalidateFontCache(){
|
|
int GenHeight=LA_RH*MAIN.FontSize;
|
|
int GenHeight=LA_RH*MAIN.FontSize;
|
|
for(int i=0;i<f->NumFaces;i++){
|
|
for(int i=0;i<f->NumFaces;i++){
|
|
FT_Set_Char_Size(f->ftface[i], 0, GenHeight << 6, 96, 96);
|
|
FT_Set_Char_Size(f->ftface[i], 0, GenHeight << 6, 96, 96);
|
|
- FT_Glyph glyph; int half_adv=0;
|
|
|
|
|
|
+ FT_Glyph glyph; FT_Fixed half_adv=0;
|
|
if(!FT_Get_Advance(f->ftface[i],'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
if(!FT_Get_Advance(f->ftface[i],'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
if (FT_Load_Char(f->ftface[i], 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
if (FT_Load_Char(f->ftface[i], 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
FT_Get_Glyph(f->ftface[i]->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
|
|
FT_Get_Glyph(f->ftface[i]->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
|
|
@@ -2714,23 +2737,29 @@ int tnsLoadSystemFontMono(char* from, char* mono){
|
|
tnsFont *f=FM->UsingFont;
|
|
tnsFont *f=FM->UsingFont;
|
|
int GenHeight=LA_RH*MAIN.FontSize;
|
|
int GenHeight=LA_RH*MAIN.FontSize;
|
|
|
|
|
|
- int full_adv=0,half_adv=0;
|
|
|
|
|
|
+ FT_Fixed full_adv=0,half_adv=0;
|
|
for(int i=0;i<f->NumFaces;i++){
|
|
for(int i=0;i<f->NumFaces;i++){
|
|
if(!FT_Get_Advance(f->ftface[i],U'我',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &full_adv)) break;
|
|
if(!FT_Get_Advance(f->ftface[i],U'我',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &full_adv)) break;
|
|
}
|
|
}
|
|
for(int i=-2;i<11;i++){
|
|
for(int i=-2;i<11;i++){
|
|
char* option;
|
|
char* option;
|
|
if(i==-2){ sprintf(buf,"%s%s%s",TNS_FONT_CUSTOM,TNS_FONT_CUSTOM[strlen(TNS_FONT_CUSTOM)-1]=='/'?"":"/",mono); }
|
|
if(i==-2){ sprintf(buf,"%s%s%s",TNS_FONT_CUSTOM,TNS_FONT_CUSTOM[strlen(TNS_FONT_CUSTOM)-1]=='/'?"":"/",mono); }
|
|
- elif(i<9){ option=(i==-1)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s%s",MAIN.WorkingDirectory->Ptr,option,mono); }
|
|
|
|
|
|
+ elif(i<9){ option=(i==-1)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s%s",SSTR(MAIN.WorkingDirectory),option,mono); }
|
|
else{ option=TNS_FONT_LOAD_OPTIONS_FROM_HOME[i-9]; sprintf(buf,"%s/%s%s",getenv("HOME"),option,mono); }
|
|
else{ option=TNS_FONT_LOAD_OPTIONS_FROM_HOME[i-9]; sprintf(buf,"%s/%s%s",getenv("HOME"),option,mono); }
|
|
- if (FT_New_Face(f->ftlib, buf, 0, &f->ftfacemono)) continue;
|
|
|
|
|
|
+ FILE* fontfile=fopen(buf,"rb"); if(!fontfile) continue;
|
|
|
|
+ fseek(fontfile,0,SEEK_END); int filesize=ftell(fontfile);
|
|
|
|
+ void*fontdata=CreateNewBuffer(char,filesize);
|
|
|
|
+ fseek(fontfile,0,SEEK_SET); fread(fontdata,filesize,1,fontfile);
|
|
|
|
+ FT_Face face; FT_Long i,num_faces; FT_Open_Args args; args.flags=FT_OPEN_MEMORY;
|
|
|
|
+ args.memory_base=fontdata; args.memory_size=filesize;
|
|
|
|
+ if(FT_Open_Face(f->ftlib, &args, 0, &f->ftfacemono)) continue;
|
|
FT_Select_Charmap(f->ftfacemono, FT_ENCODING_UNICODE);
|
|
FT_Select_Charmap(f->ftfacemono, FT_ENCODING_UNICODE);
|
|
FT_Set_Char_Size(f->ftfacemono, 0, GenHeight << 6, 96, 96);
|
|
FT_Set_Char_Size(f->ftfacemono, 0, GenHeight << 6, 96, 96);
|
|
logPrint("Loaded monospace font: %s\n",buf);
|
|
logPrint("Loaded monospace font: %s\n",buf);
|
|
if(!FT_Get_Advance(f->ftfacemono,'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
if(!FT_Get_Advance(f->ftfacemono,'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
f->MonoScale=(real)full_adv/(half_adv*2);
|
|
f->MonoScale=(real)full_adv/(half_adv*2);
|
|
FT_Set_Char_Size(f->ftfacemono, 0, (GenHeight << 6)*f->MonoScale, 96, 96);
|
|
FT_Set_Char_Size(f->ftfacemono, 0, (GenHeight << 6)*f->MonoScale, 96, 96);
|
|
- logPrint("Monospace font scale: %.2f\n",f->MonoScale); FT_Glyph glyph;
|
|
|
|
|
|
+ logPrintNew("Monospace font scale: %.2f\n",f->MonoScale); FT_Glyph glyph;
|
|
if (FT_Load_Char(f->ftfacemono, 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
if (FT_Load_Char(f->ftfacemono, 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
FT_Get_Glyph(f->ftfacemono->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
|
|
FT_Get_Glyph(f->ftfacemono->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
|
|
f->MonoAdvance=(real)f->ftfacemono->glyph->advance.x/64.0;
|
|
f->MonoAdvance=(real)f->ftfacemono->glyph->advance.x/64.0;
|
|
@@ -2758,20 +2787,26 @@ int tnsLoadSystemFont(char* from, char* name){
|
|
for(int i=-2;i<11;i++){
|
|
for(int i=-2;i<11;i++){
|
|
char* option;
|
|
char* option;
|
|
if(i==-2){ sprintf(buf,"%s%s%s",TNS_FONT_CUSTOM,TNS_FONT_CUSTOM[strlen(TNS_FONT_CUSTOM)-1]=='/'?"":"/",name); }
|
|
if(i==-2){ sprintf(buf,"%s%s%s",TNS_FONT_CUSTOM,TNS_FONT_CUSTOM[strlen(TNS_FONT_CUSTOM)-1]=='/'?"":"/",name); }
|
|
- elif(i<9){ option=(i==-1)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s%s",MAIN.WorkingDirectory->Ptr,option,name); }
|
|
|
|
|
|
+ elif(i<9){ option=(i==-1)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s%s",SSTR(MAIN.WorkingDirectory),option,name); }
|
|
else{ option=TNS_FONT_LOAD_OPTIONS_FROM_HOME[i-9]; sprintf(buf,"%s/%s%s",getenv("HOME"),option,name); }
|
|
else{ option=TNS_FONT_LOAD_OPTIONS_FROM_HOME[i-9]; sprintf(buf,"%s/%s%s",getenv("HOME"),option,name); }
|
|
- FT_Face face; FT_Long i,num_faces; FT_Open_Args args; args.flags=FT_OPEN_PATHNAME; args.pathname=buf;
|
|
|
|
|
|
+ FILE* fontfile=fopen(buf,"rb"); if(!fontfile) continue;
|
|
|
|
+ fseek(fontfile,0,SEEK_END); int filesize=ftell(fontfile);
|
|
|
|
+ void*fontdata=CreateNewBuffer(char,filesize);
|
|
|
|
+ fseek(fontfile,0,SEEK_SET); fread(fontdata,filesize,1,fontfile);
|
|
|
|
+ FT_Face face; FT_Long i,num_faces; FT_Open_Args args; args.flags=FT_OPEN_MEMORY;
|
|
|
|
+ args.memory_base=fontdata; args.memory_size=filesize;
|
|
if(FT_Open_Face(f->ftlib, &args, -1, &face )) continue;
|
|
if(FT_Open_Face(f->ftlib, &args, -1, &face )) continue;
|
|
|
|
+ logPrintNew("stream %d",fontfile);
|
|
num_faces = face->num_faces; FT_Done_Face(face); int found=0;
|
|
num_faces = face->num_faces; FT_Done_Face(face); int found=0;
|
|
for(int fa=0;fa<num_faces;fa++){
|
|
for(int fa=0;fa<num_faces;fa++){
|
|
if(FT_Open_Face(f->ftlib,&args,fa,&face)){ continue; }
|
|
if(FT_Open_Face(f->ftlib,&args,fa,&face)){ continue; }
|
|
if(strstr(face->family_name,"SC")){ found=1; break; }
|
|
if(strstr(face->family_name,"SC")){ found=1; break; }
|
|
FT_Done_Face(face);
|
|
FT_Done_Face(face);
|
|
}
|
|
}
|
|
- if(found){ f->ftface[f->NumFaces]=face; }else{ if (FT_New_Face(f->ftlib, buf, 0, &f->ftface[f->NumFaces])) continue; }
|
|
|
|
|
|
+ if(found){ f->ftface[f->NumFaces]=face; }else{ if (FT_Open_Face(f->ftlib, &args, 0, &f->ftface[f->NumFaces])) continue; }
|
|
FT_Select_Charmap(f->ftface[f->NumFaces], FT_ENCODING_UNICODE);
|
|
FT_Select_Charmap(f->ftface[f->NumFaces], FT_ENCODING_UNICODE);
|
|
FT_Set_Char_Size(f->ftface[f->NumFaces], 0, GenHeight << 6, 96, 96);
|
|
FT_Set_Char_Size(f->ftface[f->NumFaces], 0, GenHeight << 6, 96, 96);
|
|
- f->NumFaces++; FT_Glyph glyph; int half_adv=0;
|
|
|
|
|
|
+ f->NumFaces++; FT_Glyph glyph; FT_Fixed half_adv=0;
|
|
if(!f->MonoAdvance && !FT_Get_Advance(f->ftface[f->NumFaces],'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
if(!f->MonoAdvance && !FT_Get_Advance(f->ftface[f->NumFaces],'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
FT_Set_Char_Size(f->ftface[f->NumFaces], 0, (GenHeight << 6)*f->MonoScale, 96, 96);
|
|
FT_Set_Char_Size(f->ftface[f->NumFaces], 0, (GenHeight << 6)*f->MonoScale, 96, 96);
|
|
if (FT_Load_Char(f->ftface[f->NumFaces], 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
if (FT_Load_Char(f->ftface[f->NumFaces], 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
@@ -2911,7 +2946,7 @@ void tnsPopStringClip(){
|
|
};
|
|
};
|
|
|
|
|
|
int tnsStringGetDimension(char* content, uint32_t* contentU, int Count, int WLimit, int* Rows, int UseMono){
|
|
int tnsStringGetDimension(char* content, uint32_t* contentU, int Count, int WLimit, int* Rows, int UseMono){
|
|
- if((!MAIN.CurrentWindow)||(!MAIN.CurrentWindow->win)) return 0;
|
|
|
|
|
|
+ if((!MAIN.CurrentWindow)||(!MAIN.CurrentWindow->win)||(!FM->UsingFont)) return 0;
|
|
real sx = 0; int sy = FM->UsingFont->height; real MA=FM->UsingFont->MonoAdvance;
|
|
real sx = 0; int sy = FM->UsingFont->height; real MA=FM->UsingFont->MonoAdvance;
|
|
int i, rows=1, advance=1;
|
|
int i, rows=1, advance=1;
|
|
int C = 0;
|
|
int C = 0;
|
|
@@ -2932,6 +2967,7 @@ int tnsStringGetDimension(char* content, uint32_t* contentU, int Count, int WLim
|
|
continue;
|
|
continue;
|
|
}else{
|
|
}else{
|
|
fsc = tfntFetchCharacterW(UC, UseMono);
|
|
fsc = tfntFetchCharacterW(UC, UseMono);
|
|
|
|
+ if(!fsc){continue;};
|
|
real dx=fsc->advx; if(UseMono){ dx/=MA; if(dx<1.01) dx=1; if(dx>1.01)dx=2; dx*=MA; }
|
|
real dx=fsc->advx; if(UseMono){ dx/=MA; if(dx<1.01) dx=1; if(dx>1.01)dx=2; dx*=MA; }
|
|
if(sx+dx > WLimit){ sx = 0; sy += LA_RH; rows++; }
|
|
if(sx+dx > WLimit){ sx = 0; sy += LA_RH; rows++; }
|
|
sx += dx;
|
|
sx += dx;
|
|
@@ -2965,7 +3001,7 @@ int tnsDrawLCD7_ProgressSystem(real x, real y, real Percent){
|
|
if(TNS_LCD_MAP_7[uc][i]){
|
|
if(TNS_LCD_MAP_7[uc][i]){
|
|
real* seg=TNS_LCD_SEG_7[i];
|
|
real* seg=TNS_LCD_SEG_7[i];
|
|
real s1=tnsInterpolate(shear,-shear,seg[1]); real s2=tnsInterpolate(shear,-shear,seg[3]);
|
|
real s1=tnsInterpolate(shear,-shear,seg[1]); real s2=tnsInterpolate(shear,-shear,seg[3]);
|
|
-#ifdef __linux__
|
|
|
|
|
|
+#ifdef LA_LINUX
|
|
XDrawLine(MAIN.dpy,MAIN.Progress.w,MAIN.Progress.gc,
|
|
XDrawLine(MAIN.dpy,MAIN.Progress.w,MAIN.Progress.gc,
|
|
tnsInterpolate(x+s1,x+w+s1,seg[0]),tnsInterpolate(y,y+h,seg[1]),
|
|
tnsInterpolate(x+s1,x+w+s1,seg[0]),tnsInterpolate(y,y+h,seg[1]),
|
|
tnsInterpolate(x+s2,x+w+s2,seg[2]),tnsInterpolate(y,y+h,seg[3]));
|
|
tnsInterpolate(x+s2,x+w+s2,seg[2]),tnsInterpolate(y,y+h,seg[3]));
|
|
@@ -3073,7 +3109,7 @@ int tns_ClipCharacterT2D(real* v, real* t){
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags){
|
|
void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags){
|
|
- if(Flags&(LA_TEXT_LCD_16|LA_TEXT_LCD_7)){
|
|
|
|
|
|
+ if(!FM->UsingFont){return;} if(Flags&(LA_TEXT_LCD_16|LA_TEXT_LCD_7)){
|
|
tnsDrawStringLCD(content,contentU,Color,L,R,T,Flags,1.0); return;
|
|
tnsDrawStringLCD(content,contentU,Color,L,R,T,Flags,1.0); return;
|
|
}
|
|
}
|
|
real sx = L; int sy = (LA_RH!=LA_RH0)?(((((real)FM->UsingFont->height/LA_RH0-0.5)/MAIN.UiScale)+0.5)*LA_RH + T):(FM->UsingFont->height+T);
|
|
real sx = L; int sy = (LA_RH!=LA_RH0)?(((((real)FM->UsingFont->height/LA_RH0-0.5)/MAIN.UiScale)+0.5)*LA_RH + T):(FM->UsingFont->height+T);
|
|
@@ -3100,14 +3136,14 @@ void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int
|
|
|
|
|
|
if (UC == U'\n'){ if(!OneLine){sx = L; sy += LA_RH; continue;}else{ UC=' '; } }
|
|
if (UC == U'\n'){ if(!OneLine){sx = L; sy += LA_RH; continue;}else{ UC=' '; } }
|
|
|
|
|
|
- fsc = tfntFetchCharacterW(UC, Flags&LA_TEXT_MONO);
|
|
|
|
|
|
+ fsc = tfntFetchCharacterW(UC, Flags&LA_TEXT_MONO); if(!fsc){continue;}
|
|
|
|
|
|
real dx=fsc->advx; if(UseMono){ dx/=MA; if(dx<1.01) dx=1; if(dx>1.01)dx=2; dx*=MA; }
|
|
real dx=fsc->advx; if(UseMono){ dx/=MA; if(dx<1.01) dx=1; if(dx>1.01)dx=2; dx*=MA; }
|
|
if (sx + dx > R+1){
|
|
if (sx + dx > R+1){
|
|
if(Flags&LA_TEXT_LINE_WRAP){
|
|
if(Flags&LA_TEXT_LINE_WRAP){
|
|
sx=L; sy+=LA_RH;
|
|
sx=L; sy+=LA_RH;
|
|
}else{
|
|
}else{
|
|
- if(Flags&LA_TEXT_OVERFLOW_ARROW){ fsc = tfntFetchCharacterW(U'▷', 0); sx=R-fsc->advx; BreakNow=1; }
|
|
|
|
|
|
+ if(Flags&LA_TEXT_OVERFLOW_ARROW){ fsc = tfntFetchCharacterW(U'▷', 0); if(!fsc){continue;} sx=R-fsc->advx; BreakNow=1; }
|
|
else break;
|
|
else break;
|
|
}
|
|
}
|
|
}
|
|
}
|