Created
June 2, 2020 21:58
-
-
Save fujii/31ab48dde987b13218ba31cd80563c2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/samples/multi_window/MultiWindow.cpp b/samples/multi_window/MultiWindow.cpp | |
index 180726655..bcccf0c16 100644 | |
--- a/samples/multi_window/MultiWindow.cpp | |
+++ b/samples/multi_window/MultiWindow.cpp | |
@@ -64,8 +64,17 @@ void main() | |
return false; | |
} | |
+ std::vector<EGLint> attributes; | |
+ attributes.push_back(EGL_FIXED_SIZE_ANGLE); | |
+ attributes.push_back(EGL_TRUE); | |
+ attributes.push_back(EGL_WIDTH); | |
+ attributes.push_back(window.osWindow->getWidth()); | |
+ attributes.push_back(EGL_HEIGHT); | |
+ attributes.push_back(window.osWindow->getHeight()); | |
+ attributes.push_back(EGL_NONE); | |
+ | |
window.surface = eglCreateWindowSurface(getDisplay(), getConfig(), | |
- window.osWindow->getNativeWindow(), nullptr); | |
+ window.osWindow->getNativeWindow(), attributes.data()); | |
if (window.surface == EGL_NO_SURFACE) | |
{ | |
return false; | |
@@ -76,6 +85,7 @@ void main() | |
mWindows.push_back(window); | |
} | |
+#if 0 | |
int baseX = rootWindow.osWindow->getX(); | |
int baseY = rootWindow.osWindow->getY(); | |
for (auto &window : mWindows) | |
@@ -87,6 +97,7 @@ void main() | |
window.osWindow->setPosition(x, y); | |
window.osWindow->resize(width, height); | |
} | |
+#endif | |
return true; | |
} | |
@@ -105,6 +116,13 @@ void main() | |
void draw() override | |
{ | |
+#if 1 | |
+ static auto prevTick = ::GetTickCount(); | |
+ if (::GetTickCount() - prevTick < 1000) | |
+ return; | |
+ prevTick = ::GetTickCount(); | |
+#endif | |
+ | |
OSWindow *rootWindow = mWindows[0].osWindow; | |
int left = rootWindow->getX(); | |
int right = rootWindow->getX() + rootWindow->getWidth(); | |
@@ -120,6 +138,7 @@ void main() | |
bottom = std::max(bottom, window->getY() + window->getHeight()); | |
} | |
+#if 0 | |
float midX = (left + right) * 0.5f; | |
float midY = (top + bottom) * 0.5f; | |
@@ -127,14 +146,21 @@ void main() | |
Matrix4::rotate(mRotation, Vector3(0.0f, 0.0f, 1.0f)) * | |
Matrix4::translate(Vector3(-midX, -midY, 0.0f)); | |
Matrix4 viewMatrix = Matrix4::identity(); | |
+#endif | |
for (auto &windowRecord : mWindows) | |
{ | |
OSWindow *window = windowRecord.osWindow; | |
EGLSurface surface = windowRecord.surface; | |
+ eglSurfaceAttrib(getDisplay(), surface, EGL_WIDTH, window->getWidth()); | |
+ eglSurfaceAttrib(getDisplay(), surface, EGL_HEIGHT, window->getHeight()); | |
+ eglWaitClient(); | |
+ | |
eglMakeCurrent(getDisplay(), surface, surface, getContext()); | |
+ | |
+#if 0 | |
Matrix4 orthoMatrix = | |
Matrix4::ortho(static_cast<float>(window->getX()), | |
static_cast<float>(window->getX() + window->getWidth()), | |
@@ -149,6 +175,21 @@ void main() | |
Matrix4::transform(mvpMatrix, Vector4(static_cast<float>(right), | |
static_cast<float>(bottom), 0.0f, 1.0f)), | |
}; | |
+#else | |
+ | |
+ float x0 = -1; | |
+ float y0 = 1; | |
+ float x1 = x0 + 200 * 2.0 / window->getWidth(); | |
+ float y1 = y0 - 200 * 2.0 / window->getHeight(); | |
+ Vector3 vertices[] = { | |
+ { x0, y0, 0.0f }, | |
+ { x1, y0, 0.0f }, | |
+ { x0, y1, 0.0f }, | |
+ { x1, y0, 0.0f }, | |
+ { x0, y1, 0.0f }, | |
+ { x1, y1, 0.0f }, | |
+ }; | |
+#endif | |
// Set the viewport | |
glViewport(0, 0, window->getWidth(), window->getHeight()); | |
@@ -163,7 +204,7 @@ void main() | |
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vertices[0].data()); | |
glEnableVertexAttribArray(0); | |
- glDrawArrays(GL_TRIANGLES, 0, 3); | |
+ glDrawArrays(GL_TRIANGLES, 0, 6); | |
eglSwapBuffers(getDisplay(), surface); | |
} | |
diff --git a/util/EGLWindow.cpp b/util/EGLWindow.cpp | |
index c257290df..c41ad7825 100644 | |
--- a/util/EGLWindow.cpp | |
+++ b/util/EGLWindow.cpp | |
@@ -330,6 +330,9 @@ bool EGLWindow::initializeSurface(OSWindow *osWindow, | |
: EGL_FALSE); | |
} | |
+ surfaceAttributes.push_back(EGL_FIXED_SIZE_ANGLE); | |
+ surfaceAttributes.push_back(EGL_TRUE); | |
+ | |
surfaceAttributes.push_back(EGL_NONE); | |
osWindow->resetNativeWindow(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment