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

feat(webgl): Export legacy BufferWithAccessor #1773

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/webgl/src/adapter/webgl-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import type {
CommandEncoderProps
} from '@luma.gl/api';

import {ClassicBuffer} from '../classic/buffer';
import {BufferWithAccessor} from '../classic/buffer-with-accessor';
import {WEBGLBuffer} from './resources/webgl-buffer';
import {WEBGLShader} from './resources/webgl-shader';
import {WEBGLSampler} from './resources/webgl-sampler';
Expand Down Expand Up @@ -284,7 +284,7 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`

createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {
const newProps = this._getBufferProps(props);
return new ClassicBuffer(this, newProps);
return new BufferWithAccessor(this, newProps);
}

_createTexture(props: TextureProps): WEBGLTexture {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const PROP_CHECKS_SET_PROPS = {
removedProps: DEPRECATED_PROPS
};

function getWEBGLBufferProps(props: ClassicBufferProps | ArrayBufferView | number): BufferProps {
function getWEBGLBufferProps(props: BufferWithAccessorProps | ArrayBufferView | number): BufferProps {
// Signature `new Buffer(gl, new Float32Array(...)`
if (ArrayBuffer.isView(props)) {
return {data: props};
Expand All @@ -62,7 +62,7 @@ function getWEBGLBufferProps(props: ClassicBufferProps | ArrayBufferView | numbe
}

/** WebGL Buffer interface */
export type ClassicBufferProps = BufferProps & {
export type BufferWithAccessorProps = BufferProps & {
handle?: WebGLBuffer;

target?: number;
Expand All @@ -81,11 +81,11 @@ export type ClassicBufferProps = BufferProps & {
}

/** WebGL Buffer interface */
export class ClassicBuffer extends WEBGLBuffer {
export class BufferWithAccessor extends WEBGLBuffer {
usage: number;
accessor: Accessor;

constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);
constructor(device: Device | WebGLRenderingContext, props?: BufferWithAccessorProps);
constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);
constructor(device: Device | WebGLRenderingContext, byteLength: number);

Expand All @@ -96,7 +96,7 @@ export class ClassicBuffer extends WEBGLBuffer {
// this.initialize(props);

// Deprecated: Merge main props and accessor
this.setAccessor(Object.assign({}, props, (props as ClassicBufferProps).accessor));
this.setAccessor(Object.assign({}, props, (props as BufferWithAccessorProps).accessor));

// infer GL type from supplied typed array
if (this.props.data) {
Expand Down Expand Up @@ -126,7 +126,7 @@ export class ClassicBuffer extends WEBGLBuffer {
// Signature: `new Buffer(gl, {data: new Float32Array(...)})`
// Signature: `new Buffer(gl, new Float32Array(...))`
// Signature: `new Buffer(gl, 100)`
initialize(props: ClassicBufferProps = {}): this {
initialize(props: BufferWithAccessorProps = {}): this {
// Signature `new Buffer(gl, new Float32Array(...)`
if (ArrayBuffer.isView(props)) {
props = {data: props};
Expand Down Expand Up @@ -157,7 +157,7 @@ export class ClassicBuffer extends WEBGLBuffer {
return this;
}

setProps(props: ClassicBufferProps): this {
setProps(props: BufferWithAccessorProps): this {
props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);

if ('accessor' in props) {
Expand Down Expand Up @@ -197,7 +197,7 @@ export class ClassicBuffer extends WEBGLBuffer {
}

// Update with new data. Reinitializes the buffer
setData(props: ClassicBufferProps) {
setData(props: BufferWithAccessorProps) {
return this.initialize(props);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/webgl/src/classic/copy-and-blit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {assert, Texture, Framebuffer, FramebufferProps} from '@luma.gl/api';
import {GL} from '@luma.gl/constants';

import {ClassicBuffer as Buffer} from './buffer';
import {BufferWithAccessor as Buffer} from './buffer-with-accessor';
import {WEBGLTexture} from '../adapter/resources/webgl-texture';
import {WEBGLFramebuffer} from '../adapter/resources/webgl-framebuffer';
import {withParameters} from '../context/state-tracker/with-parameters';
Expand Down
4 changes: 2 additions & 2 deletions modules/webgl/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export {WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-objec
// WebGL adapter classes (Legacy, will be moved to webgl-legacy)
export {Accessor} from './classic/accessor';
export type {AccessorObject} from './types';
export type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';
export {ClassicBuffer, ClassicBuffer as Buffer} from './classic/buffer';
export type {BufferWithAccessorProps} from './classic/buffer-with-accessor';
export {BufferWithAccessor} from './classic/buffer-with-accessor';

export {
isWebGL,
Expand Down
Loading