简体   繁体   中英

Unable to compile vertex shader in Maya Plugin

I am writing a plugin on Maya/MacOS which is compiling a vertex shader for OpenGL:

    const char* vscode =
    {
        "#version 150\n"
        ...
    }

However executing the code in Maya gives me

ERROR: 0:1: '' :  version '150' is not supported

The OpenGL version returned is 2.1 ATI-1.42.6. I tried to change the OpenGL via glut

glutInitDisplayMode(GLUT_3_2_CORE_PROFILE);

But it does not seem to change the OpenGL Core Profile. How can I change the core profile from within a Maya plugin, or how can I know which "xxx" version would be supported in the shader ?

The OpenGL version returned is 2.1 ATI-1.42.6. I tried to change the OpenGL via glut

Does Maya use GLUT? No! So how so you expect this to work then?

GLUT is a independent library that does window and OpenGL context creation. GLUT is not part of OpenGL and GLUT can not influence OpenGL context management of programs not using GLUT .

Maya does its OpenGL context management internally and when your plugin is called a OpenGL context is already created and the version profile of that particular context set into stone.

But what you can do is you can create a very own OpenGL context , just for your plugin and connect it with the OpenGL context that Maya created (OpenGL context sharing). Doing this is advisable anyway, since this separates OpenGL your plugin uses from OpenGL state Maya uses.

You will have to use the system level OpenGL context management APIs for that. So no GLUT, no GLFW, no SMFL or other helper libraries. Don't worry, it's not too difficult to do. Regarding connecting with the OpenGL context of Maya, every OpenGL context management API has functions to query the currently active OpenGL context and the drawable it's active on. Use those to store which context+drawable pair was active before your plugin got called, then before returning to Maya reset the OpenGL context activation to that pair.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM