Что-то написал. Но почему-то сразу же выходит после запуска программы.
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;
// для работы с библиотекой OpenGL
using Tao.OpenGl;
// для работы с библиотекой FreeGLUT
using Tao.FreeGlut;
// для работы с элементом управления SimpleOpenGLControl
using Tao.Platform.Windows;
namespace View3D
{
public partial class Form1 : Form
{
int x, y;
double AlphaX,AlphaY;
bool MouseIsDown;
public Form1()
{
AlphaX = 45;
AlphaY = 45;
InitializeComponent();
AnT.InitializeContexts();
Init();
Draw();
Gl.glFlush();
AnT.Invalidate();
}
private void Init()
{
Glut.glutInit();
Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
Gl.glClearColor(0, 0, 0, 1);
Gl.glViewport(0, 0, AnT.Width, AnT.Height);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluPerspective(45, (float)AnT.Width / (float)AnT.Height, 0.1, 200);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
Gl.glEnable(Gl.GL_DEPTH_TEST);
Glu.gluLookAt(10, 10, 10, 0, 0, 0, 0, 0, 1);
}
private void Draw()
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
Gl.glColor3f(1, 1, 1);
Gl.glPushMatrix();
Gl.glTranslated(0, 0, -6);
Gl.glRotated(AlphaX, 1, 0, 0);
Gl.glRotated(AlphaY, 0, 1, 0);
Glut.glutWireCube(2);
Gl.glColor3f(1, 0, 0);
DrawAxes(0.5);
Gl.glPopMatrix();
}
private void DrawAxes(double Length)
{
Gl.glColor3f(1, 0, 0);
Gl.glBegin(Gl.GL_LINES);
Gl.glVertex3d(0,0,0);
Gl.glVertex3d(Length, 0, 0);
Gl.glEnd();
Gl.glColor3f(0, 1, 0);
Gl.glBegin(Gl.GL_LINES);
Gl.glVertex3d(0, 0, 0);
Gl.glVertex3d(0, Length, 0);
Gl.glEnd();
Gl.glColor3f(0, 0, 1);
Gl.glBegin(Gl.GL_LINES);
Gl.glVertex3d(0, 0, 0);
Gl.glVertex3d(0, 0, Length);
Gl.glEnd();
}
private void AnT_DragDrop(object sender, DragEventArgs e)
{
}
private void AnT_MouseDown_1(object sender, MouseEventArgs e)
{
x = e.X;
y = e.Y;
MouseIsDown = true;
}
private void AnT_MouseUp_1(object sender, MouseEventArgs e)
{
MouseIsDown = false;
}
private void AnT_MouseMove_1(object sender, MouseEventArgs e)
{
if (MouseIsDown)
{
AlphaX += Convert.ToDouble(x - e.X);
AlphaY += Convert.ToDouble(y - e.Y);
x = e.X;
y = e.Y;
Init();
Draw();
}
}
}
} |
1671
13.03.2011
2



.