1

I am working on an Android application where I am using a single OpenGL ES instance. In some instances, I am drawing a custom (rectangular) dialog ontop of everything else, with scrolling text, lines, etc. The dialog does not take up the whole screen, and I am drawing content that is larger than the dialog box, which is scrolling across the dialog, like a marquee.

Of course, since I am drawing this dialog last (ontop of every other view), all the vertices I am drawing are going to be visible, but I would like to tell OpenGL to not draw outside of the dialog rectangle for any of its rendering commands. Like this...

Culling to rectangle

Most of my drawing is done with glDrawArrays(...) using FloatBuffer arrays. What I would like is a way to specify to OpenGL that I want any drawing to be invisible outside of a specified region.

I don't know much about culling, but this seems to be very related to what I'm looking for. However, culling seems to only be for skipping the drawing of triangles that wouldn't be "seen" from the camera view in a 3D, whereas I would like to 'skip' the drawing of any triangles outside of an arbitrary rectangle within the viewport.

khiner
  • 673
  • 8
  • 19
  • 1
    The term that you're looking for is "clipping". If the triangles are outside the view frustum, opengl will automatically clip them. I should add that if you need to clip pieces inside your viewport, you'll have to use scissoring. – spatulamania Apr 03 '13 at 01:26
  • Thank you, scissoring is exactly what I needed! – khiner Apr 03 '13 at 07:17

1 Answers1

-1

if you know how to save your textures as a class reference you can use this and when you scroll back and forth or whatever you can change the parameters in it

public class TextureRegion {    
public final float u1, v1;
public final float u2, v2;
public final Texture texture;

public TextureRegion(Texture texture, float x, float y, float width, float height) {
    this.u1 = x / texture.width;
    this.v1 = y / texture.height;
    this.u2 = this.u1 + width / texture.width;
    this.v2 = this.v1 + height / texture.height;        
    this.texture = texture;
}
}
JRowan
  • 6,824
  • 8
  • 40
  • 59