Please support our C# advertiser: Programming Forums
Views: 6223 | Replies: 6
![]() |
Hi
This is a sample C# app which draws a line using csGL. I hope it helps.
using System;
using System.Drawing;
using System.Windows.Forms;
using CsGL.OpenGL;
public class GLCanvas : Form
{
View view = new View();
public GLCanvas()
{
Text = "C# OpenGL Merhaba Dünya";
view.Dock = DockStyle.Fill;
Controls.Add(view);
}
public static void Main()
{
GLCanvas glc = new GLCanvas();
Application.Run(glc);
}
}
class View : OpenGLControl
{
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GL.glLoadIdentity();
GL.glTranslatef( 0.0f, 0.0f, -10.0f );
GL.glColor3f(0.5f, 1, 1);
GL.glBegin(GL.GL_LINES);
GL.glVertex3d(0.0, 0.0, 0.0);
GL.glVertex3d(2.0, 2.0, 0.0);
GL.glEnd();
}
protected override void InitGLContext()
{
GL.glShadeModel(GL.GL_SMOOTH);
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
GL.glClearDepth(1.0f);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glDepthFunc(GL.GL_LEQUAL);
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
Size s = Size;
double aspect_ratio = (double)s.Width /(double) s.Height;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(45.0f, aspect_ratio, 0.1f, 100.0f);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
}
}
Loren Soth
This is a sample C# app which draws a line using csGL. I hope it helps.
using System;
using System.Drawing;
using System.Windows.Forms;
using CsGL.OpenGL;
public class GLCanvas : Form
{
View view = new View();
public GLCanvas()
{
Text = "C# OpenGL Merhaba Dünya";
view.Dock = DockStyle.Fill;
Controls.Add(view);
}
public static void Main()
{
GLCanvas glc = new GLCanvas();
Application.Run(glc);
}
}
class View : OpenGLControl
{
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GL.glLoadIdentity();
GL.glTranslatef( 0.0f, 0.0f, -10.0f );
GL.glColor3f(0.5f, 1, 1);
GL.glBegin(GL.GL_LINES);
GL.glVertex3d(0.0, 0.0, 0.0);
GL.glVertex3d(2.0, 2.0, 0.0);
GL.glEnd();
}
protected override void InitGLContext()
{
GL.glShadeModel(GL.GL_SMOOTH);
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
GL.glClearDepth(1.0f);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glDepthFunc(GL.GL_LEQUAL);
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
Size s = Size;
double aspect_ratio = (double)s.Width /(double) s.Height;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(45.0f, aspect_ratio, 0.1f, 100.0f);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
}
}
Loren Soth
Hi,
There are some frameworks on top of DirectX 9 Managed SDK but I am not familiar.
Loren Soth
There are some frameworks on top of DirectX 9 Managed SDK but I am not familiar.
Loren Soth
Crimson K. Software _________________________________________________________________ Crimson K. Blog
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode