Missed in previous checkin. Make sure not to include glew.h in headers

where it can cause havoc downstream, and move vertexBuffers into the cpp
file to avoid gl.h inclusion and to fix dynamic cast issues.  These were
found during Presto integration.
This commit is contained in:
gelder 2012-06-20 18:51:16 -07:00
parent 0e27dc6c20
commit 2c99708795
13 changed files with 37 additions and 55 deletions

View File

@ -55,6 +55,8 @@
// a particular purpose and non-infringement.
//
#include <GL/glew.h>
// Include this first to avoid winsock2.h problems on Windows:
#include <maya/MTypes.h>
@ -65,8 +67,6 @@
#include "hbrUtil.h"
#include <GL/glew.h>
// Maya API includes
#include <maya/MDagPath.h>
#include <maya/MFnPlugin.h>

View File

@ -71,6 +71,7 @@ set(SOURCE_FILES
cpuKernel.cpp
kernelDispatcher.cpp
mesh.cpp
vertexBuffer.cpp
)
set(KERNEL_FILES

View File

@ -54,11 +54,12 @@
// exclude the implied warranties of merchantability, fitness for
// a particular purpose and non-infringement.
//
#include <GL/glew.h>
#include "../version.h"
#include "../osd/cpuDispatcher.h"
#include "../osd/cpuKernel.h"
#include <GL/glew.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -60,7 +60,8 @@
#include "../version.h"
#include "../osd/kernelDispatcher.h"
#include <GL/glew.h>
#include <GL/glu.h>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

View File

@ -61,7 +61,7 @@
#include "../osd/kernelDispatcher.h"
#include "../osd/vertexBuffer.h"
#include <GL/glew.h>
#include <GL/glu.h>
#include <utility>
#include <vector>

View File

@ -56,7 +56,7 @@
//
#include "../version.h"
#include <GL/glew.h>
#include <GL/glu.h>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

View File

@ -55,10 +55,11 @@
// a particular purpose and non-infringement.
//
#include "../version.h"
#include <GL/glew.h>
#include "../osd/glslDispatcher.h"
#include "../osd/local.h"
#include <GL/glew.h>
#include <stdlib.h>
#include <string.h>
#include <functional>
@ -660,5 +661,12 @@ OsdGlslKernelDispatcher::ComputeShader::ApplyLoopVertexVerticesKernelA(
transformGpuBufferData(vertex, varying, offset, start, end);
}
void
OsdGlslKernelDispatcher::ComputeShader::UseProgram () const
{
glUseProgram(_program);
}
} // end namespace OPENSUBDIV_VERSION
} // end namespace OpenSubdiv

View File

@ -155,11 +155,8 @@ protected:
void ApplyLoopVertexVerticesKernelA(OsdGpuVertexBuffer *vertex, OsdGpuVertexBuffer *varying, int V_ITa_ofs, int V_W_ofs, int offset, bool pass, int start, int end);
void UseProgram () const {
glUseProgram(_program);
}
void UseProgram () const;
struct Match {
Match(int numVertexElements, int numVaryingElements) :

View File

@ -55,6 +55,8 @@
// a particular purpose and non-infringement.
//
#include "../version.h"
#include <GL/glew.h>
#include "../osd/kernelDispatcher.h"
#include "../osd/cpuDispatcher.h"
#if OPENSUBDIV_HAS_CUDA
@ -67,7 +69,7 @@
#include "../osd/clDispatcher.h"
#endif
#include <GL/glew.h>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

View File

@ -63,7 +63,7 @@
#include "../version.h"
#include "../far/dispatcher.h"
#include <GL/glew.h>
#include <GL/glu.h>
#include <map>
#include <string>
#include <vector>

View File

@ -59,7 +59,7 @@
#include "../version.h"
#include "../osd/mesh.h"
#include "../osd/local.h"
#include "../osd/dump.cpp"
//#include "../osd/dump.cpp"
#include "../osd/kernelDispatcher.h"
#include "../osd/cpuDispatcher.h"

View File

@ -59,7 +59,7 @@
#include <string>
#include <vector>
#include <GL/glew.h>
#include <GL/glu.h>
#include "../version.h"
#include "../hbr/mesh.h"

View File

@ -1,7 +1,8 @@
#ifndef OSD_VERTEX_BUFFER_H
#define OSD_VERTEX_BUFFER_H
#include <GL/glew.h>
#include <GL/glu.h>
#include <string.h> // memcpy (tobe moved to cpp)
namespace OpenSubdiv {
@ -10,7 +11,7 @@ namespace OPENSUBDIV_VERSION {
class OsdVertexBuffer {
public:
OsdVertexBuffer(int numElements) : _numElements(numElements) {}
virtual ~OsdVertexBuffer() {}
virtual ~OsdVertexBuffer();
virtual void UpdateData(const float *src, int numVertices) = 0;
@ -26,24 +27,11 @@ protected:
class OsdGpuVertexBuffer : public OsdVertexBuffer {
public:
OsdGpuVertexBuffer(int numElements, int numVertices) : OsdVertexBuffer(numElements), _vbo(0) {
int size = numElements * numVertices * sizeof(float);
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
virtual ~OsdGpuVertexBuffer() {
glDeleteBuffers(1, &_vbo);
}
OsdGpuVertexBuffer(int numElements, int numVertices);
virtual void UpdateData(const float *src, int numVertices) {
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
float * pointer = (float*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
memcpy(pointer, src, _numElements * numVertices * sizeof(float));
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
virtual ~OsdGpuVertexBuffer();
virtual void UpdateData(const float *src, int numVertices);
virtual GLuint GetGpuBuffer() {
return _vbo;
@ -55,33 +43,17 @@ protected:
class OsdCpuVertexBuffer : public OsdVertexBuffer {
public:
OsdCpuVertexBuffer(int numElements, int numVertices) : OsdVertexBuffer(numElements), _cpuVbo(NULL), _vboSize(0), _vbo(0) {
_vboSize = numElements * numVertices;
_cpuVbo = new float[numElements * numVertices];
}
virtual ~OsdCpuVertexBuffer() {
delete [] _cpuVbo;
if (_vbo)
glDeleteBuffers(1, &_vbo);
}
OsdCpuVertexBuffer(int numElements, int numVertices);
virtual ~OsdCpuVertexBuffer();
virtual void UpdateData(const float *src, int numVertices) {
memcpy(_cpuVbo, src, _numElements * numVertices * sizeof(float));
}
virtual void UpdateData(const float *src, int numVertices);
float *GetCpuBuffer() {
return _cpuVbo;
}
// XXX: this method name is missleading
virtual GLuint GetGpuBuffer() {
if (!_vbo)
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, _vboSize * sizeof(float), _cpuVbo, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
return _vbo;
}
virtual GLuint GetGpuBuffer();
protected:
float *_cpuVbo;