Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] Not clear how to implement scissor command #87

Open
EmmanuelMess opened this issue Dec 22, 2024 · 6 comments
Open

[Documentation] Not clear how to implement scissor command #87

EmmanuelMess opened this issue Dec 22, 2024 · 6 comments

Comments

@EmmanuelMess
Copy link

The CLAY_RENDER_COMMAND_TYPE_SCISSOR_START and CLAY_RENDER_COMMAND_TYPE_SCISSOR_END commands are explained as:

Rendering

Enabling scroll for an element will result in two additional render commands:

  • commandType = CLAY_RENDER_COMMAND_TYPE_SCISSOR_START, which should create a rectangle mask with its boundingBox and is not subject to culling
  • commandType = CLAY_RENDER_COMMAND_TYPE_SCISSOR_END, which disables the previous rectangle mask and is not subject to culling

But I don't understand how to map that to drawing operations. There should be a document that defines what each command means IMO.

@mrneo240
Copy link
Contributor

Think of it as cutting a square out of a piece of paper. You only render things inside the square, not outside.

@EmmanuelMess
Copy link
Author

Think of it as cutting a square out of a piece of paper. You only render things inside the square, not outside.

Are the commands nested? Do I need to keep a stack of masks?

@mrneo240
Copy link
Contributor

I have not seen "nesting" but also my examples are trivial. I'm evaluating the current scissor if it's active.

The raylib provided renderer does not handle a stack based approach and due to how Clay orders the commands i would expect it to be fine.

@nicbarker
Copy link
Owner

Are the commands nested? Do I need to keep a stack of masks?

In the current implementation, yes it is technically possible that these commands will be nested. It's not too common though, so you can probably delay the implementation of it until you see a specific use case.

In future, I will likely build this in as a feature of clay (automatically generate extra scissor start / end commands to "flatten" nested)

@EmmanuelMess
Copy link
Author

EmmanuelMess commented Dec 25, 2024

In the current implementation, yes it is technically possible that these commands will be nested. It's not too common though, so you can probably delay the implementation of it until you see a specific use case.

Apparently I cannot do this under opengl directly, which would mean that extra work would have to be done to be able to actually implement the nesting in opengl renderers.

@mrneo240
Copy link
Contributor

I have multiple opengl and opengl-like renderers and have gone with simple scissoring.

Is there an example layout that produces an incorrect result with doing scissoring this way?

@nicbarker nicbarker changed the title Not clear how to implement scissor command [Documentation] Not clear how to implement scissor command Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants