fdncred's picture

SVN Code Disables Windows7 Aero

I'm not sure why but the latest svn code disables Windows7 Aero them and switches to Basic. The precompiled binaries for the latest release work fine and do not disable the Aero theme. Any ideas how to fix this so it does not disable the Aero theme?

Thanks,
Darren


Comments

Comment viewing options

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

OpenTK doesn't actually interact with Aero directly.

  • When does this happen? (i.e. when moving to fullscreen or always on program startup?)
  • Are you using the GameWindow?
  • Can you please post a simple test case that reproduces the issue? (Run OpenTK.Examples in OpenTK.sln and check whether the issue occurs there - if so, please post the example name).
fdncred's picture

I followed the HowTo create a glControl WinForm tutorial. It happens on load. Here's my sample code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System.Diagnostics;
 
namespace GLApp
{
    public partial class GLApp : Form
    {
        bool bIsLoaded = false;
        int x = 0, y = 0;
        float rotation = 0;
        Stopwatch sw = new Stopwatch(); // available to all event handlers
        double accumulator = 0;
        int idleCounter = 0;
 
        public GLApp()
        {
            InitializeComponent();
        }
 
        private void glControl1_Load(object sender, EventArgs e)
        {
            bIsLoaded = true;
            GL.ClearColor(Color.SkyBlue); // Yey! .NET Colors can be used directly!
            SetupViewport();
            Application.Idle += new EventHandler(Application_Idle);
            sw.Start(); // start at application boot
            x = glControl1.Width / 2;
            y = glControl1.Height / 2;
        }
 
        void Application_Idle(object sender, EventArgs e)
        {
            double milliseconds = ComputeTimeSlice();
            Accumulate(milliseconds);
            Animate(milliseconds);
        }
 
        private double ComputeTimeSlice()
        {
            sw.Stop();
            double timeslice = sw.Elapsed.TotalMilliseconds;
            sw.Reset();
            sw.Start();
            return timeslice;
        }
 
        private void Animate(double milliseconds)
        {
            float deltaRotation = (float)milliseconds / 20.0f;
            rotation += deltaRotation;
            glControl1.Invalidate();
        }
 
        private void glControl1_Resize(object sender, EventArgs e)
        {
            if (!bIsLoaded)
                return;
 
            SetupViewport();
            glControl1.Invalidate();
        }
 
        private void Accumulate(double milliseconds)
        {
            idleCounter++;
            accumulator += milliseconds;
            if (accumulator > 1000)
            {
                toolStripStatusLabel1.Text = String.Format("FPS: {0} X: {1} Y: {2}", idleCounter.ToString(), x, y);
                accumulator -= 1000;
                idleCounter = 0; // don't forget to reset the counter!
            }
        }
 
        private void Render()
        {
            if (!bIsLoaded) // Play nice
                return;
 
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
 
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
 
            GL.Translate(x, y, 0); // position triangle according to our x variable
            if (glControl1.Focused)
                GL.Color3(Color.Yellow);
            else
                GL.Color3(Color.Blue);
            GL.Rotate(rotation, Vector3.UnitZ); // OpenTK has this nice Vector3 class!
 
            GL.Begin(BeginMode.Triangles);
            GL.Vertex2(10, 20);
            GL.Vertex2(100, 20);
            GL.Vertex2(100, 50);
            GL.End();
 
            glControl1.SwapBuffers();
        }
 
        private void glControl1_Paint(object sender, PaintEventArgs e)
        {
            Render();
        }
 
        private void SetupViewport()
        {
            int w = glControl1.Width;
            int h = glControl1.Height;
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, w, 0, h, -1, 1); // Bottom-left corner pixel has coordinate (0, 0)
            GL.Viewport(0, 0, w, h); // Use all of the glControl painting area
        }
 
        private void glControl1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.W)
                y++;
            if (e.KeyCode == Keys.S)
                y--;
            if (e.KeyCode == Keys.D)
                x++;
            if (e.KeyCode == Keys.A)
                x--;
            glControl1.Invalidate();
        }
    }
}

I also see it in the Examples - didn't test all of them but here's a few. Immediate Mode does *NOT* switch to Basic. DisplayLists does it. TextureMapping does it. StencilCSG does it. JuliaSetFractals does it.

the Fiddler's picture

Can you please test those same examples with 1.0 (not SVN)? Do they also disable Aero?

Also, what video card and OS are you using (Vista/7, 32-/64-bit). The result of GL.GetString(StringName.Vendor/Renderer/Version) might help pin down the issue.

fdncred's picture

None of the 1.0 samples disable Aero.

I'm running Windows7 32-bit and using a NVidia Quadro FX770M, drivers 226.58

the Fiddler's picture

Thanks, this gives me a hint on where to look. The logic behind GraphicsMode selection has changed between 1.0 and trunk and it now (presumably) selects a mode that's not compatible with Aero.

Let me take a look and I'll let you know what I find.

djk's picture

We just switched from OpenTK-1.0-beta-2 to the latest in the svn trunk about a week ago.

All of our Win 7 Enterprise 64 bit development machines experience a momentary blip where all screens go Black when OpenTK creates the glcontext through the GLControl and again when the glcontext is destroyed when the application exits.

These laptops all have Quadro FX 3700M video with NVidia's 2.66.58 drivers installed.

Disabling Aero seems to avoid the black screens.

One further note, we migrated from .Net 3.5 to .Net 4 at the same time as since we were at a break in the development schedule.

Edit: We are using the forward compatible GLcontext
Edit 2: Looks like we are on svn rev 3064 at the moment.

the Fiddler's picture

Let me see if I can reproduce this on my Nvidia system (my Ati system doesn't exhibit this).

reibisch's picture

Does anyone have other data on this issue? I just encountered it for the first time today (just started using the SVN build rather than 1.0) and what I'm experiencing is very similar to djk -- aero being disabled upon context creation and being restored when the application exits. In my case I'm using a GameWindow rather than GLControl.

My system is Win7-64 using a Quadro 2000 card (now running with the latest release drivers as I thought this might be the culprit).

Diaren's picture

see my post here