I am new to 3D graphics so i was following the instructions from the site of our university on how to work with 3D graphics but i can't understand why i have this error and if it's possible can someone explain to me how to fix this?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void OpenGLControl_OpenGLInitialized(object sender, OpenGLEventArgs args)
{
var gl = args.OpenGL;
gl.ClearColor(0.3f, 0.3f, 0.3f, 0.3f);
}
private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args)
{
var gl = args.OpenGL;
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.Begin(OpenGL.GL_TRIANGLES);
gl.Color(0f, 1f, 0f);
gl.Vertex(-1f, -1f);
gl.Vertex(0f, 1f);
gl.Vertex(1f, -1f);
gl.End();
}
private void OpenGLControl_Resized(object sender, OpenGLEventArgs args)
{
}
}
}
You are missing two key imports to be able to use the SharpGL
library. Just add these lines:
using SharpGL;
using SharpGL.SceneGraph;
In case someone else stumbles across this:
The issue here is that there are different versions of SharpGL. From the namespace, I'm assuming the OP wants to use the WPF version.
We need to add:
using SharpGL;
using SharpGL.WPF;
And also the event args parameters are slightly different:
private void OpenGLControl_OpenGLInitialized(object sender, OpenGLRoutedEventArgs args)
...
private void OpenGLControl_OpenGLDraw(object sender, OpenGLRoutedEventArgs args)
Ie use OpenGLRoutedEventArgs rather than OpenGLEventArgs .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.