1

I have two separate WPF projects. My goal: Alter project B to have the same OpenGL object instance version as project A.

Both instantiate a variable 'gl' at some point with the following line:

OpenGL gl = args.OpenGL;

After setting a breakpoint and check 'gl' for its object properties, I see the following in project A:

Version = "4.4.13084 Compatibility Profile Context 14.301.1001.0"

Yet in project B, I see the following:

Version = "1.1.0"

Concerning 'args' both projects instantiate gl in the following method:

private void OpenGLControl_OpenGLInitialized(object sender, OpenGLEventArgs args)

Both projects call that method with:

((SharpGL.WPF.OpenGLControl)(target)).OpenGLInitialized += new SharpGL.SceneGraph.OpenGLEventHandler(this.OpenGLControl_OpenGLInitialized);

Notice that 'args' is not being passed in from here explicitly. I figured function must be called in a deeper context like OpenGLEventHandler. However, I noticed that args is a parameter to that function as well.

public delegate void OpenGLEventHandler(object sender, OpenGLEventArgs args);

I don't have access to source code for OpenGLEventHandler since it is in SceneGraph.dll

I am wondering if the args variable is determined by a .config or .xaml file since my project is a WPF being run from Visual Studio. However, there isn't much differences in the files concerning OpenGL.

Project A's MainWindow.xaml:

<Window x:Class="ObjectLoadingSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Object LoadingSample" Height="600" Width="800"
        xmlns:sharpGL="clr-namespace:SharpGL.WPF;assembly=SharpGL.WPF">
    <Grid>
        <DockPanel>

            <ToolBarPanel DockPanel.Dock="Top">
                <Menu>
                    <MenuItem Header="_File">
                        <MenuItem x:Name="fileOpenItem" Header="_Open..." Click="fileOpenItem_Click" />
                    </MenuItem>
                </Menu>
            </ToolBarPanel>

            <ToolBarTray DockPanel.Dock="Top">
                <ToolBar>
                    <Label Target="{Binding ElementName=textBoxScale}">Scale: </Label>
                    <TextBox x:Name="textBoxScale" Width="60" IsEnabled="False">1</TextBox>
                    <CheckBox x:Name="checkBoxAutoScale" IsChecked="True" IsEnabled="False">Auto</CheckBox>
                    <Separator />
                    <Label Target="{Binding ElementName=comboBoxRenderMode}">Render Mode: </Label>
                    <ComboBox x:Name="comboBoxRenderMode" Width="100" SelectedIndex="1">
                        <ComboBoxItem>Immediate</ComboBoxItem>
                        <ComboBoxItem>Retained</ComboBoxItem>
                    </ComboBox>
                    <Label Target="{Binding ElementName=comboBoxPolygonMode}">Polygon Mode:</Label>
                    <ComboBox x:Name="comboBoxPolygonMode" Width="100" SelectedIndex="2" SelectionChanged="comboBoxPolygonMode_SelectionChanged">
                        <ComboBoxItem>Points</ComboBoxItem>
                        <ComboBoxItem>Lines</ComboBoxItem>
                        <ComboBoxItem>Polygons</ComboBoxItem>
                    </ComboBox>
                </ToolBar>
            </ToolBarTray>

            <sharpGL:OpenGLControl x:Name="openGlCtrl"
            OpenGLDraw="OpenGLControl_OpenGLDraw" OpenGLInitialized="OpenGLControl_OpenGLInitialized" 
            RenderContextType="FBO" Resized="OpenGLControl_Resized" />
        </DockPanel>
    </Grid>
</Window>

Project B's MainWindow.xaml

<Window x:Class="ProjectBeta.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sharpGL="clr-namespace:SharpGL.WPF;assembly=SharpGL.WPF"
        Title="MainWindow" Height="800" Width="800">
  <Grid>
    <sharpGL:OpenGLControl OpenGLDraw="OpenGLControl_OpenGLDraw" OpenGLVersion="OpenGL4_3"  OpenGLInitialized="OpenGLControl_OpenGLInitialized" DrawFPS="True" Margin="-3,0,3,0" />
  </Grid>
</Window>

There are other files like App.config, App.xaml, and Settings.settings, however, I don't know which ones would be most useful to share.

Timothy Swan
  • 623
  • 3
  • 9
  • 21
  • Well, "Project B" requests an explicit OpenGL version and "Project A" does not. – Andon M. Coleman Nov 12 '14 at 17:39
  • @AndonM.Coleman Seriously? Did you even look at the version? I added that in to force it to be version 4 and not version 1. Please stop commenting and downvoting my questions just because you don't know the answer. – Timothy Swan Nov 12 '14 at 17:41
  • 1
    What the heck is your problem? I have never down-voted your questions even though your attitude is making that very tempting. I have done nothing but try to help you, and this is the thanks I get. You should really adjust your attitude if you expect to get help on this website. – Andon M. Coleman Nov 12 '14 at 17:50
  • Are there any other differences in the projects, like in which assemblies are referenced, or native DLLs that are exported to the output directory? – Mike Strobel Nov 12 '14 at 17:52
  • Well, my last question on this got downvoted right after I answered your last comment you didn't reply to. No one answered and I have a legitimate problem here that I am trying to solve. As I stated in the question, Project A has version 4 and project B as version 1. My explicit OpenGL version request was an attempt to force project B to version 4. It didn't change anything. – Timothy Swan Nov 12 '14 at 17:53
  • @MikeStrobel I checked the solution properties and project properties for differences. The major differences in the projects are the files themselves. The only difference there is one refers to CPU settings as containing the option 'Any CPU' and the other refers to it containing 'x86' Otherwise, it is only files that are different. – Timothy Swan Nov 12 '14 at 18:30
  • What happens if you switch the x86 project to Any CPU? Does that affect the OpenGL version? Perhaps it drops from v4 down to v1? Also check to see if one project ships an OpenGL .dll in its output folder. – Mike Strobel Nov 12 '14 at 18:41
  • @MikeStrobel I cannot switch x86 to 'Any CPU' or vica versa. One project has x86 as an option. The other project has 'Any CPU' as an option. Honestly, the difference might indicate some difference between the projects, but it is probably just distracting us from finding what causes the difference in how OpenGL is instantiated. I don't think that depends on whether it is using my 'Any CPU' or my x86 CPU, which are the same CPU anyway. – Timothy Swan Nov 12 '14 at 18:44
  • It makes a difference for unmanaged code interop, e.g., when working with OpenGL. The x86 version might be linking against a more "complete" OpenGL implementation in a 32-bit DLL while the Any CPU version might be linking against a more minimal implementation in a 64-bit DLL. Check the Debug -> Modules window in Visual Studio to see which OpenGL-related DLLs are loaded for each project. If unmanaged DLLs don't show up, use Process Explorer. – Mike Strobel Nov 12 '14 at 18:53
  • If it wasn't clear from my last comment, x86 and Any CPU are not the same; x86 forces you to run in a 32-bit CLR, even if an x64 CLR is available. Any CPU will run on the "best" CLR available, e.g., x64. Based on whether you're running in a 32/64-bit CLR, your app will expect to link to 32/64-bit unmanaged DLLs. – Mike Strobel Nov 12 '14 at 19:02
  • @MikeStrobel Both projects use SharpGL.dll, SharpGL.WPF.dll, and SharpGL.SceneGraph.dll – Timothy Swan Nov 12 '14 at 19:55
  • Can you try switching your AnyCPU project to x86? Look under Project Properties -> Build -> Platform Target. – Mike Strobel Nov 12 '14 at 20:01
  • @MikeStrobel The only option available there is "Active (Any CPU)" – Timothy Swan Nov 12 '14 at 20:03
  • You're looking at the wrong drop-down. Don't look at "Configuration" or "Platform" at the top. Look at "Platform target" under the "Build" tab. – Mike Strobel Nov 12 '14 at 20:04
  • @MikeStrobel I set it to x86. The object stays at v1.1 and the drop downs still say Any CPU – Timothy Swan Nov 12 '14 at 20:39

0 Answers0