Recent

Author Topic: Stencil and TOpenGLControl  (Read 2606 times)

Mathias

  • Jr. Member
  • **
  • Posts: 93
Stencil and TOpenGLControl
« on: October 19, 2023, 01:31:33 pm »
I want to get Stencil to work with OpenGLControl.
With SDL2 this works as follows.
     
Code: Pascal  [Select][+][-]
  1.   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
  2.   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
  3.   SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
  4.   SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);

Now I wanted to try it with OpenGLControl and did the following.
Code: Pascal  [Select][+][-]
  1.    OpenGLControl1.OpenGLMinorVersion := 3;
  2.    OpenGLControl1.OpenGLMajorVersion := 3;
  3.    OpenGLControl1.StencilBits := 1;
Only then will unfortunately nothing be drawn at all.

If I don't do any of this at all, then Stencil is simply ignored, so it must be related to context creation.

Anyone have an idea how to do it with OpenGLControl?

Lulu

  • Sr. Member
  • ****
  • Posts: 265
Re: Stencil and TOpenGLControl
« Reply #1 on: December 10, 2023, 08:57:43 pm »
Hi Mathias, I just read your post.
I use stencil buffer with OpenGLControl (to clip child surface when drawing them on their parent)
with:
Code: Pascal  [Select][+][-]
  1. OpenGLControl1.StencilBits := 8; // I need 8 bits on stencil
  2. ...
  3. glClear(GL_COLOR_BUFFER_BIT or GL_STENCIL_BUFFER_BIT); // clear the buffer color and stencil
  4. glEnable(GL_STENCIL_TEST);
  5. some drawing...

No problem here (windows10) with OpenGLControl.
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Mathias

  • Jr. Member
  • **
  • Posts: 93
Re: Stencil and TOpenGLControl
« Reply #2 on: March 04, 2024, 07:16:02 pm »
Code: Pascal  [Select][+][-]
  1. OpenGLControl1 . SchabloneBits : = 8
Thanks, that was exactly the problem.

 

TinyPortal © 2005-2018