mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Merge pull request #3 from codeanticode/p4-new_pshape_api-stream_copy
P4 new pshape api stream copy
This commit is contained in:
@@ -623,19 +623,19 @@ public class PShape implements PConstants {
|
||||
|
||||
|
||||
/**
|
||||
* The <b>beginContour()</b> and <b>endContour()</b> methods make it
|
||||
* possible to define shapes with other shapes cut out of them. For
|
||||
* example, the inside of a letter 'O'. These two functions are always
|
||||
* used together, you'll never use one without the other. Between them,
|
||||
* define the geometry you want to create. As you'll see when you run
|
||||
* the example above, the second smaller shape is cut out of the first
|
||||
* The <b>beginContour()</b> and <b>endContour()</b> methods make it
|
||||
* possible to define shapes with other shapes cut out of them. For
|
||||
* example, the inside of a letter 'O'. These two functions are always
|
||||
* used together, you'll never use one without the other. Between them,
|
||||
* define the geometry you want to create. As you'll see when you run
|
||||
* the example above, the second smaller shape is cut out of the first
|
||||
* larger shape.<br />
|
||||
* <br />
|
||||
* The exterior shape and the interior contour must <em>wind</em> in
|
||||
* opposite directions. This means that if the points of the geometry
|
||||
* for the exterior shape are described in a clockwise order, the points
|
||||
* on the interior shape are defined in a counterclockwise order.
|
||||
*
|
||||
* The exterior shape and the interior contour must <em>wind</em> in
|
||||
* opposite directions. This means that if the points of the geometry
|
||||
* for the exterior shape are described in a clockwise order, the points
|
||||
* on the interior shape are defined in a counterclockwise order.
|
||||
*
|
||||
* @webref shape:vertex
|
||||
* @webBrief Starts a new contour
|
||||
* @see PShape#endContour()
|
||||
@@ -671,18 +671,18 @@ public class PShape implements PConstants {
|
||||
|
||||
|
||||
/**
|
||||
* The <b>beginContour()</b> and <b>endContour()</b> methods make
|
||||
* it possible to define shapes with other shapes cut out of them.
|
||||
* For example, the inside of a letter 'O'. These two functions are
|
||||
* always used together, you'll never use one without the other.
|
||||
* Between them, define the geometry you want to create. As you'll
|
||||
* see when you run the example above, the second smaller shape is
|
||||
* The <b>beginContour()</b> and <b>endContour()</b> methods make
|
||||
* it possible to define shapes with other shapes cut out of them.
|
||||
* For example, the inside of a letter 'O'. These two functions are
|
||||
* always used together, you'll never use one without the other.
|
||||
* Between them, define the geometry you want to create. As you'll
|
||||
* see when you run the example above, the second smaller shape is
|
||||
* cut out of the first larger shape.<br />
|
||||
* <br />
|
||||
* The exterior shape and the interior contour must <em>wind</em>
|
||||
* in opposite directions. This means that if the points of the
|
||||
* geometry for the exterior shape are described in a clockwise order,
|
||||
* the points on the interior shape are defined in a counterclockwise order.
|
||||
* The exterior shape and the interior contour must <em>wind</em>
|
||||
* in opposite directions. This means that if the points of the
|
||||
* geometry for the exterior shape are described in a clockwise order,
|
||||
* the points on the interior shape are defined in a counterclockwise order.
|
||||
*
|
||||
* @webref shape:vertex
|
||||
* @webBrief Ends a contour
|
||||
@@ -756,6 +756,7 @@ public class PShape implements PConstants {
|
||||
public void attribPosition(String name, float x, float y, float z) {
|
||||
}
|
||||
|
||||
|
||||
public void attribNormal(String name, float nx, float ny, float nz) {
|
||||
}
|
||||
|
||||
@@ -777,9 +778,9 @@ public class PShape implements PConstants {
|
||||
|
||||
|
||||
/**
|
||||
* This method is used to start a custom shape created with the <b>createShape()</b>
|
||||
* function. It's always and only used with <b>createShape()</b>.
|
||||
*
|
||||
* This method is used to start a custom shape created with the <b>createShape()</b>
|
||||
* function. It's always and only used with <b>createShape()</b>.
|
||||
*
|
||||
* @webref pshape:method
|
||||
* @webBrief Starts the creation of a new <b>PShape</b>
|
||||
* @see PApplet#endShape()
|
||||
@@ -795,8 +796,8 @@ public class PShape implements PConstants {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to complete a custom shape created with the <b>createShape()</b>
|
||||
* function. It's always and only used with <b>createShape()</b>.
|
||||
* This method is used to complete a custom shape created with the <b>createShape()</b>
|
||||
* function. It's always and only used with <b>createShape()</b>.
|
||||
*
|
||||
* @webref pshape:method
|
||||
* @webBrief Finishes the creation of a new <b>PShape</b>
|
||||
@@ -2026,7 +2027,7 @@ public class PShape implements PConstants {
|
||||
|
||||
/**
|
||||
* Returns the number of children within the <b>PShape</b>.
|
||||
*
|
||||
*
|
||||
* @webref
|
||||
* @webBrief Returns the number of children
|
||||
*/
|
||||
@@ -2101,9 +2102,9 @@ public class PShape implements PConstants {
|
||||
|
||||
// can't be just 'add' because that suggests additive geometry
|
||||
/**
|
||||
* Adds a child PShape to a parent PShape that is defined as a GROUP.
|
||||
* In the example, the three shapes <b>path</b>, <b>rectangle</b>,
|
||||
* and <b>circle</b> are added to a parent PShape variable named
|
||||
* Adds a child PShape to a parent PShape that is defined as a GROUP.
|
||||
* In the example, the three shapes <b>path</b>, <b>rectangle</b>,
|
||||
* and <b>circle</b> are added to a parent PShape variable named
|
||||
* <b>house</b> that is a GROUP.
|
||||
* @webref pshape:method
|
||||
* @webBrief Adds a new child
|
||||
@@ -2201,11 +2202,28 @@ public class PShape implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a PShape holding the tessellated geometry of this shape,
|
||||
* composed entirely of triangles.
|
||||
*/
|
||||
public PShape getTessellation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void beginTessellation() {
|
||||
beginTessellation(TRIANGLES);
|
||||
}
|
||||
|
||||
|
||||
public void beginTessellation(int kind) {
|
||||
}
|
||||
|
||||
|
||||
public void endTessellation() {
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
@@ -2275,11 +2293,11 @@ public class PShape implements PConstants {
|
||||
}
|
||||
|
||||
/**
|
||||
* The <b>getVertexCount()</b> method returns the number of vertices that
|
||||
* make up a <b>PShape</b>. In the above example, the value 4 is returned by the
|
||||
* <b>getVertexCount()</b> method because 4 vertices are defined in
|
||||
* The <b>getVertexCount()</b> method returns the number of vertices that
|
||||
* make up a <b>PShape</b>. In the above example, the value 4 is returned by the
|
||||
* <b>getVertexCount()</b> method because 4 vertices are defined in
|
||||
* <b>setup()</b>.
|
||||
*
|
||||
*
|
||||
* @webref pshape:method
|
||||
* @webBrief Returns the total number of vertices as an int
|
||||
* @see PShape#getVertex(int)
|
||||
@@ -2294,12 +2312,12 @@ public class PShape implements PConstants {
|
||||
|
||||
|
||||
/**
|
||||
* The <b>getVertex()</b> method returns a <b>PVector</b> with the coordinates of
|
||||
* the vertex point located at the position defined by the <b>index</b>
|
||||
* parameter. This method works when shapes are created as shown in the
|
||||
* example above, but won't work properly when a shape is defined explicitly
|
||||
* The <b>getVertex()</b> method returns a <b>PVector</b> with the coordinates of
|
||||
* the vertex point located at the position defined by the <b>index</b>
|
||||
* parameter. This method works when shapes are created as shown in the
|
||||
* example above, but won't work properly when a shape is defined explicitly
|
||||
* (e.g. <b>createShape(RECT, 20, 20, 80, 80)</b>.
|
||||
*
|
||||
*
|
||||
* @webref pshape:method
|
||||
* @webBrief Returns the vertex at the index position
|
||||
* @param index the location of the vertex
|
||||
@@ -2315,9 +2333,7 @@ public class PShape implements PConstants {
|
||||
* @param vec PVector to assign the data to
|
||||
*/
|
||||
public PVector getVertex(int index, PVector vec) {
|
||||
if (vec == null) {
|
||||
vec = new PVector();
|
||||
}
|
||||
if (vec == null) vec = new PVector();
|
||||
float[] vert = vertices[index];
|
||||
vec.x = vert[X];
|
||||
vec.y = vert[Y];
|
||||
@@ -2346,11 +2362,11 @@ public class PShape implements PConstants {
|
||||
|
||||
|
||||
/**
|
||||
* The <b>setVertex()</b> method defines the coordinates of the vertex point
|
||||
* located at the position defined by the <b>index</b> parameter. This method
|
||||
* works when shapes are created as shown in the example above, but won't work
|
||||
* The <b>setVertex()</b> method defines the coordinates of the vertex point
|
||||
* located at the position defined by the <b>index</b> parameter. This method
|
||||
* works when shapes are created as shown in the example above, but won't work
|
||||
* properly when a shape is defined explicitly (e.g. <b>createShape(RECT, 20, 20, 80, 80)</b>.
|
||||
*
|
||||
*
|
||||
* @webref pshape:method
|
||||
* @webBrief Sets the vertex at the index position
|
||||
* @param index the location of the vertex
|
||||
@@ -2411,9 +2427,7 @@ public class PShape implements PConstants {
|
||||
|
||||
|
||||
public PVector getNormal(int index, PVector vec) {
|
||||
if (vec == null) {
|
||||
vec = new PVector();
|
||||
}
|
||||
if (vec == null) vec = new PVector();
|
||||
vec.x = vertices[index][PGraphics.NX];
|
||||
vec.y = vertices[index][PGraphics.NY];
|
||||
vec.z = vertices[index][PGraphics.NZ];
|
||||
@@ -2448,19 +2462,6 @@ public class PShape implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setAttrib(String name, int index, float... values) {
|
||||
}
|
||||
|
||||
|
||||
public void setAttrib(String name, int index, int... values) {
|
||||
}
|
||||
|
||||
|
||||
public void setAttrib(String name, int index, boolean... values) {
|
||||
}
|
||||
|
||||
|
||||
public float getTextureU(int index) {
|
||||
return vertices[index][PGraphics.U];
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -104,7 +104,7 @@ class FontTexture implements PConstants {
|
||||
offsetY = 0;
|
||||
lineHeight = 0;
|
||||
|
||||
texinfoMap = new HashMap<PFont.Glyph, TextureInfo>();
|
||||
texinfoMap = new HashMap<>();
|
||||
glyphTexinfos = new TextureInfo[font.getGlyphCount()];
|
||||
addAllGlyphsToTexture(pg, font);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -77,6 +77,16 @@ public abstract class PGL {
|
||||
protected static boolean USE_DIRECT_BUFFERS = true;
|
||||
protected static int MIN_DIRECT_BUFFER_SIZE = 1;
|
||||
|
||||
/** Controls the use of buffer object streaming. In combination with use direct buffers,
|
||||
* the only advantage of enabling it in immediate mode would be to reduce memory footprint
|
||||
* since the direct vertex buffers would not be allocated, simply mapped from the OpenGL
|
||||
* objects and thus only the vertex arrays would be created.
|
||||
* In the case of the retained mode (PShape), memory footprint would be reduced (for the same
|
||||
* reason) but it may enable some speed ups when editing a geometry in within a being/end
|
||||
* tessellation update block. */
|
||||
static public boolean USE_BUFFER_OBJECT_STREAMING_IN_IMMEDIATE_MODE = false;
|
||||
static public boolean USE_BUFFER_OBJECT_STREAMING_IN_RETAINED_MODE = true;
|
||||
|
||||
/** Enables/disables mipmap use. */
|
||||
protected static boolean MIPMAPS_ENABLED = true;
|
||||
|
||||
@@ -129,6 +139,15 @@ public abstract class PGL {
|
||||
|
||||
// ........................................................
|
||||
|
||||
// These variables are left public so advanced users can experiment with different
|
||||
// usage modes controlling the buffer data store:
|
||||
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml
|
||||
|
||||
static public int glUsageRetained;
|
||||
static public int glUsageImmediate;
|
||||
|
||||
// ........................................................
|
||||
|
||||
// Variables to handle single-buffered situations (i.e.: Android)
|
||||
|
||||
protected IntBuffer firstFrame;
|
||||
@@ -2355,7 +2374,7 @@ public abstract class PGL {
|
||||
|
||||
protected static ByteBuffer updateByteBuffer(ByteBuffer buf, byte[] arr,
|
||||
boolean wrap) {
|
||||
if (USE_DIRECT_BUFFERS) {
|
||||
if (USE_DIRECT_BUFFERS || (buf != null && buf.isDirect())) {
|
||||
if (buf == null || buf.capacity() < arr.length) {
|
||||
buf = allocateDirectByteBuffer(arr.length);
|
||||
}
|
||||
@@ -2380,7 +2399,7 @@ public abstract class PGL {
|
||||
|
||||
protected static void updateByteBuffer(ByteBuffer buf, byte[] arr,
|
||||
int offset, int size) {
|
||||
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
|
||||
if (buf.isDirect() || (buf.hasArray() && buf.array() != arr)) {
|
||||
buf.position(offset);
|
||||
buf.put(arr, offset, size);
|
||||
buf.rewind();
|
||||
@@ -2447,7 +2466,7 @@ public abstract class PGL {
|
||||
|
||||
protected static ShortBuffer updateShortBuffer(ShortBuffer buf, short[] arr,
|
||||
boolean wrap) {
|
||||
if (USE_DIRECT_BUFFERS) {
|
||||
if (USE_DIRECT_BUFFERS || (buf != null && buf.isDirect())) {
|
||||
if (buf == null || buf.capacity() < arr.length) {
|
||||
buf = allocateDirectShortBuffer(arr.length);
|
||||
}
|
||||
@@ -2472,7 +2491,7 @@ public abstract class PGL {
|
||||
|
||||
protected static void updateShortBuffer(ShortBuffer buf, short[] arr,
|
||||
int offset, int size) {
|
||||
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
|
||||
if (buf.isDirect() || (buf.hasArray() && buf.array() != arr)) {
|
||||
buf.position(offset);
|
||||
buf.put(arr, offset, size);
|
||||
buf.rewind();
|
||||
@@ -2539,7 +2558,7 @@ public abstract class PGL {
|
||||
|
||||
protected static IntBuffer updateIntBuffer(IntBuffer buf, int[] arr,
|
||||
boolean wrap) {
|
||||
if (USE_DIRECT_BUFFERS) {
|
||||
if (USE_DIRECT_BUFFERS || (buf != null && buf.isDirect())) {
|
||||
if (buf == null || buf.capacity() < arr.length) {
|
||||
buf = allocateDirectIntBuffer(arr.length);
|
||||
}
|
||||
@@ -2564,7 +2583,7 @@ public abstract class PGL {
|
||||
|
||||
protected static void updateIntBuffer(IntBuffer buf, int[] arr,
|
||||
int offset, int size) {
|
||||
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
|
||||
if (buf.isDirect() || (buf.hasArray() && buf.array() != arr)) {
|
||||
buf.position(offset);
|
||||
buf.put(arr, offset, size);
|
||||
buf.rewind();
|
||||
@@ -2630,7 +2649,7 @@ public abstract class PGL {
|
||||
|
||||
protected static FloatBuffer updateFloatBuffer(FloatBuffer buf, float[] arr,
|
||||
boolean wrap) {
|
||||
if (USE_DIRECT_BUFFERS) {
|
||||
if (USE_DIRECT_BUFFERS || (buf != null && buf.isDirect())) {
|
||||
if (buf == null || buf.capacity() < arr.length) {
|
||||
buf = allocateDirectFloatBuffer(arr.length);
|
||||
}
|
||||
@@ -2655,7 +2674,7 @@ public abstract class PGL {
|
||||
|
||||
protected static void updateFloatBuffer(FloatBuffer buf, float[] arr,
|
||||
int offset, int size) {
|
||||
if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
|
||||
if (buf.isDirect() || (buf.hasArray() && buf.array() != arr)) {
|
||||
buf.position(offset);
|
||||
buf.put(arr, offset, size);
|
||||
buf.rewind();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -386,7 +386,7 @@ public class PShader implements PConstants {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the uniform variables inside the shader to modify the effect while the
|
||||
* Sets the uniform variables inside the shader to modify the effect while the
|
||||
* program is running.
|
||||
*
|
||||
* @webref rendering:shaders
|
||||
@@ -743,7 +743,7 @@ public class PShader implements PConstants {
|
||||
|
||||
protected void setUniformImpl(String name, int type, Object value) {
|
||||
if (uniformValues == null) {
|
||||
uniformValues = new HashMap<String, UniformValue>();
|
||||
uniformValues = new HashMap<>();
|
||||
}
|
||||
uniformValues.put(name, new UniformValue(type, value));
|
||||
}
|
||||
@@ -833,10 +833,10 @@ public class PShader implements PConstants {
|
||||
PImage img = (PImage)val.value;
|
||||
Texture tex = currentPG.getTexture(img);
|
||||
|
||||
if (textures == null) textures = new HashMap<Integer, Texture>();
|
||||
if (textures == null) textures = new HashMap<>();
|
||||
textures.put(loc, tex);
|
||||
|
||||
if (texUnits == null) texUnits = new HashMap<Integer, Integer>();
|
||||
if (texUnits == null) texUnits = new HashMap<>();
|
||||
if (texUnits.containsKey(loc)) {
|
||||
unit = texUnits.get(loc);
|
||||
pgl.uniform1i(loc, unit);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-20 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -815,7 +815,7 @@ public class Texture implements PConstants {
|
||||
public void copyBufferFromSource(Object natRef, ByteBuffer byteBuf,
|
||||
int w, int h) {
|
||||
if (bufferCache == null) {
|
||||
bufferCache = new LinkedList<BufferData>();
|
||||
bufferCache = new LinkedList<>();
|
||||
}
|
||||
|
||||
if (bufferCache.size() + 1 <= MAX_BUFFER_CACHE_SIZE) {
|
||||
@@ -872,7 +872,7 @@ public class Texture implements PConstants {
|
||||
// renderer draws the texture, and hence put the pixels put of sync, we
|
||||
// simply empty the cache.
|
||||
if (usedBuffers == null) {
|
||||
usedBuffers = new LinkedList<BufferData>();
|
||||
usedBuffers = new LinkedList<>();
|
||||
}
|
||||
while (0 < bufferCache.size()) {
|
||||
data = bufferCache.remove(0);
|
||||
@@ -911,7 +911,7 @@ public class Texture implements PConstants {
|
||||
// Putting the buffer in the used buffers list to dispose at the end of
|
||||
// draw.
|
||||
if (usedBuffers == null) {
|
||||
usedBuffers = new LinkedList<BufferData>();
|
||||
usedBuffers = new LinkedList<>();
|
||||
}
|
||||
usedBuffers.add(data);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -38,14 +38,14 @@ public class VertexBuffer {
|
||||
boolean index;
|
||||
|
||||
protected PGL pgl; // The interface between Processing and OpenGL.
|
||||
protected int context; // The context that created this texture.
|
||||
protected int context; // The context that created this resource.
|
||||
private GLResourceVertexBuffer glres;
|
||||
|
||||
VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize) {
|
||||
this(pg, target, ncoords, esize, false);
|
||||
VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize, int usage) {
|
||||
this(pg, target, ncoords, esize, usage, false);
|
||||
}
|
||||
|
||||
VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize, boolean index) {
|
||||
VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize, int usage, boolean index) {
|
||||
pgl = pg.pgl;
|
||||
context = pgl.createEmptyContext();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class VertexBuffer {
|
||||
this.elementSize = esize;
|
||||
this.index = index;
|
||||
create();
|
||||
init();
|
||||
init(usage);
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
@@ -62,11 +62,11 @@ public class VertexBuffer {
|
||||
glres = new GLResourceVertexBuffer(this);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
protected void init(int usage) {
|
||||
int size = index ? ncoords * INIT_INDEX_BUFFER_SIZE * elementSize :
|
||||
ncoords * INIT_VERTEX_BUFFER_SIZE * elementSize;
|
||||
pgl.bindBuffer(target, glId);
|
||||
pgl.bufferData(target, size, null, PGL.STATIC_DRAW);
|
||||
pgl.bufferData(target, size, null, usage);
|
||||
}
|
||||
|
||||
protected void dispose() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -31,4 +31,4 @@ void main() {
|
||||
gl_Position = transformMatrix * position;
|
||||
|
||||
vertColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -30,4 +30,4 @@ varying vec4 backVertColor;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = gl_FrontFacing ? vertColor : backVertColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -151,4 +151,4 @@ void main() {
|
||||
vec4(totalBackDiffuse, 1) * color +
|
||||
vec4(totalBackSpecular, 0) * specular +
|
||||
vec4(emissive.rgb, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -151,4 +151,4 @@ void main() {
|
||||
vec4(totalBackDiffuse, 1) * color +
|
||||
vec4(totalBackSpecular, 0) * specular +
|
||||
vec4(emissive.rgb, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -148,4 +148,4 @@ void main() {
|
||||
vec4(totalBackDiffuse, 1) * color +
|
||||
vec4(totalBackSpecular, 0) * specular +
|
||||
vec4(emissive.rgb, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -29,4 +29,4 @@ varying vec4 vertColor;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vertColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -37,4 +37,4 @@ void main() {
|
||||
vec3 maskColor = texture2D(mask, vertTexCoord.st).rgb;
|
||||
float luminance = dot(maskColor, vec3(0.2126, 0.7152, 0.0722));
|
||||
gl_FragColor = vec4(texColor, luminance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -29,4 +29,4 @@ varying vec4 vertColor;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vertColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -34,4 +34,4 @@ varying vec4 vertTexCoord;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(texture, vertTexCoord.st) * vertColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -34,4 +34,4 @@ varying vec4 vertTexCoord;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(texture, vertTexCoord.st) * (gl_FrontFacing ? vertColor : backVertColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-15 The Processing Foundation
|
||||
Copyright (c) 2012-21 The Processing Foundation
|
||||
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
@@ -35,4 +35,4 @@ void main() {
|
||||
|
||||
vertColor = color;
|
||||
vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user