Followers 0

# glScissor - Coordinate confusion

## 2 posts in this topic

Hello everyone

Currently im facing some difficulties getting glScissor to work. Im trying to clip the elements that are outside my treeview (technically its only the last one before its completely "out of range" that can be cut off). Now this is done the following way:

void TreeView::draw() {
glEnable(GL_SCISSOR_TEST);

Vector2 screenPos = getScreenPosition();

glScissor(/* something */);

Vector2 startPos(mPosition.X + 2, mPosition.Y + 2);

for(auto& elem : mRootItems) {
renderItem(startPos, elem);

if(startPos.Y >= mPosition.Y + mSize.Y)
break;
}

glDisable(GL_SCISSOR_TEST);
}


FYI: screenPos is checked and is the correct window coordinate (relative to the top left point of the client area).

Now the something i have tested with various versions:

glScissor((int32)screenPos.X, sWindow->getClientHeight() - (int32)screenPos.Y, (int32)mSize.X, -(int32)mSize.Y);

Thats ok unless the window is resized then the items are all hidden unless i move the frame containing the treeview to the bottom left corner, there it gets visible until as long it stays inside a rectangle with the old size of the window (Imagine like that: You take the old size of the window and move it down to the bottom left corner. As long as the frame is inside this area its correctly displayed).

glScissor((int32)screenPos.X, sWindow->getClientHeight() - (int32)screenPos.Y, (int32)mSize.X, (int32)mSize.Y);

NOTE: difference is the missing - at (int32)mSize.Y

Cant see anything anywhere

glScissor((int32)screenPos.X, (int32)screenPos.Y, (int32)mSize.X, (int32)mSize.Y);

Its drawn correctly if the element is inside a horizontal band around the middle of the window with mSize.Y beeing the height of the band.

I guess i did not find the correct system for the coordinates yet. How do the coordinates of glScissor correspond to what i set at glViewport?

Greetings

Plerion

0

##### Share on other sites

glScissor  cordinate 0,0 is the bottom left hand corner not the top left.

2

##### Share on other sites

Hey BornToCode

Thanks, i was aware of that but i made a little error in reasoning. Anyway, im using the stencil buffer now so it dont need glScissor anymore but maybe another time :)

Greetings

Plerion

0

## Create an account

Register a new account