mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-05 02:35:29 +02:00
Fix Linux/Android compilation.
This commit is contained in:
1 parent
1401de50dc
commit
110f640ca8
4 files changed
+28
-21
No files matched your search
@@ -88,6 +88,8 @@ LOCAL_SRC_FILES :=\
|
||||
image/zim_load.cpp \
|
||||
image/zim_save.cpp \
|
||||
image/png_load.cpp \
|
||||
thin3d/thin3d.cpp \
|
||||
thin3d/thin3d_gl.cpp \
|
||||
ui/view.cpp \
|
||||
ui/viewgroup.cpp \
|
||||
ui/ui.cpp \
|
||||
|
||||
+9
-11
@@ -199,14 +199,14 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
||||
|
||||
#else
|
||||
|
||||
TextDrawer::TextDrawer() {
|
||||
TextDrawer::TextDrawer(Thin3DContext *thin3d) : thin3d_(thin3d), ctx_(NULL) {
|
||||
fontScaleX_ = 1.0f;
|
||||
fontScaleY_ = 1.0f;
|
||||
}
|
||||
|
||||
TextDrawer::~TextDrawer() {
|
||||
for (auto iter = cache_.begin(); iter != cache_.end(); ++iter) {
|
||||
glDeleteTextures(1, &iter->second->textureHandle);
|
||||
iter->second->texture->Release();
|
||||
delete iter->second;
|
||||
}
|
||||
cache_.clear();
|
||||
@@ -254,6 +254,9 @@ void TextDrawer::MeasureString(const char *str, float *w, float *h) {
|
||||
}
|
||||
|
||||
void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float y, uint32_t color, int align) {
|
||||
if (!strlen(str))
|
||||
return;
|
||||
|
||||
#ifdef USING_QT_UI
|
||||
uint32_t stringHash = hash::Fletcher((const uint8_t *)str, strlen(str));
|
||||
uint32_t entryHash = stringHash ^ fontHash_;
|
||||
@@ -266,7 +269,7 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
||||
if (iter != cache_.end()) {
|
||||
entry = iter->second;
|
||||
entry->lastUsedFrame = frameCount_;
|
||||
glBindTexture(GL_TEXTURE_2D, entry->textureHandle);
|
||||
thin3d_->SetTexture(0, entry->texture);
|
||||
} else {
|
||||
QFont *font = fontMap_.find(fontHash_)->second;
|
||||
QFontMetrics fm(*font);
|
||||
@@ -285,11 +288,10 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
||||
painter.end();
|
||||
|
||||
entry = new TextStringEntry();
|
||||
glGenTextures(1, &entry->textureHandle);
|
||||
glBindTexture(GL_TEXTURE_2D, entry->textureHandle);
|
||||
entry->bmWidth = entry->width = image.width();
|
||||
entry->bmHeight = entry->height = image.height();
|
||||
entry->lastUsedFrame = frameCount_;
|
||||
entry->texture = thin3d_->CreateTexture(LINEAR2D, RGBA4444, entry->bmWidth, entry->bmHeight, 1, 0);
|
||||
|
||||
uint16_t *bitmapData = new uint16_t[entry->bmWidth * entry->bmHeight];
|
||||
for (int x = 0; x < entry->bmWidth; x++) {
|
||||
@@ -297,12 +299,8 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
||||
bitmapData[entry->bmWidth * y + x] = 0xfff0 | image.pixel(x, y) >> 28;
|
||||
}
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, entry->bmWidth, entry->bmHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, bitmapData);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
entry->texture->SetImageData(0, 0, 0, entry->bmWidth, entry->bmHeight, 1, 0, entry->bmWidth * 2, (const uint8_t *)bitmapData);
|
||||
entry->texture->Finalize(0);
|
||||
|
||||
delete [] bitmapData;
|
||||
|
||||
|
||||
@@ -24,11 +24,7 @@ class Thin3DTexture;
|
||||
#endif
|
||||
|
||||
struct TextStringEntry {
|
||||
#if defined(_WIN32) && !defined(USING_QT_UI)
|
||||
Thin3DTexture *texture;
|
||||
#else
|
||||
GLuint textureHandle;
|
||||
#endif
|
||||
int width;
|
||||
int height;
|
||||
int bmWidth;
|
||||
|
||||
+17
-6
@@ -315,11 +315,15 @@ Thin3DVertexFormat *Thin3DGLContext::CreateVertexFormat(const std::vector<Thin3D
|
||||
|
||||
GLuint TypeToTarget(T3DTextureType type) {
|
||||
switch (type) {
|
||||
#ifndef USING_GLES2
|
||||
case LINEAR1D: return GL_TEXTURE_1D;
|
||||
#endif
|
||||
case LINEAR2D: return GL_TEXTURE_2D;
|
||||
case LINEAR3D: return GL_TEXTURE_3D;
|
||||
case CUBE: return GL_TEXTURE_CUBE_MAP;
|
||||
#ifndef USING_GLES2
|
||||
case ARRAY1D: return GL_TEXTURE_1D_ARRAY;
|
||||
#endif
|
||||
case ARRAY2D: return GL_TEXTURE_2D_ARRAY;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
@@ -522,12 +526,13 @@ bool Thin3DGLShaderSet::Link() {
|
||||
}
|
||||
|
||||
// Auto-initialize samplers.
|
||||
glUseProgram(program_);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
char temp[256];
|
||||
sprintf(temp, "Sampler%i", i);
|
||||
int samplerLoc = GetUniformLoc(temp);
|
||||
if (samplerLoc != -1) {
|
||||
glProgramUniform1i(program_, samplerLoc, i);
|
||||
glUniform1i(samplerLoc, i);
|
||||
}
|
||||
}
|
||||
// Here we could (using glGetAttribLocation) save a bitmask about which pieces of vertex data are used in the shader
|
||||
@@ -550,21 +555,23 @@ int Thin3DGLShaderSet::GetUniformLoc(const char *name) {
|
||||
}
|
||||
|
||||
void Thin3DGLShaderSet::SetVector(const char *name, float *value, int n) {
|
||||
glUseProgram(program_);
|
||||
int loc = GetUniformLoc(name);
|
||||
if (loc != -1) {
|
||||
switch (n) {
|
||||
case 1: glProgramUniform1fv(program_, loc, 1, value); break;
|
||||
case 2: glProgramUniform1fv(program_, loc, 2, value); break;
|
||||
case 3: glProgramUniform1fv(program_, loc, 3, value); break;
|
||||
case 4: glProgramUniform1fv(program_, loc, 4, value); break;
|
||||
case 1: glUniform1fv(loc, 1, value); break;
|
||||
case 2: glUniform1fv(loc, 2, value); break;
|
||||
case 3: glUniform1fv(loc, 3, value); break;
|
||||
case 4: glUniform1fv(loc, 4, value); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Thin3DGLShaderSet::SetMatrix4x4(const char *name, const Matrix4x4 &value) {
|
||||
glUseProgram(program_);
|
||||
int loc = GetUniformLoc(name);
|
||||
if (loc != -1) {
|
||||
glProgramUniformMatrix4fv(program_, loc, 1, false, value.getReadPtr());
|
||||
glUniformMatrix4fv(loc, 1, false, value.getReadPtr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +640,11 @@ void Thin3DGLContext::Clear(int mask, uint32_t colorval, float depthVal, int ste
|
||||
glMask |= GL_COLOR_BUFFER_BIT;
|
||||
}
|
||||
if (mask & T3DClear::DEPTH) {
|
||||
#ifdef USING_GLES2
|
||||
glClearDepthf(depthVal);
|
||||
#else
|
||||
glClearDepth(depthVal);
|
||||
#endif
|
||||
glMask |= GL_DEPTH_BUFFER_BIT;
|
||||
}
|
||||
if (mask & T3DClear::STENCIL) {
|
||||
|
||||
Reference in new issue
Block a user