mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-23 04:00:07 +00:00
Add glfw error callback to code examples
This commit is contained in:
parent
88bbdee64f
commit
b59c36d691
@ -977,6 +977,12 @@ uninitGL() {
|
||||
glDeleteVertexArrays(1, &g_samplesVAO);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackErrorGLFW(int error, const char* description) {
|
||||
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile() {
|
||||
@ -1019,9 +1025,9 @@ int main(int argc, char **argv) {
|
||||
|
||||
Far::SetErrorCallback(callbackError);
|
||||
|
||||
|
||||
initShapes();
|
||||
|
||||
glfwSetErrorCallback(callbackErrorGLFW);
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
return 1;
|
||||
|
@ -1213,6 +1213,11 @@ callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackErrorGLFW(int error, const char* description) {
|
||||
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile() {
|
||||
@ -1260,6 +1265,7 @@ int main(int argc, char ** argv) {
|
||||
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
glfwSetErrorCallback(callbackErrorGLFW);
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
return 1;
|
||||
|
@ -1110,6 +1110,11 @@ callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackErrorGLFW(int error, const char* description) {
|
||||
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile() {
|
||||
@ -1154,6 +1159,7 @@ int main(int argc, char ** argv) {
|
||||
initShapes();
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
glfwSetErrorCallback(callbackErrorGLFW);
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
return 1;
|
||||
|
@ -2299,6 +2299,11 @@ callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackErrorGLFW(int error, const char* description) {
|
||||
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile() {
|
||||
@ -2387,6 +2392,7 @@ int main(int argc, char ** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
glfwSetErrorCallback(callbackErrorGLFW);
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
return 1;
|
||||
|
@ -1519,6 +1519,11 @@ callbackError(Far::ErrorType err, const char *message) {
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackErrorGLFW(int error, const char* description) {
|
||||
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile() {
|
||||
@ -1554,6 +1559,7 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
Far::SetErrorCallback(callbackError);
|
||||
|
||||
glfwSetErrorCallback(callbackErrorGLFW);
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
return 1;
|
||||
|
@ -980,6 +980,11 @@ uninitGL() {
|
||||
glDeleteVertexArrays(1, &g_stencilsVAO);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackErrorGLFW(int error, const char* description) {
|
||||
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile() {
|
||||
@ -1024,6 +1029,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
initShapes();
|
||||
|
||||
glfwSetErrorCallback(callbackErrorGLFW);
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
return 1;
|
||||
|
@ -1479,14 +1479,12 @@ keyboard(GLFWwindow *, int key, int /* scancode */, int event, int /* mods */) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
rebuildOsdMesh()
|
||||
{
|
||||
rebuildOsdMesh() {
|
||||
createOsdMesh( g_defaultShapes[ g_currentShape ], g_level, g_kernel, g_defaultShapes[ g_currentShape ].scheme );
|
||||
}
|
||||
|
||||
static void
|
||||
callbackDisplayStyle(int b)
|
||||
{
|
||||
callbackDisplayStyle(int b) {
|
||||
if (g_displayStyle == kVaryingColor or b == kVaryingColor or
|
||||
g_displayStyle == kInterleavedVaryingColor or b == kInterleavedVaryingColor or
|
||||
g_displayStyle == kFaceVaryingColor or b == kFaceVaryingColor) {
|
||||
@ -1499,8 +1497,7 @@ callbackDisplayStyle(int b)
|
||||
}
|
||||
|
||||
static void
|
||||
callbackKernel(int k)
|
||||
{
|
||||
callbackKernel(int k) {
|
||||
g_kernel = k;
|
||||
|
||||
#ifdef OPENSUBDIV_HAS_OPENCL
|
||||
@ -1522,15 +1519,13 @@ callbackKernel(int k)
|
||||
}
|
||||
|
||||
static void
|
||||
callbackLevel(int l)
|
||||
{
|
||||
callbackLevel(int l) {
|
||||
g_level = l;
|
||||
rebuildOsdMesh();
|
||||
}
|
||||
|
||||
static void
|
||||
callbackModel(int m)
|
||||
{
|
||||
callbackModel(int m) {
|
||||
if (m < 0)
|
||||
m = 0;
|
||||
|
||||
@ -1542,8 +1537,7 @@ callbackModel(int m)
|
||||
}
|
||||
|
||||
static void
|
||||
callbackAdaptive(bool checked, int /* a */)
|
||||
{
|
||||
callbackAdaptive(bool checked, int /* a */) {
|
||||
if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) {
|
||||
g_adaptive = checked;
|
||||
rebuildOsdMesh();
|
||||
@ -1551,8 +1545,7 @@ callbackAdaptive(bool checked, int /* a */)
|
||||
}
|
||||
|
||||
static void
|
||||
callbackSingleCreasePatch(bool checked, int /* a */)
|
||||
{
|
||||
callbackSingleCreasePatch(bool checked, int /* a */) {
|
||||
if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) {
|
||||
g_singleCreasePatch = checked;
|
||||
rebuildOsdMesh();
|
||||
@ -1560,8 +1553,7 @@ callbackSingleCreasePatch(bool checked, int /* a */)
|
||||
}
|
||||
|
||||
static void
|
||||
callbackCheckBox(bool checked, int button)
|
||||
{
|
||||
callbackCheckBox(bool checked, int button) {
|
||||
switch (button) {
|
||||
case kHUD_CB_DISPLAY_CAGE_EDGES:
|
||||
g_drawCageEdges = checked;
|
||||
@ -1594,8 +1586,7 @@ callbackCheckBox(bool checked, int button)
|
||||
}
|
||||
|
||||
static void
|
||||
initHUD()
|
||||
{
|
||||
initHUD() {
|
||||
int windowWidth = g_width, windowHeight = g_height;
|
||||
int frameBufferWidth = g_width, frameBufferHeight = g_height;
|
||||
|
||||
@ -1680,8 +1671,7 @@ initHUD()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
initGL()
|
||||
{
|
||||
initGL() {
|
||||
glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
@ -1712,15 +1702,19 @@ idle() {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
callbackErrorOsd(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("Error: %d\n", err);
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile()
|
||||
{
|
||||
callbackErrorGLFW(int error, const char* description) {
|
||||
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
setGLCoreProfile() {
|
||||
#define glfwOpenWindowHint glfwWindowHint
|
||||
#define GLFW_OPENGL_VERSION_MAJOR GLFW_CONTEXT_VERSION_MAJOR
|
||||
#define GLFW_OPENGL_VERSION_MINOR GLFW_CONTEXT_VERSION_MINOR
|
||||
@ -1782,8 +1776,9 @@ int main(int argc, char ** argv) {
|
||||
|
||||
g_fpsTimer.Start();
|
||||
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackErrorOsd);
|
||||
|
||||
glfwSetErrorCallback(callbackErrorGLFW);
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user