avc81's picture

temporary non-multisampled glcontrol for color picking

i'm trying to create a temporary non-multisampled glcontrol for the color picking technique. Unfortunately (guess what?) i get errors :-(
this is what i'm doing

 Dim nonmultisampledglcontrol As GL15Control = New GL15Control(0)  '
 nonmultisampledglcontrol.Size = _glcontrol.Size()

where _glcontrol is my main GLControl and this is the GL15Control constructor i'm calling

Friend Sub New(ByVal antialiasing As Byte)
      MyBase.New(New GraphicsMode(New ColorFormat(8, 8, 8, 8), 24, 0, antialiasing), 1, 5, GraphicsContextFlags.Default)
    End Sub

i get a "Object reference not set to an instance of an object" in in OpenTK.GLControl.get_WindowInfo()

i'm sure i'm doing something stupid ;)

any suggestion would be really appreciated!:)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tksuoran's picture

What do you mean by temporary? You probably should keep it around instead of recreating it whenever needed.

Using Framebuffer objects for color picking might be a better idea, you don't need a window at all.

avc81's picture

yes by temporary i mean what u say.
Unfortunately i can't use fbos 'cause i have to stay close to opengl 1.5 specs

the Fiddler's picture

What you are trying to do is not possible:


because you the GLControls have different GraphicsModes. (The GLControls must have the same GraphicsMode or MakeCurrent will fail).

Try using a single context, calling GL.Disable(EnableCap.Multiplesample) before rendering the picking buffer and GL.Enable(EnableCap.Multiplesample) for your regular scene. (Note: this will still fail if the user forces multisampling in his driver options - using GL_EXT_framebuffer_object is the only 100% safe approach).

avc81's picture

i've tried calling


but it doesn't work. the multisampling is still there ruining my color picking alg:(

avc81's picture

at this link
you can find a discussion about gldisable(GL_MULTISAMPLE) not working as expected

avc81's picture

for the sake of completeness here's the solution i've found:

 Dim notmultisampledglcontrol As GL15Control = New GL15Control(0)
 notmultisampledglcontrol.Size = _glcontrol.Size()
'set viewport
'render and picking code