Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

WebGL unsigned long issue #14

Closed
n9 opened this issue Feb 28, 2014 · 2 comments
Closed

WebGL unsigned long issue #14

n9 opened this issue Feb 28, 2014 · 2 comments

Comments

@n9
Copy link

n9 commented Feb 28, 2014

Some WebGL code needs casting int/uint casting, for instance:

gl.TexParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_WRAP_S, WebGLRenderingContext.CLAMP_TO_EDGE);

Since WebGLRenderingContext contains method with the last parameter of type int:

// IDL: void texParameteri(GLenum target, GLenum pname, GLint param); 
public void TexParameteri(uint target, uint pname, int param);

and uint constant:

// IDL: const GLenum CLAMP_TO_EDGE                  = 0x812F;
public const uint CLAMP_TO_EDGE = 33071;

The problem is caused because GLenum is defined in IDL as:

typedef unsigned long  GLenum;

There are more cases of casting problem in the spec, e.g. Uniform1i vs. TEXTURE_2D.

One possible workaround is to define alternative methods, such as:

public void TexParameteri(uint target, uint pname, uint param) { }
public void Uniform1i(WebGLUniformLocation location, uint x) { }

However similar problem is with:

GLint getAttribLocation(WebGLProgram? program, DOMString name)

vs.

void enableVertexAttribArray(GLuint index)

from WebGL specification.

I think that the spec considers unsigned long as non-negative integer implicitly convertible to common integer long.

So, the solution from my point of view is to translate IDL's unsigned long to C#'s int.

@erik-kallen
Copy link
Contributor

I made this change in 88f5351

@n9
Copy link
Author

n9 commented Mar 27, 2014

Looks ok, thx.

@n9 n9 closed this as completed Mar 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants