-
Notifications
You must be signed in to change notification settings - Fork 162
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
Add support for WebGL2 #838
Open
tsnee
wants to merge
8
commits into
scala-js:main
Choose a base branch
from
tsnee:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b86b9c3
First draft of WebGL 2 facades.
tsnee 34ba0e9
Replace `js.Any` with multiple overloads.
tsnee 147f5c3
Add previously-unsupported WebGLObject types.
tsnee f7c7c27
Prepare for PR.
tsnee 9017ed8
Fix ScalaDoc errors.
tsnee 1d90025
Fix WebGL 1 vs 2 inconsistency.
tsnee 8aa3a44
Bug fix.
tsnee f339bdf
Update API reports.
tsnee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
9,999 changes: 9,999 additions & 0 deletions
9,999
dom/src/main/scala/org/scalajs/dom/WebGL2RenderingContext.scala
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (C) 2014 Matt Seddon. This source is donated in full to the scala-js-dom project. | ||
* | ||
* Based on https://www.khronos.org/registry/webgl/specs/1.0/ | ||
*/ | ||
|
||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation._ | ||
|
||
/** An opaque type that provides ways to asynchronously query for information. By default, occlusion queries and | ||
* primitive queries are available. | ||
*/ | ||
@js.native | ||
@JSGlobal | ||
class WebGLQuery private[this] () extends js.Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (C) 2014 Matt Seddon. This source is donated in full to the scala-js-dom project. | ||
* | ||
* Based on https://www.khronos.org/registry/webgl/specs/1.0/ | ||
*/ | ||
|
||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation._ | ||
|
||
/** An opaque type that stores sampling parameters for WebGLTexture access inside of a shader. */ | ||
@js.native | ||
@JSGlobal | ||
class WebGLSampler private[this] () extends js.Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (C) 2014 Matt Seddon. This source is donated in full to the scala-js-dom project. | ||
* | ||
* Based on https://www.khronos.org/registry/webgl/specs/1.0/ | ||
*/ | ||
|
||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation._ | ||
|
||
/** An opaque type that is used to synchronize activities between the GPU and the application. */ | ||
@js.native | ||
@JSGlobal | ||
class WebGLSync private[this] () extends js.Object |
18 changes: 18 additions & 0 deletions
18
dom/src/main/scala/org/scalajs/dom/WebGLTransformFeedback.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (C) 2014 Matt Seddon. This source is donated in full to the scala-js-dom project. | ||
* | ||
* Based on https://www.khronos.org/registry/webgl/specs/1.0/ | ||
*/ | ||
|
||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation._ | ||
|
||
/** An opaque type that enables transform feedback, which is the process of capturing primitives generated by vertex | ||
* processing. It allows to preserve the post-transform rendering state of an object and resubmit this data multiple | ||
* times. | ||
*/ | ||
@js.native | ||
@JSGlobal | ||
class WebGLTransformFeedback private[this] () extends js.Object |
15 changes: 15 additions & 0 deletions
15
dom/src/main/scala/org/scalajs/dom/WebGLVertexArrayObject.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (C) 2014 Matt Seddon. This source is donated in full to the scala-js-dom project. | ||
* | ||
* Based on https://www.khronos.org/registry/webgl/specs/1.0/ | ||
*/ | ||
|
||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation._ | ||
|
||
/** An opaque type representing a WebGL Vertex Array Object (VAO). */ | ||
@js.native | ||
@JSGlobal | ||
class WebGLVertexArrayObject private[this] () extends js.Object |
64 changes: 64 additions & 0 deletions
64
dom/src/main/scala/org/scalajs/dom/webgl/extensions/EXTTextureCompressionBPTC.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.scalajs.dom.webgl.extensions | ||
|
||
import scala.scalajs.js | ||
|
||
/** The EXT_texture_compression_bptc extension is part of the WebGL API and exposes 4 BPTC compressed texture formats. | ||
* These compression formats are called BC7 and BC6H in Microsoft's DirectX API. | ||
* | ||
* WebGL extensions are available using the [[org.scalajs.dom.WebGLRenderingContext.getExtension]] and | ||
* [[org.scalajs.dom.WebGL2RenderingContext.getExtension]] methods. | ||
* | ||
* Note: Support depends on the system's graphics driver. There is no support on Windows. | ||
* | ||
* Note: This extension is available to both WebGL1 and WebGL2 contexts. | ||
* | ||
* The compressed texture formats are exposed by four constants and can be used in the | ||
* WebGL2RenderingContext.compressedTexImage2D and WebGL2RenderingContext.compressedTexSubImage2D functions. | ||
* | ||
* @see | ||
* https://www.khronos.org/registry/webgl/extensions/EXT_texture_compression_bptc/ | ||
* @see | ||
* https://docs.microsoft.com/windows/win32/direct3d11/bc7-format | ||
* @see | ||
* https://docs.microsoft.com/windows/win32/direct3d11/bc6h-format | ||
* @example | ||
* {{{ | ||
* val ext = gl.getExtension("EXT_texture_compression_bptc") | ||
* | ||
* val texture = gl.createTexture() | ||
* gl.bindTexture(WebGLRenderingContext.TEXTURE_2D, texture) | ||
* | ||
* gl.compressedTexImage2D( | ||
* WebGLRenderingContext.TEXTURE_2D, | ||
* 0, | ||
* ext.COMPRESSED_RGBA_BPTC_UNORM_EXT, | ||
* 128, | ||
* 128, | ||
* 0, | ||
* textureData | ||
* ) | ||
* }}} | ||
*/ | ||
@js.native | ||
trait EXTTextureCompressionBPTC extends js.Object { | ||
|
||
/** Compresses 8-bit fixed-point data. Each 4x4 block of texels consists of 128 bits of RGBA or image data. See also | ||
* BC7 format. | ||
*/ | ||
val COMPRESSED_RGBA_BPTC_UNORM_EXT: Int = js.native | ||
|
||
/** Compresses 8-bit fixed-point data. Each 4x4 block of texels consists of 128 bits of SRGB_ALPHA or image data. See | ||
* also BC7 format. | ||
*/ | ||
val COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: Int = js.native | ||
|
||
/** Compresses high dynamic range signed floating point values. Each 4x4 block of texels consists of 128 bits of RGB | ||
* data. It only contains RGB data, so the returned alpha value is 1.0. See also BC6H format. | ||
*/ | ||
val COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: Int = js.native | ||
|
||
/** Compresses high dynamic range unsigned floating point values. Each 4x4 block of texels consists of 128 bits of RGB | ||
* data. It only contains RGB data, so the returned alpha value is 1.0. See also BC6H format. | ||
*/ | ||
val COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: Int = js.native | ||
} |
61 changes: 61 additions & 0 deletions
61
dom/src/main/scala/org/scalajs/dom/webgl/extensions/EXTTextureCompressionRGTC.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.scalajs.dom.webgl.extensions | ||
|
||
import scala.scalajs.js | ||
|
||
/** The EXT_texture_compression_rgtc extension is part of the WebGL API and exposes 4 RGTC compressed texture formats. | ||
* RGTC is a block-based texture compression format suited for unsigned and signed red and red-green textures | ||
* (Red-Green Texture Compression). | ||
* | ||
* WebGL extensions are available using the [[org.scalajs.dom.WebGLRenderingContext.getExtension]] and | ||
* [[org.scalajs.dom.WebGL2RenderingContext.getExtension]] methods. | ||
* | ||
* Note: Support depends on the system's graphics driver. There is no support on Windows. | ||
* | ||
* Note: This extension is available to both WebGL1 and WebGL2 contexts. | ||
* | ||
* The compressed texture formats are exposed by four constants and can be used in the | ||
* WebGL2RenderingContext.compressedTexImage2D and WebGL2RenderingContext.compressedTexSubImage2D functions. | ||
* | ||
* @see | ||
* https://www.khronos.org/registry/webgl/extensions/EXT_texture_compression_rgtc/ | ||
* @see | ||
* https://docs.microsoft.com/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression#bc4 | ||
* @see | ||
* https://docs.microsoft.com/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression#bc5 | ||
* @example | ||
* {{{ | ||
* val ext = gl.getExtension("EXT_texture_compression_rgtc") | ||
* | ||
* val texture = gl.createTexture() | ||
* gl.bindTexture(WebGLRenderingContext.TEXTURE_2D, texture) | ||
* | ||
* gl.compressedTexImage2D( | ||
* WebGLRenderingContext.TEXTURE_2D, | ||
* 0, | ||
* ext.COMPRESSED_RED_RGTC1_EXT, | ||
* 128, | ||
* 128, | ||
* 0, | ||
* textureData | ||
* ) | ||
* }}} | ||
*/ | ||
@js.native | ||
trait EXTTextureCompressionRGTC extends js.Object { | ||
|
||
/** Each 4x4 block of texels consists of 64 bits of unsigned red image data. See also BC4 unsigned. */ | ||
val COMPRESSED_RED_RGTC1_EXT: Int = js.native | ||
|
||
/** Each 4x4 block of texels consists of 64 bits of signed red image data. See also BC4 signed. */ | ||
val COMPRESSED_SIGNED_RED_RGTC1_EXT: Int = js.native | ||
|
||
/** Each 4x4 block of texels consists of 64 bits of compressed unsigned red image data followed by 64 bits of | ||
* compressed unsigned green image data. See also BC5 unsigned. | ||
*/ | ||
val COMPRESSED_RED_GREEN_RGTC2_EXT: Int = js.native | ||
|
||
/** Each 4x4 block of texels consists of 64 bits of compressed signed red image data followed by 64 bits of compressed | ||
* signed green image data. See also BC5 signed. | ||
*/ | ||
val COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: Int = js.native | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, who is Matt Seddon? What is the origin and license of this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this file and and several others by copying WebGLBuffer.scala and changing only the class name and comment. I didn't feel good about copying the code without the copyright statement. Did I err?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. It looks like these contributions originated in #14. Thanks for bringing this to my attention.
To be clear, the issue is not the
(C) 2014 Matt Seddon
. The issue is that "donated in full" is not a well-known license. I don't know what that means. For example, does "donated in full" allow you to copy and modify the code like you just did in this PR?@mseddon would you be able to clarify the license that this code is under?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, that is me, it appears to have crept in from a template I had years ago- please remove this and any comment like it, it is unnecessary. All code committed here is property of the scala-js-dom project. You have complete ownership of it, and I relinquish any perceived claims of ownership. I'm happy to merge. Apologies delaying this PR, and thank you @tsnee for contributing this much needed feature!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@armanbilge Confirming via ping since there hasn't been much movement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mseddon Thanks for the ping, I had missed this (although haven't had much time recently for sjs-dom maintenance). I appreciate the clarification! In retrospect, it should have been obvious that
mseddon
is Matt Seddon 😅