Skip to main content
added 12 characters in body
Source Link
ashes999
  • 11.3k
  • 9
  • 61
  • 95

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    stack.Pop();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Example when I scissor with half the needed height:

i.stack.imgur.com/mibOp.png

(In the last case I cannot understand why it shows the bottom half instead of the top half.)

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it.

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    stack.Pop();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Example when I scissor with half the needed height:

i.stack.imgur.com/mibOp.png

(In the last case I cannot understand why it shows the bottom half instead of the top half.)

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it.

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    stack.Pop();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Example when I scissor with half the needed height:

(In the last case I cannot understand why it shows the bottom half instead of the top half.)

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it.

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

Bumped by Community user
Bumped by Community user
Bumped by Community user
added another image.
Source Link

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    stack.Pop();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Example when I scissor with half the needed height:

i.stack.imgur.com/mibOp.png

(In the last case I cannot understand why it shows the bottom half instead of the top half.)

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it.

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    stack.Pop();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it.

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    stack.Pop();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Example when I scissor with half the needed height:

i.stack.imgur.com/mibOp.png

(In the last case I cannot understand why it shows the bottom half instead of the top half.)

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it.

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

added 142 characters in body
Source Link

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    var rect = stack.Peek();
    stack.Pop ();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it. PS

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    var rect = stack.Peek();
    stack.Pop ();
    if (stack.Count == 0) GL.Disable(EnableCap.ScissorTest);
    else applyScissor(rect);
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it. PS. The issue is not only on OS X so it's not the platform.

I am currently developing a GUI app using OpenGL with OpenTK as interface in C#.

The viewport is set to the entire window space (0,0,width,height) and an ortho transformation is applied like this:

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, width, height, 0, 0f, 1f);

With this I can draw objects just like I would do in GDI+ using X,Y coords.

The issue appears when I want to clip elements within their parent's area. I am doing it using glScissor. I am using a stack to keep trace of the scissored areas like so: static Stack stack = new Stack();

internal static void Scissor(Rectangle rect)
{
    applyScissor(rect);
    if (stack.Count == 0) GL.Enable(EnableCap.ScissorTest);
    stack.Push(rect);
}

internal static void RemoveScissor()
{
    if (stack.Count == 0) throw new Exception("Unblanaced stack.");
    stack.Pop();
    if (stack.Count == 0)
    {
        GL.Disable(EnableCap.ScissorTest);
    }
    else
    {
        var rect = stack.Peek();
        applyScissor(rect);
    }
}

static void applyScissor(Rectangle rect)
{
    GL.Scissor(rect.X, rect.Y, rect.Width, rect.Height);
}

It works fine whenever the height is "big" enough but if the values for the height given to the scissor are "small" it doesn't work.

Example without scissors:

enter image description here

Example with scissor

enter image description here

Basically there is an element (the blue box and the text) within the red box with a blue border that should be clipped within and there should be only a small portion of the A visible but at the very least the blue rectangle should be visible. However it is not. :/ The scissor test does work fine however if the height is "big" enough as I mentioned, being able to move the red box with blue borders outside the area of its parent and it wouldn't be visible.

I need to know why that is and how to fix it.

PS. The issue is not only on OS X so it's not the platform.

PS2. I did check the values given to the scissor and they are correct. The area of the red box with blue border is 175,20 with size 36x36.

Source Link
Loading