mirror of
https://github.com/galacean/engine.git
synced 2026-05-31 07:42:01 +08:00
Refactor: add IPlatformShaderProgram type (#2782)
* refactor: add IPlatformShaderProgram type
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { IPlatformShaderProgram } from "./IPlatformShaderProgram";
|
||||
|
||||
export interface IPlatformPrimitive {
|
||||
draw(tech: any, subPrimitive: any): void;
|
||||
draw(shaderProgram: IPlatformShaderProgram, subPrimitive: any): void;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface IPlatformShaderProgram {
|
||||
readonly id: number;
|
||||
readonly attributeLocation: Record<string, GLint>;
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export type { IHardwareRenderer } from "./IHardwareRenderer";
|
||||
export type { IPlatformPrimitive } from "./IPlatformPrimitive";
|
||||
export type { IPlatformShaderProgram } from "./IPlatformShaderProgram";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { GLCapabilityType, Logger, Primitive } from "@galacean/engine-core";
|
||||
import { SubPrimitive } from "@galacean/engine-core/types/graphic/SubPrimitive";
|
||||
import { IPlatformPrimitive } from "@galacean/engine-design";
|
||||
import { IPlatformPrimitive, IPlatformShaderProgram } from "@galacean/engine-design";
|
||||
import { WebGLGraphicDevice } from "./WebGLGraphicDevice";
|
||||
import { WebGLExtension } from "./type";
|
||||
|
||||
@@ -32,7 +32,7 @@ export class GLPrimitive implements IPlatformPrimitive {
|
||||
/**
|
||||
* Draw the primitive.
|
||||
*/
|
||||
draw(shaderProgram: any, subMesh: SubPrimitive): void {
|
||||
draw(shaderProgram: IPlatformShaderProgram, subMesh: SubPrimitive): void {
|
||||
const gl = this._gl;
|
||||
const primitive = this._primitive;
|
||||
const useVao = this._isSupportVAO && primitive.enableVAO;
|
||||
@@ -100,7 +100,7 @@ export class GLPrimitive implements IPlatformPrimitive {
|
||||
/**
|
||||
* Bind buffer and attribute.
|
||||
*/
|
||||
private _bindBufferAndAttrib(shaderProgram: any): void {
|
||||
private _bindBufferAndAttrib(shaderProgram: IPlatformShaderProgram): void {
|
||||
const gl = this._gl;
|
||||
const primitive = this._primitive;
|
||||
const vertexBufferBindings = primitive.vertexBufferBindings;
|
||||
@@ -148,7 +148,7 @@ export class GLPrimitive implements IPlatformPrimitive {
|
||||
}
|
||||
}
|
||||
|
||||
private _registerVAO(shaderProgram: any): void {
|
||||
private _registerVAO(shaderProgram: IPlatformShaderProgram): void {
|
||||
const gl = this._gl;
|
||||
const vao = gl.createVertexArray();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
TextureCubeFace,
|
||||
TextureFormat
|
||||
} from "@galacean/engine-core";
|
||||
import { IHardwareRenderer, IPlatformPrimitive } from "@galacean/engine-design";
|
||||
import { IHardwareRenderer, IPlatformPrimitive, IPlatformShaderProgram } from "@galacean/engine-design";
|
||||
import { Color, Vector4 } from "@galacean/engine-math";
|
||||
import { GLBuffer } from "./GLBuffer";
|
||||
import { GLCapability } from "./GLCapability";
|
||||
@@ -354,7 +354,7 @@ export class WebGLGraphicDevice implements IHardwareRenderer {
|
||||
gl.clear(clearFlag);
|
||||
}
|
||||
|
||||
drawPrimitive(primitive: GLPrimitive, subPrimitive: SubMesh, shaderProgram: any) {
|
||||
drawPrimitive(primitive: GLPrimitive, subPrimitive: SubMesh, shaderProgram: IPlatformShaderProgram) {
|
||||
// todo: VAO not support morph animation
|
||||
if (primitive) {
|
||||
primitive.draw(shaderProgram, subPrimitive);
|
||||
|
||||
Reference in New Issue
Block a user