|
|
@ -28,11 +28,6 @@ |
|
|
|
#define GLFW_INCLUDE_NONE |
|
|
|
#define GLFW_INCLUDE_NONE |
|
|
|
#include <GLFW/glfw3.h> |
|
|
|
#include <GLFW/glfw3.h> |
|
|
|
|
|
|
|
|
|
|
|
#if USE_NATIVE_OSMESA |
|
|
|
|
|
|
|
#define GLFW_EXPOSE_NATIVE_OSMESA |
|
|
|
|
|
|
|
#include <GLFW/glfw3native.h> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "linmath.h" |
|
|
|
#include "linmath.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdlib.h> |
|
|
@ -151,12 +146,8 @@ int main(void) |
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 3); |
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 3); |
|
|
|
glFinish(); |
|
|
|
glFinish(); |
|
|
|
|
|
|
|
|
|
|
|
#if USE_NATIVE_OSMESA |
|
|
|
|
|
|
|
glfwGetOSMesaColorBuffer(window, &width, &height, NULL, (void**) &buffer); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
buffer = calloc(4, width * height); |
|
|
|
buffer = calloc(4, width * height); |
|
|
|
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); |
|
|
|
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Write image Y-flipped because OpenGL
|
|
|
|
// Write image Y-flipped because OpenGL
|
|
|
|
stbi_write_png("offscreen.png", |
|
|
|
stbi_write_png("offscreen.png", |
|
|
@ -164,11 +155,7 @@ int main(void) |
|
|
|
buffer + (width * 4 * (height - 1)), |
|
|
|
buffer + (width * 4 * (height - 1)), |
|
|
|
-width * 4); |
|
|
|
-width * 4); |
|
|
|
|
|
|
|
|
|
|
|
#if USE_NATIVE_OSMESA |
|
|
|
|
|
|
|
// Here is where there's nothing
|
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
free(buffer); |
|
|
|
free(buffer); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glfwDestroyWindow(window); |
|
|
|
glfwDestroyWindow(window); |
|
|
|
|
|
|
|
|
|
|
|