Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with loading GL functions #1

Closed
DeafMan1983 opened this issue May 17, 2022 · 4 comments
Closed

Problem with loading GL functions #1

DeafMan1983 opened this issue May 17, 2022 · 4 comments

Comments

@DeafMan1983
Copy link

Hello nice job with WASM!

But I tried with simple white triangle and it can't see in my code like this your code with I use white Triangle

		uint vaoID = 0;
		GL.glGenVertexArrays(1,&vaoID);

		uint vboID = 0;
		GL.glGenBuffers(1, &vboID);

		GL.glBindVertexArray(vaoID);
		GL.glBindBuffer(BufferTargetARB.ArrayBuffer, vboID);

		float[] vertices = {
			 0.0f,  0.5f, 0.0f,
		     0.5f, -0.5f, 0.0f,
			-0.5f, -0.5f, 0.0f
		};

		fixed (float* vertices_ptr = &vertices[0])
		{
			GL.glBufferData(BufferTargetARB.ArrayBuffer, vertices.Length * sizeof(float), vertices_ptr, BufferUsageARB.StaticDraw);
		}

		int stride = 3 * sizeof(float);
		GL.glVertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, stride, (void*)0);
		GL.glEnableVertexAttribArray(0);

		GL.glDrawArrays(PrimitiveType.Triangles, 0, 3);	

Add lines asssssssssfter GL.LoadAllFunctions(EGL.GetProcAddress);

Than I type dotnet build -c Release and dotnet run -c Release and I open chrome and it doesn't see triangle :(

image

How do I fix? I thought WASM has not problem with OpenGLES.

@AshleighAdams
Copy link
Owner

Just to check, have you set a shader to render your verts? It would be helpful if you upload the solution in full so I can take a look.

@DeafMan1983
Copy link
Author

Hello @AshleighAdams sorry I am busy for trying to resolve with WASM-Test like you made but It is really hard to find. I thought MyRuntime() should with GL function, correct or wrong?

Check my repository under Github DeafMan1983/Wasm-Test

Thanks!

@AshleighAdams
Copy link
Owner

I took a quick look, and it looks like you're doing the rendering once on load, which is then cleared in Frame() here: https://github.com/DeafMan1983/Wasm-Test/blob/f49e8bd439842ac1c2ad705ca5c55d2a2d0c0cda/Program.cs#L130-L135

Frame is where your rendering code should ideally be run, as it's currently set up to be invoked from requestAnimationFrame(). Just as a quick test, I commented out the clear invocation, and it resulted in the following:

image

@DeafMan1983
Copy link
Author

Thank you for explanation! I have tried triangle with shader = ok
But without shader than it can't show white triangle if you work without shader. so sad. I know OpenGL 3.3 uses without shader means it shows only white shapes...

Thank you for helping me! Now I got triangle on wasm :)
image

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

No branches or pull requests

2 participants