Created
January 9, 2025 02:28
-
-
Save sgithens/03e94462cb2dc5420cae2373ea1269d3 to your computer and use it in GitHub Desktop.
Passing lisp strings in to c functions
This file contains hidden or 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
| (defvar vertexSource "attribute vec4 position; | |
| varying vec3 color; | |
| void main() | |
| { | |
| gl_Position = vec4(position.xyz, 1.0); | |
| color = gl_Position.xyz + vec3(0.5); | |
| }") | |
| (gl:shader-source vertex-shader vertexSource) |
This file contains hidden or 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
| const GLchar* vertexSource = | |
| "attribute vec4 position; \n" | |
| "varying vec3 color; \n" | |
| "void main() \n" | |
| "{ \n" | |
| " gl_Position = vec4(position.xyz, 1.0); \n" | |
| " color = gl_Position.xyz + vec3(0.5); \n" | |
| "} \n"; | |
| // In c/c++ this call would have been: | |
| // glShaderSource(vertexShader, 1, &vertexSource, NULL); | |
| // I'm not sure if the ecl_string already has a pointer inside it somewhere with the string | |
| // allocated, or if that needs to be done still, it doens't seem ready to be coerced, as this | |
| // doesn't work. | |
| // (const char *const *) ecl_foreign_data_pointer_safe(ecl_null_terminated_base_string(source)) | |
| // | |
| cl_object lisp_gl_shader_source(cl_object shader, cl_object source) { | |
| glShaderSource(ecl_fixnum(shader), 1, ??source??, NULL); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment