Skip to content

Commit

Permalink
Remove OSMesa specific code from offscreen example
Browse files Browse the repository at this point in the history
The OSMesa specific path is more appropriate for a test than an example.
  • Loading branch information
elmindreda committed May 6, 2022
1 parent 7dfd84c commit 5c3ebfb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
5 changes: 0 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
C_STANDARD 99
FOLDER "GLFW3/Examples")

if (GLFW_USE_OSMESA)
find_package(OSMesa REQUIRED)
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
endif()

if (MSVC)
# Tell MSVC to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
Expand Down
13 changes: 0 additions & 13 deletions examples/offscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>

#if USE_NATIVE_OSMESA
#define GLFW_EXPOSE_NATIVE_OSMESA
#include <GLFW/glfw3native.h>
#endif

#include "linmath.h"

#include <stdlib.h>
Expand Down Expand Up @@ -151,24 +146,16 @@ int main(void)
glDrawArrays(GL_TRIANGLES, 0, 3);
glFinish();

#if USE_NATIVE_OSMESA
glfwGetOSMesaColorBuffer(window, &width, &height, NULL, (void**) &buffer);
#else
buffer = calloc(4, width * height);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
#endif

// Write image Y-flipped because OpenGL
stbi_write_png("offscreen.png",
width, height, 4,
buffer + (width * 4 * (height - 1)),
-width * 4);

#if USE_NATIVE_OSMESA
// Here is where there's nothing
#else
free(buffer);
#endif

glfwDestroyWindow(window);

Expand Down

0 comments on commit 5c3ebfb

Please sign in to comment.