Added macOS compatability again
This commit is contained in:
@@ -23,9 +23,11 @@ message(STATUS "SFML found: ${SFML_FOUND}")
|
|||||||
find_package( OpenCL REQUIRED )
|
find_package( OpenCL REQUIRED )
|
||||||
message(STATUS "OpenCL found: ${OPENCL_FOUND}")
|
message(STATUS "OpenCL found: ${OPENCL_FOUND}")
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
# Find GLEW
|
# Find GLEW
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
message(STATUS "GLEW found: ${GLEW_FOUND}")
|
message(STATUS "GLEW found: ${GLEW_FOUND}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Find Vulkan
|
# Find Vulkan
|
||||||
#find_package(VULKAN REQUIRED)
|
#find_package(VULKAN REQUIRED)
|
||||||
@@ -127,6 +129,7 @@ target_link_libraries (${PNAME} ${OpenCL_LIBRARY})
|
|||||||
target_link_libraries (${PNAME} ${OPENGL_LIBRARIES})
|
target_link_libraries (${PNAME} ${OPENGL_LIBRARIES})
|
||||||
target_link_libraries (${PNAME} ${GLEW_LIBRARIES})
|
target_link_libraries (${PNAME} ${GLEW_LIBRARIES})
|
||||||
#target_link_libraries (${PNAME} ${Vulkan_LIBRARIES})
|
#target_link_libraries (${PNAME} ${Vulkan_LIBRARIES})
|
||||||
|
#target_link_libraries(${PNAME} "/Users/cs445001_09/Desktop/voxel-raycaster/SFML/extlibs/freetype.framework/Versions/A/freetype")
|
||||||
|
|
||||||
if (NOT WIN32)
|
if (NOT WIN32)
|
||||||
target_link_libraries (${PNAME} -lpthread)
|
target_link_libraries (${PNAME} -lpthread)
|
||||||
|
|||||||
@@ -3,9 +3,15 @@
|
|||||||
#include <util.hpp>
|
#include <util.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#ifdef defined _WIN32
|
||||||
#define GLEW_STATIC
|
#define GLEW_STATIC
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
#elif defined TARGET_OS_MAC
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
class GL_Testing
|
class GL_Testing
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#elif defined TARGET_OS_MAC
|
#elif defined TARGET_OS_MAC
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
#include <OpenCL/opencl.h>
|
#include <OpenCL/opencl.h>
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ GL_Testing::GL_Testing() {
|
|||||||
matrix = new GLfloat[16];
|
matrix = new GLfloat[16];
|
||||||
memcpy(matrix, tmp, sizeof(GLfloat) * 16);
|
memcpy(matrix, tmp, sizeof(GLfloat) * 16);
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
GLint err = glewInit();
|
GLint err = glewInit();
|
||||||
|
#elif _WIN32
|
||||||
|
GLint err = glewInit();
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
GLint err = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
std::cout << "error initializing glew" << std::endl;
|
std::cout << "error initializing glew" << std::endl;
|
||||||
@@ -98,11 +104,26 @@ void GL_Testing::create_buffers() {
|
|||||||
// Second Triangle
|
// Second Triangle
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
glGenVertexArrays(1, &VAO);
|
glGenVertexArrays(1, &VAO);
|
||||||
|
#elif defined _WIN32
|
||||||
|
glGenVertexArrays(1, &VAO);
|
||||||
|
#elif defined TARGET_OS_MAC
|
||||||
|
glGenVertexArraysAPPLE(1, &VAO);
|
||||||
|
#endif
|
||||||
|
|
||||||
glGenBuffers(1, &VBO);
|
glGenBuffers(1, &VBO);
|
||||||
glGenBuffers(1, &EBO);
|
glGenBuffers(1, &EBO);
|
||||||
// Bind the Vertex Array Object first, then bind and set vertex buffer(s) and attribute pointer(s).
|
// Bind the Vertex Array Object first, then bind and set vertex buffer(s) and attribute pointer(s).
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
glBindVertexArray(VAO);
|
glBindVertexArray(VAO);
|
||||||
|
#elif defined _WIN32
|
||||||
|
glBindVertexArray(VAO);
|
||||||
|
#elif defined TARGET_OS_MAC
|
||||||
|
glBindVertexArrayAPPLE(VAO);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||||
@@ -115,7 +136,13 @@ void GL_Testing::create_buffers() {
|
|||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
glBindVertexArray(0);
|
#ifdef linux
|
||||||
|
glbindvertexarray(0);
|
||||||
|
#elif defined _win32
|
||||||
|
glbindvertexarray(0);
|
||||||
|
#elif defined target_os_mac
|
||||||
|
glbindvertexarrayapple(0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL_Testing::transform()
|
void GL_Testing::transform()
|
||||||
@@ -146,9 +173,27 @@ void GL_Testing::rotate(double delta) {
|
|||||||
void GL_Testing::draw() {
|
void GL_Testing::draw() {
|
||||||
|
|
||||||
glUseProgram(shader_program);
|
glUseProgram(shader_program);
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
glBindVertexArray(VAO);
|
glBindVertexArray(VAO);
|
||||||
|
#elif defined _WIN32
|
||||||
|
glBindVertexArray(VAO);
|
||||||
|
#elif defined TARGET_OS_MAC
|
||||||
|
glBindVertexArrayAPPLE(VAO);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//glDrawArrays(GL_TRIANGLES, 0, 6);
|
//glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0);
|
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0);
|
||||||
glBindVertexArray(0);
|
|
||||||
|
#ifdef linux
|
||||||
|
glbindVertexArray(0);
|
||||||
|
#elif defined _win32
|
||||||
|
glbindVertexArray(0);
|
||||||
|
#elif defined target_os_mac
|
||||||
|
glbindVertexArrayAPPLE(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -74,7 +74,12 @@ int main() {
|
|||||||
|
|
||||||
// Keep at this at the top of main. I think it has to do with it and
|
// Keep at this at the top of main. I think it has to do with it and
|
||||||
// sf::RenderWindow stepping on each others feet
|
// sf::RenderWindow stepping on each others feet
|
||||||
|
#ifdef linux
|
||||||
glewInit();
|
glewInit();
|
||||||
|
#elif defined _WIN32
|
||||||
|
glewInit();
|
||||||
|
#elif defined TARGET_OS_MAC
|
||||||
|
#endif
|
||||||
|
|
||||||
// The socket listener for interacting with the TCP streaming android controller
|
// The socket listener for interacting with the TCP streaming android controller
|
||||||
NetworkInput ni;
|
NetworkInput ni;
|
||||||
@@ -92,7 +97,7 @@ int main() {
|
|||||||
_map.a.get_voxel(sf::Vector3i(5, 5, 0));
|
_map.a.get_voxel(sf::Vector3i(5, 5, 0));
|
||||||
// =============================
|
// =============================
|
||||||
|
|
||||||
return 0;
|
//return 0;
|
||||||
|
|
||||||
sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
||||||
window.setMouseCursorVisible(false);
|
window.setMouseCursorVisible(false);
|
||||||
@@ -147,7 +152,7 @@ int main() {
|
|||||||
// Load in the spritesheet texture
|
// Load in the spritesheet texture
|
||||||
sf::Texture spritesheet;
|
sf::Texture spritesheet;
|
||||||
spritesheet.loadFromFile("../assets/textures/minecraft_tiles.png");
|
spritesheet.loadFromFile("../assets/textures/minecraft_tiles.png");
|
||||||
spritesheet.getNativeHandle();
|
//spritesheet.getNativeHandle();
|
||||||
raycaster->create_texture_atlas(&spritesheet, sf::Vector2i(16, 16));
|
raycaster->create_texture_atlas(&spritesheet, sf::Vector2i(16, 16));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ void Hardware_Caster::validate()
|
|||||||
|
|
||||||
void Hardware_Caster::create_texture_atlas(sf::Texture *t, sf::Vector2i tile_dim) {
|
void Hardware_Caster::create_texture_atlas(sf::Texture *t, sf::Vector2i tile_dim) {
|
||||||
|
|
||||||
create_image_buffer("texture_atlas", t->getSize().x * t->getSize().x * 4 * sizeof(float), t);
|
create_image_buffer("texture_atlas", t->getSize().y * t->getSize().x * 4 * sizeof(float), t);
|
||||||
|
|
||||||
// create_buffer observes arg 3's
|
// create_buffer observes arg 3's
|
||||||
|
|
||||||
@@ -441,7 +441,9 @@ int Hardware_Caster::check_cl_khr_gl_sharing() {
|
|||||||
char *ext_str = new char[ext_str_size];
|
char *ext_str = new char[ext_str_size];
|
||||||
clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, ext_str_size, ext_str, &ext_str_size);
|
clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, ext_str_size, ext_str, &ext_str_size);
|
||||||
|
|
||||||
if (std::string(ext_str).find("cl_khr_gl_sharing") == std::string::npos) {
|
std::cout << std::string(ext_str);
|
||||||
|
if (std::string(ext_str).find("cl_khr_gl_sharing") == std::string::npos &&
|
||||||
|
std::string(ext_str).find("cl_APPLE_gl_sharing") == std::string::npos) {
|
||||||
std::cout << "No support for the cl_khr_gl_sharing extension";
|
std::cout << "No support for the cl_khr_gl_sharing extension";
|
||||||
delete ext_str;
|
delete ext_str;
|
||||||
return RayCaster::SHARING_NOT_SUPPORTED;
|
return RayCaster::SHARING_NOT_SUPPORTED;
|
||||||
@@ -522,9 +524,11 @@ int Hardware_Caster::set_kernel_arg(
|
|||||||
sizeof(cl_mem),
|
sizeof(cl_mem),
|
||||||
(void *)&buffer_map.at(buffer_name));
|
(void *)&buffer_map.at(buffer_name));
|
||||||
|
|
||||||
if (assert(error, "clSetKernelArg"))
|
if (assert(error, "clSetKernelArg")){
|
||||||
|
std::cout << buffer_name << std::endl;
|
||||||
|
std::cout << buffer_map.at(buffer_name) << std::endl;
|
||||||
return OPENCL_ERROR;
|
return OPENCL_ERROR;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -630,6 +634,8 @@ int Hardware_Caster::run_kernel(std::string kernel_name, const int work_size) {
|
|||||||
|
|
||||||
cl_kernel kernel = kernel_map.at(kernel_name);
|
cl_kernel kernel = kernel_map.at(kernel_name);
|
||||||
|
|
||||||
|
std::cout << std::endl << command_queue << std::endl;
|
||||||
|
|
||||||
error = clEnqueueAcquireGLObjects(getCommandQueue(), 1, &buffer_map.at("image"), 0, 0, 0);
|
error = clEnqueueAcquireGLObjects(getCommandQueue(), 1, &buffer_map.at("image"), 0, 0, 0);
|
||||||
if (assert(error, "clEnqueueAcquireGLObjects"))
|
if (assert(error, "clEnqueueAcquireGLObjects"))
|
||||||
return OPENCL_ERROR;
|
return OPENCL_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user