OpenGL texture glitch / doom era bug
in
Core Library Questions
•
2 years ago
hi,
I have a texture problem, obviously related to the fact that a quad consists of 2 triangles.
I found a lot of postings saying that this sort of behavior ( see
http://processing.org/learning/3d/texture1.html ) only occurs when using P3D -- not with OPENGL.
using OPENGL indeed works for the texture example, but the following code still produces a similar / unexpected behavior:
- import processing.opengl.*;
- PImage img;
- void setup() {
- size(640, 360, OPENGL);
- frameRate(30);
- img = loadImage("data/texture.png");
- /*hint(DISABLE_OPENGL_2X_SMOOTH);
- //hint(ENABLE_OPENGL_4X_SMOOTH);
- hint(ENABLE_DEPTH_TEST);
- hint(ENABLE_DEPTH_SORT);
- hint(ENABLE_ACCURATE_TEXTURES);*/
- noStroke();
- }
- void draw() {
- background(0);
- pushMatrix();
- translate(width/2, height/2);
- beginShape();
- texture(img);
- textureMode(NORMALIZED);
- vertex(0, sin(frameCount/10.0)*20, 0, 0, 0);
- vertex(100, -sin(frameCount/10.0)*20, 0, 1, 0);
- vertex(100, 100, 0, 1, 1);
- vertex(0, 100, 0, 0, 1);
- endShape(CLOSE);
- popMatrix();
- }
is this the way it should look like?
if yes, how would I map a texture onto a trapezoid without that sort of glitch?
thanks a lot in advance!
1