nythrix's picture

0.3.13 - changes

Hi!
Thanks for the work you all guys have put into this release.
I couldn't help notice that Enums renaming wasn't the only big change.

In VC# designer GLControl is not acting as before (no background clearing). And it's not doing anything even when my app is running. It just stays grey. Maybe something in my code I need to rewrite?

No IGLControl?

Is there a nicer solution for GL.TexParameter(...)? I keep casting the last parameter i.e.: (int)(TextureMinFilter.Linear). Is it possible to have the last param with a solid type? Like TextureParameterValue or similar?

I hope to write some more when I get back from school.


Comments

Comment viewing options

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

In VC# designer GLControl is not acting as before (no background clearing). And it's not doing anything even when my app is running. It just stays grey. Maybe something in my code I need to rewrite?
I think this has been reported before, but I haven´t been able to reproduce the issue. Sounds like a genuine bug, can you post some code (or even better email a solution) that demonstrates the problem?

No IGLControl?
Err, shouldn´t have made that interface public in the first place... There used to be three consumers for this interface before (GLControl, WinGLControl, X11GLControl), but now that the last two don´t exist there wasn´t any reason to keep it around. How were you using it?

Is there a nicer solution for GL.TexParameter(...)? I keep casting the last parameter i.e.: (int)(TextureMinFilter.Linear). Is it possible to have the last param with a solid type? Like TextureParameterValue or similar?
We were having a related discussion at the opengl.org discussion boards (unfortunately they seem down right now). The only solution is the one you propose (add a new enum and provide an overload that takes just this enum), which we can do for the next release. I thought of adding it in 0.3.13, but didn´t want to delay the release any more.

I hope to write some more when I get back from school.
Please do, it´s the only way to improve the interface and fix bugs.

nythrix's picture

Edit: I just wrote a post and then found out it wasn't relevant. It was working in the end. So for now just what's below.

IGLControl is not THAT important for me. I used it as a param type for the ctor of my engine. It made some of the method signatures shorter omitting parameters but it wasn't vital. Is the new GLControl portable then?

the Fiddler.'s picture

Yes, GLControl does not contain any platform-specific code. The implementation is cleaner and less error-prone now (should behave identically on all platforms).

Edit: When you say it was working, what was the problem after all? I'm sure someone else might encounter the same behavior (grey or no rendering), so it would be good to know what to do in that case.

nythrix's picture

I still have the code which doesn't render. I can't reproduce the problem by writing a short example so I'll try to cut it out of the old code. Problem is I can't make it today. I hope to have a look at it before weekend.
Real life and hobbyist programming just don't talk to each other...

the Fiddler.'s picture

Real life and hobbyist programming just don't talk to each other...
So true...

Take your time, we are not in a rush. If this is such a widespread problem that it warrants immediate action, we'll probably see more reports soon :)

nythrix's picture

Here's the promised piece.

Using 0.3.12.4:
The control repaints itself in the editor. When running, the background clears to a bright red as expected.

Using 0.3.13.3:
The control does not repaint in the editor. When running, the control is invisible because it gets some default control color. The background color i pick in the editor is also ignored (probably it's supposed to work like this, I don't know or care, I just thought it might help you)

using OpenTK.OpenGL;
using OpenTK.OpenGL.Enums;
 
namespace GlControlTest1
{
    partial class MainForm1
    {
        public MainForm1()
        {
            InitializeComponent();
        }
 
        protected override void OnLoad( System.EventArgs e )
        {
            base.OnLoad( e );
 
            glControl.Context.MakeCurrent();
 
            glControl.Paint += new System.Windows.Forms.PaintEventHandler( glControl_Paint );
            glControl.Resize += new System.EventHandler( glControl_Resize );
 
            GL.ClearColor( 1, 0, 0, 0 );
 
            GL.ClearDepth( 1 );
 
            GL.DepthFunc( DepthFunction.Less );
            GL.DepthMask( true );
 
            GL.Enable( EnableCap.DepthTest );
 
            GL.ShadeModel( ShadingModel.Smooth );
            glControl_Resize( this, new System.EventArgs() );
        }
 
        void glControl_Paint( object sender, System.Windows.Forms.PaintEventArgs e )
        {
            glControl.Context.MakeCurrent();
 
            GL.Clear( ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit );
 
            GL.LoadIdentity();
 
            glControl.SwapBuffers();
        }
 
        void glControl_Resize( object sender, System.EventArgs e )
        {
            glControl.Context.MakeCurrent();
 
            int width = glControl.ClientSize.Width;
            int height = glControl.ClientSize.Height;
 
            GL.MatrixMode( MatrixMode.Projection );
 
            GL.Viewport( 0, 0, width, height );
            GL.Scissor( 0, 0, width, height );
 
            if( height == 0 ) height = 1;
            double aspectRatio = width / ( double )height;
 
            GL.LoadIdentity();
 
            GL.Frustum( -1, 1, -aspectRatio, aspectRatio, 1, 100 );
 
            GL.MatrixMode( MatrixMode.Modelview );
 
            glControl.Invalidate();
        }
    }
}

Can u confirm this behaviour? Or at least tell me I have a bug in here :D

the Fiddler.'s picture

Thanks! Haven't been able to confirm yet, the control is rendered in a bright red color (tested Vista x64). Could it be that glControl.Visible is set to false somewhere in the glControl properties?

I'll have to test more thoroughly.

Semi-offtopic: Do you see GLControl as an option in Visual Studio's "ToolBox" pane? It doesn't appear on mine, although it should.

nythrix's picture

Could it be that glControl.Visible is set to false somewhere in the glControl properties?
Oh lord, I'm ruined. This is the most embarrasing moment of my net life. I can see gurus everywhere, laughing out their last meal. Damned mouseclick-programming. Forgive me and thank you for your patience.

In the editor the control is not repainting though. But that's a cosmetic issue so I'll stop nagging :)

Semi-offtopic: Do you see GLControl as an option in Visual Studio's "ToolBox" pane? It doesn't appear on mine, although it should.
Yes I do. I use WinXP Sp2 32bit, VC# EE.

Changes related:
I noticed you added "d" to Scale for double types but Rotate and Translate are unchanged. Any special reason for that?

the Fiddler.'s picture

:) I'll take a look at the repaint issue, shouldn't be hard to fix.

Changes related:
I noticed you added "d" to Scale for double types but Rotate and Translate are unchanged. Any special reason for that?

Oops, Regex fun! There was a 'd' missing in IsEnabled, but didn't consider that adding that back would affect Scale, too... (late night programming to the blame)