Is it possible to have the Unity plug-in perform OpenGLES operations?

Asked 1 years ago, Updated 1 years ago, 92 views

I would like to process OpenGLES with the Unity plug-in (dll side) and reflect it to Unity side.

Find out how
https://docs.unity3d.com/ja/540/Manual/NativePluginInterface.html

in such a way that Unity generates the substance of the texture and rewrites the content. Samples and contents were listed.
(There were a lot of articles that verified the above in the search results to see if the method of investigation was bad.)

What I want to implement is

on the dll side
glEnable(GL_TEXTURE_2D);
glGenTextures(1,&m_TexID);
glBindTexture(GL_TEXTURE_2D, m_TexID);

Call to generate textures on the dll side and draw them on the Unity side

on the dll side
glClearColor(r,g,b,a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Use to clear the screen or

glViewport(x,y,w,h);

Is it possible to use to specify a viewport?

実行 The running environment is Unity 5.6.0f3, and
Player Setting to work with OpenGLES Changing the Auto Graphics API.

Also
https://docs.unity3d.com/ja/540/ScriptReference/GL.InvalidateState.html

as described in the .
GL.InvalidateState();

Is it necessary to use ?
(I couldn't even find a GL.InvalidateState use case, so
I couldn't decide whether the reference content is relevant or when to use it.)

I would appreciate it if you could let me know if anyone is familiar with it.

unity3d opengl-es

2022-09-30 11:38

1 Answers

After trial and error, we found that it is possible for Unity to draw the contents created on the dll side.
To actually reflect the above content
Do it in a col routine, etc., and

yield return new WaitForEndOfFrame();

Wait until

GL.IssuePluginEvent (RenderEventFunc(), eventID);

must call dll-side action to handle OpenGL in render events.


If you do not wait until WaitForEndOfFrame() The operation specified on the dll side is not drawn.
(However,
for example, transforming textures and polygons created on the Unity side. It seems to be applied to objects that already exist.)

In addition, GL.InvalidateState(); was not required to be used.
(What is GL.InvalidateState() for...)


2022-09-30 11:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.