What does the console warning "Adding same texture twice" mean?
in
Core Library Questions
•
11 months ago
I am working on a sketch using the OpenGL render mode and I am getting an error "Adding same texture twice" and I'm trying to figure out what that means.
I looked it up in the source code and it is generated by a function called
createTextureObject. Anyone know what the significance of this message is?
-
// Texture Objects ----------------------------------------------------------- protected int createTextureObject(int context) { deleteFinalizedTextureObjects(); int[] temp = new int[1]; pgl.genTextures(1, temp, 0); int id = temp[0]; GLResource res = new GLResource(id, context); if (glTextureObjects.containsKey(res)) { showWarning("Adding same texture twice"); } else { glTextureObjects.put(res, false); } return id; }
Here's the code I'm running that's generating the warning:
- import processing.opengl.*;
- //Declare Globals
- float PHI = 0.618033989;
- int rotationMode = 0;
- // 0 = rotate in 90deg increments
- // 1 = fine increments (cn.val * TWO_PI)
- int xRes, yRes;
- float cellH, cellW;
- PImage src;
- float imgTileW;
- float imgTileH;
- Node[] nodeField;
- void setup() {
- background(255);
- size(1200, 800, OPENGL);
- smooth();
- colorMode(RGB, 255, 255, 255, 255);
- xRes = 30;
- yRes = 20;
- cellH = height/yRes;
- cellW = width/xRes;
- src = loadImage("andrew.jpeg");
- imgTileW = src.width/xRes;
- imgTileH = src.height/yRes;
- nodeField = new Node[xRes * yRes];
- for (int i=0; i < nodeField.length; i++) {
- Node n = new Node();
- n.gridLoc.x = i % xRes;
- n.gridLoc.y = floor(i / xRes);
- n.loc.x = n.gridLoc.x * cellW;
- n.loc.y = n.gridLoc.y * cellH;
- nodeField[i] = n;
- }
- }
- void draw() {
- background(255);
- for (Node n : nodeField) {
- n.val = noise((n.gridLoc.x + frameCount/10) * 0.05, (n.gridLoc.y) * .05);
- }
- for (int i=0; i < nodeField.length; i++) {
- Node cn = nodeField[i];
- fill(0);
- noStroke();
- smooth();
- pushMatrix();
- translate(cn.loc.x + (cellW/2), cn.loc.y + (cellH/2));
- if (rotationMode == 0) {
- if (cn.val < 0.25) {
- rotate(0);
- }
- else if (cn.val > 0.25 && cn.val < 0.5) {
- rotate(PI/2);
- }
- else if (cn.val > 0.5 && cn.val < 0.75) {
- rotate(PI);
- }
- else if (cn.val > 0.75) {
- rotate(PI/2+PI);
- }
- }
- else if (rotationMode == 1) {
- rotate(cn.val * TWO_PI);
- }
- PImage tile = src.get(int(cn.gridLoc.x * imgTileW), int(cn.gridLoc.y * imgTileH), int(imgTileW), int(imgTileH));
- image(tile, -cellW/2, -cellH/2, cellW, cellH);
- popMatrix();
- }
- }
- class Node {
- PVector loc = new PVector();
- float val;
- PVector gridLoc = new PVector();
- }
1