Hello Guest

| Operator?

  • 2 Replies
  • 5649 Views
| Operator?
« on: February 23, 2005, 22:05:24 »
Code: [Select]

GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);          // Clear The Screen And The Depth Buffer


I understand that GL11.glClear first passes GL11.GL_COLOR and when that was successful GL11.GL_DEPTH_BUFFER_BIT?

But that seems to be wrong because my experiment
Code: [Select]

private static void test(String testtext)
{
  System.out.println(testtext);
}

public static void main(String args[])
{
  ...
  test("test 1" | "test 2");
  ...
}

didn't work.

*

Offline princec

  • *****
  • 1933
    • Puppygames
| Operator?
« Reply #1 on: February 23, 2005, 23:13:33 »
No! That is a binary OR operatator; those two GL constants just refer to different bits in an int. GL checks each bit and clears the appropriate buffers.

Cas :)

| Operator?
« Reply #2 on: February 24, 2005, 11:01:42 »
if you assume that GL_COLOR_BUFFER_BIT is equal to 2 and GL_DEPTH_BUFFER_BIT equal to 8:

than the int in binary of GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT is ...01010

where the left 1 stands for the 8 and the right one for 2. when you now go there with

(merged_int & GL_COLOR_BUFFER_BIT > 0)  it will return true. so opengl knows that you want to clear the GL_COLOR_BUFFER.