Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# send NumPy array data to CUDA code | |
# ============================================================================= | |
# ============================================================================= | |
# MAIN LESSONS: | |
# 1. python natively provides "buffer protocol" which is interface to C array | |
# 2. numpy supports this, and offers you a ptr to the C array data | |
# 3. use ctypes as native interface to C libraries, send them the ptr | |
# 4. no point using other tools as they all break with updates | |
# 5. for cuda, compile it as an extern C shared object | |
# need to restart python each time .so changes to reimport w ctypes |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on https://gist.github.com/kamino410/09df4ecdf37b03cbd05752a7b2e52d3a | |
// this adds ImGui to an application with CUDA and OpenGL. the thing is, once you use CUDA, ImGui renders very strangely. | |
// after 9 hours of debugging I found that putting glBindBuffer before and after the draw call fixes this! | |
//glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo); // THE MAGIC LINE #1 | |
//glDrawPixels(WIDTH, HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, 0); | |
//glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); // THE MAGIC LINE #2 | |
#include "imgui/imgui.h" // version 1.78 and 1.60 | |
#include "imgui/imgui_impl_glfw.h" |