only use VBO's and USE_GPU_COPY -> OpenCL/OpenGL interop under Windows, so that stuff compiles/runs on Mac OSX and Linux
See Issue 495
This commit is contained in:
@@ -17,11 +17,12 @@ subject to the following restrictions:
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef USE_MINICL
|
||||
#define USE_SIMDAWARE_SOLVER
|
||||
#define USE_GPU_SOLVER
|
||||
#ifdef _WIN32
|
||||
#define USE_GPU_COPY //only tested on Windows, may work under Linux
|
||||
#if defined (_WIN32)
|
||||
#define USE_GPU_COPY //only tested on Windows
|
||||
#endif //_WIN32
|
||||
#endif //USE_MINICL
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include "LinearMath/btScalar.h"
|
||||
#include <stdio.h> //sprintf
|
||||
|
||||
|
||||
struct vertex_struct
|
||||
{
|
||||
@@ -49,7 +49,9 @@ class piece_of_cloth
|
||||
created = false;
|
||||
cpu_buffer = NULL;
|
||||
m_vertexBufferDescriptor = NULL;
|
||||
#ifdef USE_GPU_COPY
|
||||
clothVBO = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool created;
|
||||
@@ -64,6 +66,7 @@ class piece_of_cloth
|
||||
int height;
|
||||
|
||||
GLuint m_texture;
|
||||
#ifdef USE_GPU_COPY
|
||||
|
||||
GLuint clothVBO;
|
||||
|
||||
@@ -71,6 +74,7 @@ class piece_of_cloth
|
||||
{
|
||||
return clothVBO;
|
||||
}
|
||||
#endif //USE_GPU_COPY
|
||||
|
||||
void draw(void)
|
||||
{
|
||||
@@ -80,26 +84,25 @@ class piece_of_cloth
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glColor3f(0.0f, 1.0f, 1.0f);
|
||||
|
||||
#ifdef USE_GPU_COPY
|
||||
int error = 0;
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, clothVBO);
|
||||
#ifndef USE_GPU_COPY
|
||||
// Upload data to VBO
|
||||
// Needed while we're not doing interop
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_struct)*width*height, &(cpu_buffer[0]), GL_DYNAMIC_DRAW);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
#ifdef USE_GPU_COPY
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
#endif
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture);
|
||||
#ifdef USE_GPU_COPY
|
||||
error = glGetError();
|
||||
|
||||
|
||||
// VBO version
|
||||
glVertexPointer( 3, GL_FLOAT, sizeof(vertex_struct), (const GLvoid *)0 );
|
||||
error = glGetError();
|
||||
@@ -107,15 +110,25 @@ class piece_of_cloth
|
||||
error = glGetError();
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(vertex_struct), (const GLvoid *)(sizeof(float)*6) );
|
||||
error = glGetError();
|
||||
|
||||
|
||||
|
||||
#else
|
||||
glVertexPointer( 3, GL_FLOAT, sizeof(vertex_struct), reinterpret_cast< GLvoid* >(&(cpu_buffer[0].pos[0])) );
|
||||
//glNormalPointer( 3, sizeof(vertex_struct), reinterpret_cast< GLvoid* >(&(cpu_buffer[0].normal[0])) );
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(vertex_struct), reinterpret_cast< GLvoid* >(&(cpu_buffer[0].texcoord[0])) );
|
||||
#endif
|
||||
|
||||
glDrawElements(GL_TRIANGLES, (height-1 )*(width-1)*3*2, GL_UNSIGNED_INT, indices);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
// glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
error = glGetError();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#ifdef USE_GPU_COPY
|
||||
error = glGetError();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
error = glGetError();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void create_texture(std::string filename)
|
||||
@@ -248,7 +261,7 @@ class piece_of_cloth
|
||||
indices[baseIndex+5] = x+width + y*width;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_GPU_COPY
|
||||
// Construct VBO
|
||||
glGenBuffers(1, &clothVBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, clothVBO);
|
||||
@@ -256,8 +269,6 @@ class piece_of_cloth
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_struct)*width*height, &(cpu_buffer[0]), GL_DYNAMIC_DRAW);
|
||||
int error = glGetError();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user