Skip to content

Add support for double and dvec uniform#210

Open
TristanCacqueray wants to merge 1 commit intoglumpy:masterfrom
TristanCacqueray:master
Open

Add support for double and dvec uniform#210
TristanCacqueray wants to merge 1 commit intoglumpy:masterfrom
TristanCacqueray:master

Conversation

@TristanCacqueray
Copy link
Copy Markdown
Contributor

This change adds GL_DOUBLE (np.float64) support to uniform types.

@rougier
Copy link
Copy Markdown
Member

rougier commented Apr 22, 2019

Thanks and sorry ofr being so late in answering you. Are the GL_DOUBLE type part of GL ES 2.0 ? Else, you light need to surround the declaration with some conditionals.

@TristanCacqueray
Copy link
Copy Markdown
Contributor Author

GL_DOUBLE doesn't seem to be part of GL ES 2.0. It seems to be only available when using this extension: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader_fp64.txt . Thus I'm not sure how the type could be correctly added conditionally. Perhaps the Uniform constructor could have the Program version and the type would only be available if the version is > 400 ?

@rougier
Copy link
Copy Markdown
Member

rougier commented Apr 22, 2019

I'm afraid it might be more complicated than that since we can add them only when we know what version of GL we're using. This means you probably have to hacky gloo on the fly. Do you have a simple case usage ? Maybe we can start with a simple example file to check this can work and then consider a more durable implementation.

This change adds GL_DOUBLE (np.float64) support to uniform types.
@TristanCacqueray
Copy link
Copy Markdown
Contributor Author

I added an example that uses a dvec2 uniform... Couldn't find an easier way to demonstrate double usage :-)

I don't understand why gloo has to be patched on the fly. If Variable and Uniform constructor could know the program version, then why not load gl_double type informations when version > 400?

@rougier
Copy link
Copy Markdown
Member

rougier commented Apr 22, 2019

And actually, GL_DOUBLE is also defined on my system independently of the GL version so maybe we can just merge. What is your example doing exactly (didn't ran it yet)?

@TristanCacqueray
Copy link
Copy Markdown
Contributor Author

The example animates Julia sets of the burning ship fractal. The animation increments the Julia coordinate with a value below the float precision limit, hence the need for double. It may not be the best example to show double uniform, but that's the use-case i needed this change.

@rougier
Copy link
Copy Markdown
Member

rougier commented Apr 22, 2019

Ok, I'll test it and merge.

@rougier
Copy link
Copy Markdown
Member

rougier commented Apr 22, 2019

OSX doesn't allow me to have GL 4.0 :( Do you know when this extension first appeared ?

@TristanCacqueray
Copy link
Copy Markdown
Contributor Author

TristanCacqueray commented Apr 23, 2019

According to https://www.khronos.org/opengl/wiki/History_of_OpenGL , Version 4.0 appeared in 2010.
Though the extension https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader_fp64.txt is compatible with OpenGL 3.2 and GLSL 1.50.

@rougier
Copy link
Copy Markdown
Member

rougier commented Apr 24, 2019

I can't make it run with 3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants