mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Feat] (MG_Test/Backend/DirectVulkan): test glDrawElements
This commit is contained in:
@@ -107,6 +107,7 @@ set(SPIRV_CROSS_STATIC ON CACHE BOOL "Prefer static libs" FORCE)
|
|||||||
# add_subdirectory(3rdparty/DiligentCore)
|
# add_subdirectory(3rdparty/DiligentCore)
|
||||||
add_subdirectory(3rdparty/glslang)
|
add_subdirectory(3rdparty/glslang)
|
||||||
add_subdirectory(3rdparty/SPIRV-Cross)
|
add_subdirectory(3rdparty/SPIRV-Cross)
|
||||||
|
add_subdirectory(3rdparty/VulkanMemoryAllocator)
|
||||||
|
|
||||||
set(XXHASH_BUILD_XXHSUM OFF)
|
set(XXHASH_BUILD_XXHSUM OFF)
|
||||||
option(BUILD_SHARED_LIBS OFF)
|
option(BUILD_SHARED_LIBS OFF)
|
||||||
@@ -208,10 +209,12 @@ set(SOURCE_FILES
|
|||||||
MobileGL/MG_Backend/DirectGLES/Managers.cpp
|
MobileGL/MG_Backend/DirectGLES/Managers.cpp
|
||||||
|
|
||||||
MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp
|
MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp
|
||||||
|
MobileGL/MG_Backend/DirectVulkan/VmaImpl.cpp
|
||||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp
|
||||||
MobileGL/MG_Backend/DirectVulkan/Renderer/SwapchainObject.cpp
|
MobileGL/MG_Backend/DirectVulkan/Renderer/SwapchainObject.cpp
|
||||||
MobileGL/MG_Backend/DirectVulkan/Renderer/FrameContext.cpp
|
MobileGL/MG_Backend/DirectVulkan/Renderer/FrameContext.cpp
|
||||||
MobileGL/MG_Backend/DirectVulkan/Renderer/ProgramFactory.cpp
|
MobileGL/MG_Backend/DirectVulkan/Renderer/ProgramFactory.cpp
|
||||||
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferObject.cpp
|
||||||
|
|
||||||
MobileGL/MG_State/GLState/Core.cpp
|
MobileGL/MG_State/GLState/Core.cpp
|
||||||
MobileGL/MG_State/GLState/ErrorState/Error.cpp
|
MobileGL/MG_State/GLState/ErrorState/Error.cpp
|
||||||
@@ -246,6 +249,7 @@ set(MOBILEGL_LINK_LIBRARIES
|
|||||||
SPIRV-Tools-opt
|
SPIRV-Tools-opt
|
||||||
SPIRV-Tools
|
SPIRV-Tools
|
||||||
xxHash::xxhash
|
xxHash::xxhash
|
||||||
|
GPUOpen::VulkanMemoryAllocator
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MOBILEGL_INCLUDE_DIR
|
set(MOBILEGL_INCLUDE_DIR
|
||||||
|
|||||||
@@ -8,20 +8,26 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define EGLAPI
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
#include <GL/glcorearb.h>
|
||||||
|
#include <GL/glext.h>
|
||||||
|
#undef GL_GLEXT_PROTOTYPES
|
||||||
|
|
||||||
|
#ifndef EGLAPI
|
||||||
|
#define EGLAPI extern
|
||||||
|
#endif
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||||
#endif
|
#endif
|
||||||
#include "Init.h"
|
|
||||||
#include "MG_Backend/DirectVulkan/DirectVulkan.h"
|
|
||||||
#include "MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h"
|
|
||||||
|
|
||||||
#include <GLFW/glfw3native.h>
|
#include <GLFW/glfw3native.h>
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -30,6 +36,10 @@
|
|||||||
#include <objc/runtime.h>
|
#include <objc/runtime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace MobileGL {
|
||||||
|
void MG_Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
glfwInit();
|
glfwInit();
|
||||||
|
|
||||||
@@ -75,6 +85,16 @@ int main() {
|
|||||||
|
|
||||||
MobileGL::MG_Initialize();
|
MobileGL::MG_Initialize();
|
||||||
|
|
||||||
|
GLuint vao = 0;
|
||||||
|
glGenVertexArrays(1, &vao);
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
|
||||||
|
static constexpr GLushort kTriangleIndices[] = {0, 1, 2};
|
||||||
|
GLuint ebo = 0;
|
||||||
|
glGenBuffers(1, &ebo);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(kTriangleIndices), kTriangleIndices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(!glfwWindowShouldClose(window)) {
|
while(!glfwWindowShouldClose(window)) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
@@ -85,7 +105,7 @@ int main() {
|
|||||||
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
if (i % 500 > 250)
|
if (i % 500 > 250)
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, nullptr);
|
||||||
eglSwapBuffers(display, surface);
|
eglSwapBuffers(display, surface);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user