mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-06 02:09:55 +03:00
Get desktop GL conformance tests to build
The target for these tests is angle_deqp_gl_tests. Bug: angleproject:7533 Change-Id: I290822671d99da020f9a6a1f02bee43987644bf9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3766435 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Eddie Hatfield <eddiehatfield@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
448e2275f4
commit
c54ed79053
@@ -31,6 +31,7 @@ angle_source_set("sample_util") {
|
||||
"../:libGLESv1_CM",
|
||||
"../:libGLESv2",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"../:angle_common",
|
||||
"../util:angle_test_utils",
|
||||
@@ -42,6 +43,10 @@ angle_source_set("sample_util") {
|
||||
":sample_util_config",
|
||||
"../:no_gl_prototypes",
|
||||
]
|
||||
|
||||
if (angle_expose_wgl_entry_points) {
|
||||
defines = [ "ANGLE_EXPOSE_WGL_ENTRY_POINTS" ]
|
||||
}
|
||||
}
|
||||
|
||||
template("angle_sample") {
|
||||
@@ -90,6 +95,10 @@ angle_sample("hello_triangle") {
|
||||
sources = [ "hello_triangle/HelloTriangle.cpp" ]
|
||||
}
|
||||
|
||||
angle_sample("hello_triangle_gl") {
|
||||
sources = [ "hello_triangle_gl/HelloTriangleGL.cpp" ]
|
||||
}
|
||||
|
||||
angle_sample("mip_map_2d") {
|
||||
sources = [ "mip_map_2d/MipMap2D.cpp" ]
|
||||
}
|
||||
|
||||
85
samples/hello_triangle_gl/HelloTriangleGL.cpp
Normal file
85
samples/hello_triangle_gl/HelloTriangleGL.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// Copyright 2022 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// Based on Hello_Triangle.c from
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
|
||||
#include "SampleApplication.h"
|
||||
|
||||
#include "util/shader_utils.h"
|
||||
|
||||
// Practically identical to the normal HelloTrianglesSample, but uses desktop GL instead.
|
||||
class HelloTriangleGLSample : public SampleApplication
|
||||
{
|
||||
public:
|
||||
HelloTriangleGLSample(int argc, char **argv)
|
||||
: SampleApplication("HelloTriangle", argc, argv, ClientType::GL3_3_CORE)
|
||||
{}
|
||||
|
||||
bool initialize() override
|
||||
{
|
||||
constexpr char kVS[] = R"(attribute vec4 vPosition;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vPosition;
|
||||
})";
|
||||
|
||||
constexpr char kFS[] = R"(precision mediump float;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
|
||||
mProgram = CompileProgram(kVS, kFS);
|
||||
if (!mProgram)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void destroy() override { glDeleteProgram(mProgram); }
|
||||
|
||||
void draw() override
|
||||
{
|
||||
GLfloat vertices[] = {
|
||||
0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f,
|
||||
};
|
||||
|
||||
// Set the viewport
|
||||
glViewport(0, 0, getWindow()->getWidth(), getWindow()->getHeight());
|
||||
|
||||
// Clear the color buffer
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// Use the program object
|
||||
glUseProgram(mProgram);
|
||||
|
||||
// Load the vertex data
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
private:
|
||||
GLuint mProgram;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
HelloTriangleGLSample app(argc, argv);
|
||||
return app.run();
|
||||
}
|
||||
@@ -139,6 +139,18 @@ SampleApplication::SampleApplication(std::string name,
|
||||
glMinorVersion = 3;
|
||||
profileMask = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
|
||||
break;
|
||||
case ClientType::GL4_6_CORE:
|
||||
eglClientType = EGL_OPENGL_API;
|
||||
glMajorVersion = 4;
|
||||
glMinorVersion = 6;
|
||||
profileMask = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT;
|
||||
break;
|
||||
case ClientType::GL4_6_COMPATIBILITY:
|
||||
eglClientType = EGL_OPENGL_API;
|
||||
glMajorVersion = 4;
|
||||
glMinorVersion = 6;
|
||||
profileMask = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@@ -161,10 +173,16 @@ SampleApplication::SampleApplication(std::string name,
|
||||
}
|
||||
else
|
||||
{
|
||||
mGLWindow = mEGLWindow =
|
||||
#if defined(ANGLE_EXPOSE_WGL_ENTRY_POINTS)
|
||||
mGLWindow = WGLWindow::New(eglClientType, glMajorVersion, glMinorVersion, profileMask);
|
||||
mEntryPointsLib.reset(angle::OpenSharedLibrary("opengl32", angle::SearchType::ModuleDir));
|
||||
mDriverType = angle::GLESDriverType::SystemWGL;
|
||||
#else
|
||||
mGLWindow = mEGLWindow =
|
||||
EGLWindow::New(eglClientType, glMajorVersion, glMinorVersion, profileMask);
|
||||
mEntryPointsLib.reset(
|
||||
angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ModuleDir));
|
||||
#endif // defined(ANGLE_EXPOSE_WGL_ENTRY_POINTS)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ enum class ClientType
|
||||
ES3_1,
|
||||
GL3_3_CORE,
|
||||
GL3_3_COMPATIBILITY,
|
||||
GL4_6_CORE,
|
||||
GL4_6_COMPATIBILITY,
|
||||
};
|
||||
|
||||
class SampleApplication
|
||||
|
||||
Reference in New Issue
Block a user