Fix gl / glew includes and fix some related windows build issues

Closes #29.
This commit is contained in:
manuelk 2012-06-21 12:30:12 -07:00
parent ec30d8cf03
commit d9f46575cd
14 changed files with 47 additions and 176 deletions

View File

@ -59,12 +59,12 @@
#include "../osd/local.h"
#if defined(_WIN32)
#include <windows.h>
#include <windows.h>
#elif defined(__APPLE__)
#include <OpenCL/opencl.h>
#include <OpenCL/opencl.h>
#else
#include <GL/glx.h>
#include <CL/opencl.h>
#include <GL/glx.h>
#include <CL/opencl.h>
#endif
#ifdef _MSC_VER

View File

@ -62,9 +62,9 @@
#include "../osd/vertexBuffer.h"
#if defined(__APPLE__)
#include <OpenCL/opencl.h>
#include <OpenCL/opencl.h>
#else
#include <CL/opencl.h>
#include <CL/opencl.h>
#endif
namespace OpenSubdiv {

View File

@ -54,7 +54,6 @@
// 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"

View File

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

View File

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

View File

@ -1,141 +0,0 @@
//
// Copyright (C) Pixar. All rights reserved.
//
// This license governs use of the accompanying software. If you
// use the software, you accept this license. If you do not accept
// the license, do not use the software.
//
// 1. Definitions
// The terms "reproduce," "reproduction," "derivative works," and
// "distribution" have the same meaning here as under U.S.
// copyright law. A "contribution" is the original software, or
// any additions or changes to the software.
// A "contributor" is any person or entity that distributes its
// contribution under this license.
// "Licensed patents" are a contributor's patent claims that read
// directly on its contribution.
//
// 2. Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license,
// including the license conditions and limitations in section 3,
// each contributor grants you a non-exclusive, worldwide,
// royalty-free copyright license to reproduce its contribution,
// prepare derivative works of its contribution, and distribute
// its contribution or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license,
// including the license conditions and limitations in section 3,
// each contributor grants you a non-exclusive, worldwide,
// royalty-free license under its licensed patents to make, have
// made, use, sell, offer for sale, import, and/or otherwise
// dispose of its contribution in the software or derivative works
// of the contribution in the software.
//
// 3. Conditions and Limitations
// (A) No Trademark License- This license does not grant you
// rights to use any contributor's name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over
// patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends
// automatically.
// (C) If you distribute any portion of the software, you must
// retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source
// code form, you may do so only under this license by including a
// complete copy of this license with your distribution. If you
// distribute any portion of the software in compiled or object
// code form, you may only do so under a license that complies
// with this license.
// (E) The software is licensed "as-is." You bear the risk of
// using it. The contributors give no express warranties,
// guarantees or conditions. You may have additional consumer
// rights under your local laws which this license cannot change.
// To the extent permitted under your local laws, the contributors
// exclude the implied warranties of merchantability, fitness for
// a particular purpose and non-infringement.
//
#include "../version.h"
#include <GL/glu.h>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
static void
DumpBuffer(GLuint buffer) {
printf("----------------------------------------------------\n");
glBindBuffer(GL_ARRAY_BUFFER, buffer);
int size = 0;
glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
float *p = (float*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
if (p)
for (int i = 0; i < size/16; i++, p+=4)
printf("%d: %f %f %f %f\n", i, p[0], p[1], p[2], p[3]);
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
static void
DumpBufferInt(GLuint buffer) {
if (buffer == 0) return;
printf("---------------------------------------------------\n");
glBindBuffer(GL_ARRAY_BUFFER, buffer);
int size = 0;
glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
unsigned int *p = (unsigned int*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
if (p) {
for (int i = 0; i < size/4; i++)
printf("%04x ", *p++);
printf("\n");
}
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
static void
DebugAttribs(GLuint program) {
GLint numAttributes = 0;
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &numAttributes);
if (numAttributes == 0) {
printf("No attributes\n");
return;
}
GLint maxNameLength = 0;
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxNameLength);
char * name = new char[maxNameLength];
for (int i=0; i<numAttributes; ++i) {
GLint size;
GLenum type;
glGetActiveAttrib(program, i, maxNameLength, NULL, &size, &type, name);
printf("Attrib %s, size=%d, type=%x\n", name, size, type);
}
}
static void
DebugProgram(GLuint program) {
unsigned char buffer[1*1024*1024];
GLsizei length = 0;
GLenum format;
glGetProgramBinary(program, 10*1024*1024, &length, &format, buffer);
FILE *fp =fopen ("out.bin", "wb");
if (fp) {
fwrite(buffer, 1, length, fp);
fclose(fp);
}
}
} // end namespace OPENSUBDIV_VERSION
} // end namespace OpenSubdiv

View File

@ -55,7 +55,12 @@
// a particular purpose and non-infringement.
//
#include "../version.h"
#include <GL/glew.h>
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#include <OpenGL/gl.h>
#endif
#include "../osd/glslDispatcher.h"
#include "../osd/local.h"

View File

@ -57,6 +57,12 @@
#ifndef OSD_GLSL_DISPATCHER_H
#define OSD_GLSL_DISPATCHER_H
#if not defined(__APPLE__)
#include <GL/gl.h>
#else
#include <OpenGL/gl.h>
#endif
#include "../version.h"
#include "../osd/kernelDispatcher.h"

View File

@ -55,18 +55,20 @@
// 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
#include "../osd/cudaDispatcher.h"
#include "../osd/cudaDispatcher.h"
#endif
#if OPENSUBDIV_HAS_GLSL
#include "../osd/glslDispatcher.h"
#include "../osd/glslDispatcher.h"
#endif
#if OPENSUBDIV_HAS_CL
#include "../osd/clDispatcher.h"
#include "../osd/clDispatcher.h"
#endif
@ -81,19 +83,19 @@ OsdKernelDispatcher::Factory::Factory()
_kernelCreators.resize(kMAX);
#if 0
OsdCpuKernelDispatcher::Register();
OsdCpuKernelDispatcher::Register();
#if OPENSUBDIV_HAS_CUDA
OsdCudaKernelDispatcher::Register();
#endif
#if OPENSUBDIV_HAS_CUDA
OsdCudaKernelDispatcher::Register();
#endif
#if OPENSUBDIV_HAS_GLSL
OsdGlslKernelDispatcher::Register();
#endif
#if OPENSUBDIV_HAS_GLSL
OsdGlslKernelDispatcher::Register();
#endif
#if OPENSUBDIV_HAS_CL
OsdClKernelDispatcher::Register();
#endif
#if OPENSUBDIV_HAS_CL
OsdClKernelDispatcher::Register();
#endif
#endif
}

View File

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

View File

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

View File

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

View File

@ -1,12 +1,13 @@
#include "../version.h"
#include <GL/glew.h>
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#include <OpenGL/gl.h>
#endif
#include "vertexBuffer.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include <iostream>
namespace OpenSubdiv {

View File

@ -1,7 +1,14 @@
#ifndef OSD_VERTEX_BUFFER_H
#define OSD_VERTEX_BUFFER_H
#include <GL/glu.h>
#if not defined(__APPLE__)
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#else
#include <OpenGL/gl.h>
#endif
#include <string.h> // memcpy (tobe moved to cpp)