mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Fixes for iOS.
This commit is contained in:
parent
0f2e808477
commit
6b3869ce90
12 changed files with 97 additions and 25 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -20,6 +20,9 @@ build
|
|||
debug
|
||||
release
|
||||
ipch
|
||||
Debug*
|
||||
.DS_Store
|
||||
.qmake.stash
|
||||
Makefile
|
||||
library.bin
|
||||
leocad_plugin_import.cpp
|
||||
|
|
|
@ -7,6 +7,17 @@
|
|||
#include "lc_mainwindow.h"
|
||||
#include "lc_library.h"
|
||||
|
||||
#ifdef LC_OPENGLES
|
||||
#define glEnableClientState(...)
|
||||
#define glDisableClientState(...)
|
||||
#define glVertexPointer(...)
|
||||
#define glTexCoordPointer(...)
|
||||
#define glColorPointer(...)
|
||||
#define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER
|
||||
#define GL_ELEMENT_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER
|
||||
#define GL_STATIC_DRAW_ARB GL_STATIC_DRAW
|
||||
#endif
|
||||
|
||||
lcProgram lcContext::mPrograms[LC_NUM_PROGRAMS];
|
||||
|
||||
static int lcOpaqueRenderMeshCompare(const void* Elem1, const void* Elem2)
|
||||
|
@ -69,7 +80,9 @@ lcContext::lcContext()
|
|||
|
||||
mTexture = NULL;
|
||||
mLineWidth = 1.0f;
|
||||
#ifndef LC_OPENGLES
|
||||
mMatrixMode = GL_MODELVIEW;
|
||||
#endif
|
||||
|
||||
mFramebufferObject = 0;
|
||||
mFramebufferTexture = 0;
|
||||
|
@ -95,21 +108,35 @@ lcContext::~lcContext()
|
|||
|
||||
void lcContext::CreateShaderPrograms()
|
||||
{
|
||||
#ifndef LC_OPENGLES
|
||||
#define LC_SHADER_VERSION "#version 110\n"
|
||||
#define LC_VERTEX_INPUT "attribute "
|
||||
#define LC_VERTEX_OUTPUT "varying "
|
||||
#define LC_PIXEL_INPUT "varying "
|
||||
#define LC_PIXEL_OUTPUT
|
||||
#else
|
||||
#define LC_SHADER_VERSION "#version 300 es\n#define texture2D texture\n"
|
||||
#define LC_VERTEX_INPUT "in "
|
||||
#define LC_VERTEX_OUTPUT "out "
|
||||
#define LC_PIXEL_INPUT "in mediump "
|
||||
#define LC_PIXEL_OUTPUT "#define gl_FragColor FragColor\nout mediump vec4 gl_FragColor;\n"
|
||||
#endif
|
||||
|
||||
const char* VertexShaders[LC_NUM_PROGRAMS] =
|
||||
{
|
||||
// LC_PROGRAM_SIMPLE
|
||||
"#version 110\n"
|
||||
"attribute vec3 VertexPosition;\n"
|
||||
LC_SHADER_VERSION
|
||||
LC_VERTEX_INPUT "vec3 VertexPosition;\n"
|
||||
"uniform mat4 WorldViewProjectionMatrix;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = WorldViewProjectionMatrix * vec4(VertexPosition, 1.0);\n"
|
||||
"}\n",
|
||||
// LC_PROGRAM_TEXTURE
|
||||
"#version 110\n"
|
||||
"attribute vec3 VertexPosition;\n"
|
||||
"attribute vec2 VertexTexCoord;\n"
|
||||
"varying vec2 PixelTexCoord;\n"
|
||||
LC_SHADER_VERSION
|
||||
LC_VERTEX_INPUT "vec3 VertexPosition;\n"
|
||||
LC_VERTEX_INPUT "vec2 VertexTexCoord;\n"
|
||||
LC_VERTEX_OUTPUT "vec2 PixelTexCoord;\n"
|
||||
"uniform mat4 WorldViewProjectionMatrix;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
|
@ -117,10 +144,10 @@ void lcContext::CreateShaderPrograms()
|
|||
" PixelTexCoord = VertexTexCoord;\n"
|
||||
"}\n",
|
||||
// LC_PROGRAM_VERTEX_COLOR
|
||||
"#version 110\n"
|
||||
"attribute vec3 VertexPosition;\n"
|
||||
"attribute vec4 VertexColor;\n"
|
||||
"varying vec4 PixelColor;\n"
|
||||
LC_SHADER_VERSION
|
||||
LC_VERTEX_INPUT "vec3 VertexPosition;\n"
|
||||
LC_VERTEX_INPUT "vec4 VertexColor;\n"
|
||||
LC_VERTEX_OUTPUT "vec4 PixelColor;\n"
|
||||
"uniform mat4 WorldViewProjectionMatrix;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
|
@ -132,24 +159,27 @@ void lcContext::CreateShaderPrograms()
|
|||
const char* FragmentShaders[LC_NUM_PROGRAMS] =
|
||||
{
|
||||
// LC_PROGRAM_SIMPLE
|
||||
"#version 110\n"
|
||||
"uniform vec4 Color;\n"
|
||||
LC_SHADER_VERSION
|
||||
LC_PIXEL_OUTPUT
|
||||
"uniform mediump vec4 Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = Color;\n"
|
||||
"}\n",
|
||||
// LC_PROGRAM_TEXTURE
|
||||
"#version 110\n"
|
||||
"varying vec2 PixelTexCoord;\n"
|
||||
"uniform vec4 Color;\n"
|
||||
LC_SHADER_VERSION
|
||||
LC_PIXEL_INPUT "vec2 PixelTexCoord;\n"
|
||||
LC_PIXEL_OUTPUT
|
||||
"uniform mediump vec4 Color;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(Texture, PixelTexCoord) * Color;\n"
|
||||
"}\n",
|
||||
// LC_PROGRAM_VERTEX_COLOR
|
||||
"#version 110\n"
|
||||
"varying vec4 PixelColor;\n"
|
||||
LC_SHADER_VERSION
|
||||
LC_PIXEL_INPUT "vec4 PixelColor;\n"
|
||||
LC_PIXEL_OUTPUT
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = PixelColor;\n"
|
||||
|
@ -307,8 +337,10 @@ void lcContext::SetDefaultState()
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifndef LC_OPENGLES
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
mMatrixMode = GL_MODELVIEW;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,6 +436,7 @@ bool lcContext::BeginRenderToTexture(int Width, int Height)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
if (gSupportsFramebufferObjectEXT)
|
||||
{
|
||||
glGenFramebuffersEXT(1, &mFramebufferObject);
|
||||
|
@ -435,7 +468,8 @@ bool lcContext::BeginRenderToTexture(int Width, int Height)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -453,6 +487,7 @@ void lcContext::EndRenderToTexture()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
if (gSupportsFramebufferObjectEXT)
|
||||
{
|
||||
glDeleteFramebuffersEXT(1, &mFramebufferObject);
|
||||
|
@ -462,6 +497,7 @@ void lcContext::EndRenderToTexture()
|
|||
glDeleteRenderbuffersEXT(1, &mDepthRenderbufferObject);
|
||||
mDepthRenderbufferObject = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QImage lcContext::GetRenderToTextureImage(int Width, int Height)
|
||||
|
@ -879,6 +915,7 @@ void lcContext::FlushState()
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifndef LC_OPENGLES
|
||||
glColor4fv(mColor);
|
||||
|
||||
if (mWorldMatrixDirty || mViewMatrixDirty)
|
||||
|
@ -905,6 +942,7 @@ void lcContext::FlushState()
|
|||
glLoadMatrixf(mProjectionMatrix);
|
||||
mProjectionMatrixDirty = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,4 +331,10 @@ void lcInitializeGLExtensions(const QGLContext* Context)
|
|||
#endif
|
||||
gSupportsShaderObjects = true;
|
||||
}
|
||||
|
||||
#ifdef LC_OPENGLES
|
||||
gSupportsVertexBufferObject = true;
|
||||
gSupportsFramebufferObjectARB = true;
|
||||
gSupportsShaderObjects = true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -730,6 +730,7 @@ void lcMainWindow::ColorChanged(int ColorIndex)
|
|||
|
||||
void lcMainWindow::Print(QPrinter* Printer)
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
lcModel* Model = lcGetActiveModel();
|
||||
int DocCopies;
|
||||
int PageCopies;
|
||||
|
@ -993,6 +994,7 @@ void lcMainWindow::Print(QPrinter* Printer)
|
|||
Model->SetTemporaryStep(PreviousTime);
|
||||
|
||||
Context->EndRenderToTexture();
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcMainWindow::ShowUpdatesDialog()
|
||||
|
@ -1009,6 +1011,7 @@ void lcMainWindow::ShowAboutDialog()
|
|||
|
||||
void lcMainWindow::ShowPrintDialog()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
lcModel* Model = lcGetActiveModel();
|
||||
int Rows = lcGetProfileInt(LC_PROFILE_PRINT_ROWS);
|
||||
int Columns = lcGetProfileInt(LC_PROFILE_PRINT_COLUMNS);
|
||||
|
@ -1022,6 +1025,7 @@ void lcMainWindow::ShowPrintDialog()
|
|||
|
||||
if (PrintDialog.exec() == QDialog::Accepted)
|
||||
Print(&Printer);
|
||||
#endif
|
||||
}
|
||||
|
||||
// todo: call dialogs directly
|
||||
|
@ -1394,6 +1398,7 @@ void lcMainWindow::ResetViews()
|
|||
|
||||
void lcMainWindow::TogglePrintPreview()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
// todo: print preview inside main window
|
||||
|
||||
lcModel* Model = lcGetActiveModel();
|
||||
|
@ -1408,6 +1413,7 @@ void lcMainWindow::TogglePrintPreview()
|
|||
QPrintPreviewDialog Preview(&Printer, this);
|
||||
connect(&Preview, SIGNAL(paintRequested(QPrinter*)), SLOT(Print(QPrinter*)));
|
||||
Preview.exec();
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcMainWindow::ToggleFullScreen()
|
||||
|
|
|
@ -14,6 +14,9 @@ class lcQPartsTree;
|
|||
class lcQColorList;
|
||||
class lcQPropertiesTree;
|
||||
class lcTimelineWidget;
|
||||
#ifdef QT_NO_PRINTER
|
||||
class QPrinter;
|
||||
#endif
|
||||
|
||||
#define LC_MAX_RECENT_FILES 4
|
||||
|
||||
|
|
|
@ -1116,7 +1116,9 @@ void lcModel::DrawBackground(lcGLWidget* Widget)
|
|||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
#ifndef LC_OPENGLES
|
||||
glDisable(GL_LIGHTING);
|
||||
#endif
|
||||
|
||||
float ViewWidth = (float)Widget->mWidth;
|
||||
float ViewHeight = (float)Widget->mHeight;
|
||||
|
@ -1128,7 +1130,9 @@ void lcModel::DrawBackground(lcGLWidget* Widget)
|
|||
|
||||
if (mProperties.mBackgroundType == LC_BACKGROUND_GRADIENT)
|
||||
{
|
||||
#ifndef LC_OPENGLES
|
||||
glShadeModel(GL_SMOOTH);
|
||||
#endif
|
||||
|
||||
const lcVector3& Color1 = mProperties.mBackgroundGradientColor1;
|
||||
const lcVector3& Color2 = mProperties.mBackgroundGradientColor2;
|
||||
|
@ -1149,7 +1153,9 @@ void lcModel::DrawBackground(lcGLWidget* Widget)
|
|||
|
||||
Context->ClearVertexBuffer(); // context remove
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
glShadeModel(GL_FLAT);
|
||||
#endif
|
||||
}
|
||||
else if (mProperties.mBackgroundType == LC_BACKGROUND_IMAGE)
|
||||
{
|
||||
|
|
|
@ -199,8 +199,8 @@ bool lcTexture::Load(Image* images, int NumLevels, int Flags)
|
|||
int MipIndex = Flags & LC_TEXTURE_MIPMAPS ? 0 : 1;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, mTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (Flags & LC_TEXTURE_WRAPU) ? GL_REPEAT : GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (Flags & LC_TEXTURE_WRAPV) ? GL_REPEAT : GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (Flags & LC_TEXTURE_WRAPU) ? GL_REPEAT : GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (Flags & LC_TEXTURE_WRAPV) ? GL_REPEAT : GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filters[MipIndex][FilterIndex]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filters[1][FilterIndex]);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
|
|
@ -528,6 +528,7 @@ void lcLight::DrawPointLight(lcContext* Context) const
|
|||
|
||||
bool lcLight::Setup(int LightIndex)
|
||||
{
|
||||
#ifndef LC_OPENGLES
|
||||
GLenum LightName = (GLenum)(GL_LIGHT0 + LightIndex);
|
||||
|
||||
if (mState & LC_LIGHT_DISABLED)
|
||||
|
@ -567,6 +568,7 @@ bool lcLight::Setup(int LightIndex)
|
|||
glLightf(LightName, GL_SPOT_EXPONENT, mSpotExponent);
|
||||
glLightfv(LightName, GL_SPOT_DIRECTION, Dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1658,7 +1658,9 @@ void Project::ExportPOVRay()
|
|||
|
||||
Arguments.append(QString::fromLatin1("/EXIT"));
|
||||
|
||||
#ifndef QT_NO_PROCESS
|
||||
QProcess::execute(Dialog.mPOVRayPath, Arguments);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,8 +113,6 @@ bool TexFont::Load()
|
|||
|
||||
glGenTextures(1, &mTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, mTexture);
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDisable(GL_TEXTURE_GEN_T);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
|
|
@ -565,12 +565,13 @@ void View::OnDraw()
|
|||
mModel->DrawBackground(this);
|
||||
|
||||
const lcPreferences& Preferences = lcGetPreferences();
|
||||
const lcModelProperties& Properties = mModel->GetProperties();
|
||||
|
||||
mContext->SetViewMatrix(mCamera->mWorldView);
|
||||
mContext->SetProjectionMatrix(GetProjectionMatrix());
|
||||
mContext->SetProgram(LC_PROGRAM_SIMPLE); // todo: lighting
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
const lcModelProperties& Properties = mModel->GetProperties();
|
||||
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
||||
{
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
|
@ -603,7 +604,8 @@ void View::OnDraw()
|
|||
glFogfv(GL_FOG_COLOR, lcVector4(Properties.mFogColor, 1.0f));
|
||||
glEnable(GL_FOG);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
mContext->SetLineWidth(Preferences.mLineWidth);
|
||||
|
||||
mContext->DrawOpaqueMeshes(mScene.mOpaqueMeshes);
|
||||
|
@ -611,6 +613,7 @@ void View::OnDraw()
|
|||
|
||||
mContext->UnbindMesh(); // context remove
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
|
@ -620,6 +623,7 @@ void View::OnDraw()
|
|||
|
||||
if (Properties.mFogEnabled)
|
||||
glDisable(GL_FOG);
|
||||
#endif
|
||||
|
||||
if (DrawInterface)
|
||||
{
|
||||
|
@ -1554,7 +1558,9 @@ void View::DrawViewport()
|
|||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
#ifndef LC_OPENGLES
|
||||
glDisable(GL_LIGHTING);
|
||||
#endif
|
||||
|
||||
if (gMainWindow->GetActiveView() == this)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
|
|||
gMainWindow->GetActiveView()->MakeCurrent();
|
||||
|
||||
GLint Red, Green, Blue, Alpha, Depth, Stencil;
|
||||
GLboolean DoubleBuffer, RGBA;
|
||||
GLboolean DoubleBuffer = GL_TRUE, RGBA = GL_TRUE;
|
||||
|
||||
glGetIntegerv(GL_RED_BITS, &Red);
|
||||
glGetIntegerv(GL_GREEN_BITS, &Green);
|
||||
|
@ -24,8 +24,10 @@ lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
|
|||
glGetIntegerv(GL_ALPHA_BITS, &Alpha);
|
||||
glGetIntegerv(GL_DEPTH_BITS, &Depth);
|
||||
glGetIntegerv(GL_STENCIL_BITS, &Stencil);
|
||||
#ifndef LC_OPENGLES
|
||||
glGetBooleanv(GL_DOUBLEBUFFER, &DoubleBuffer);
|
||||
glGetBooleanv(GL_RGBA_MODE, &RGBA);
|
||||
#endif
|
||||
|
||||
QString VersionFormat = tr("OpenGL Version %1 (GLSL %2)\n%3 - %4\n\n");
|
||||
QString Version = VersionFormat.arg(QString((const char*)glGetString(GL_VERSION)), QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION)), QString((const char*)glGetString(GL_RENDERER)), QString((const char*)glGetString(GL_VENDOR)));
|
||||
|
|
Loading…
Reference in a new issue