Sign in to follow this  
Plerion

glScissor - Coordinate confusion

Recommended Posts

Plerion    381

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

Share this post


Link to post
Share on other sites
Plerion    381

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this