/////////////////////////////////////////////// ////////////////////FIELDS///////////////////// /////////////////////////////////////////////// /*********************************************/ /////////////////////////////////////////////// /////////////////CONSTRUCTORS////////////////// /////////////////////////////////////////////// public WinFormsGlContext(Timer T, Form FatherForm, SimpleOpenGlControl drawContext, Action graphicsInit, Action drawMeth, Action <int, int> reshapeMeth, int FPS) { drawContext.InitializeContexts(); this.width = drawContext.Width; this.height = drawContext.Height; this.x = drawContext.Left; this.y = drawContext.Top; this.name = drawContext.Name; this.DrawContext = drawContext; this.ParentForm = FatherForm; this.T = T; this.FPS = FPS; T.Interval = (int)(1000f / FPS); T.Tick += new System.EventHandler(WinFormsTimerFunc); this.windowObserver = new Observer(0, 0, 5, 0, 0, 0, 0, 1, 0);//setting looker this.InitGraphicsMeth = graphicsInit; this.RedisplayMeth = drawMeth; this.ReshapeMeth = reshapeMeth; this.defColor = new GlWinDrawColor(0.0f, 0.0f, 0.0f); this.setDefColor(); this.setDefLineWidth(); this.ParentForm.Resize += this.WinFormsReshapeFunc; this.InitGraphicsMeth(); this.InitGlSetting(); }
public ModelViewer() { try { InitializeComponent(); Label not = new Label(); not.AutoSize = false; not.Text = "Not a model"; not.Dock = DockStyle.Fill; not.TextAlign = ContentAlignment.MiddleCenter; not.Visible = false; Controls.Add(not); try { gl_control = new SimpleOpenGlControl(); if (SoftwareRendering) { gl_control.Visible = false; } gl_control.Dock = DockStyle.Fill; gl_control.MouseDown += image_MouseDown; gl_control.MouseMove += image_MouseMove; gl_control.MouseWheel += image_MouseWheel; gl_control.InitializeContexts(); gl_control.SizeChanged += gl_control_SizeChanged; gl_control.KeyDown += gl_control_KeyDown; } catch (Exception ex) { MessageBox.Show("Failed to initialize OpenGL.\n\n" + ex.Message + "\n\n" + ex.StackTrace, "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Error); SoftwareRendering = true; } software_control = new SelectablePictureBox(); software_control.Dock = DockStyle.Fill; software_control.MouseDown += image_MouseDown; software_control.MouseMove += image_MouseMove; software_control.MouseWheel += image_MouseWheel; software_control.SizeChanged += gl_control_SizeChanged; software_control.KeyDown += gl_control_KeyDown; if (!SoftwareRendering) { software_control.Visible = false; } Controls.Add(gl_control); Controls.Add(software_control); selected_model = null; } catch (Exception e) { MessageBox.Show("An error occurred while loading the model viewer.\nIt's probably related to OpenGL.\n\n" + e.Message + "\n\n" + e.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public OpenGLAdapter(SimpleOpenGlControl viewport) { _viewport = viewport; _viewport.InitializeContexts(); Glut.glutInit(); Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH); Gl.glClearColor(255, 255, 255, 1); Gl.glViewport(0, 0, _viewport.Width, _viewport.Height); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluOrtho2D(0, _viewport.Height, 0, _viewport.Width); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); }
public Visualizer(SimpleOpenGlControl drawArea) { this.drawArea = drawArea; drawArea.InitializeContexts(); SetViewPort(); EnableSmooth(); RefreshBorders(); for (char s = '0'; s <= '9'; s++) { symOffset[s] = ((int)s - 48); } symOffset['p'] = 10; symOffset['L'] = 11; symOffset['z'] = 12; symOffset['n'] = 13; symOffset[','] = 14; }
public static void init(ref SimpleOpenGlControl canv) { canvas = canv; canvas.InitializeContexts(); Glut.glutInit(); Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_SINGLE | Glut.GLUT_DEPTH); Gl.glClearColor(1, 1, 1, 1); Gl.glViewport(0, 0, canvas.Width, canvas.Height); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluOrtho2D(0.0, canvas.Width, canvas.Height, 0.0); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); geometrics = new List <Shape>(); }
/// <summary> /// This function MUST be called when the form with the SimpelOpenGLControl is first shown. /// A good place to call is the FormLoadEvent. /// </summary> public void OnFormShown() { control.InitializeContexts(); control.AutoFinish = true; control.AutoSwapBuffers = true; control.MouseDown += new MouseEventHandler(control_MouseDown); control.MouseUp += new MouseEventHandler(control_MouseUp); control.MouseMove += new MouseEventHandler(control_MouseMove); w.ScreenSize = new SizeF(control.Size); w.Scale = 30.0f; GLUtility.InitGL(control.Width, control.Height, Color.White, control, false); xOff = 0; yOff = 0; renderTimer = new System.Timers.Timer(1.0 / fps * 1000.0); renderTimer.AutoReset = true; renderTimer.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed); renderTimer.Enabled = true; }
/** * @brief OpenGL ekrani initialize fonksiyonu * @param MONITOR * @retval yok */ public void initialize(SimpleOpenGlControl MONITOR) { MONITOR.InitializeContexts(); }
private void Form1_Load(object sender, EventArgs e) { sogc = new SimpleOpenGlControl(); sogc.Dock = DockStyle.Fill; sogc.Paint += new PaintEventHandler(sogc_Paint); sogc.Resize += new EventHandler(sogc_Resize); Controls.Add(sogc); sogc.InitializeContexts(); InitOpenGL(sogc.Size, 1, PointF.Empty); // Define the gravity vector. b2Vec2 gravity = new b2Vec2(0.0f, -10.0f); // Do we want to let bodies sleep? bool doSleep = true; // Construct a world object, which will hold and simulate the rigid bodies. world = new b2World(gravity, doSleep); // world.SetWarmStarting(true); { b2BodyDef bd = new b2BodyDef(); b2Body ground = world.CreateBody(bd); b2PolygonShape shape = new b2PolygonShape(); shape.SetAsEdge(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f)); ground.CreateFixture(shape, 0.0f); } { float a = 0.5f; b2CircleShape shape = new b2CircleShape(); shape.m_radius = a; b2Vec2 x = new b2Vec2(-7.0f, 0.95f); b2Vec2 y; b2Vec2 deltaX = new b2Vec2(0, 1.25f); b2Vec2 deltaY = new b2Vec2(0, 1.25f); y = deltaY; for (int j = 0; j < 8; ++j) { b2BodyDef bd = new b2BodyDef(); bd.type = b2BodyType.b2_dynamicBody; bd.position = y; b2Body body = world.CreateBody(bd); body.CreateFixture(shape, 5.0f); y += deltaY; } } GDIDebugThing.instance.SetFlags(EDebugFlags.e_shapeBit); world.SetDebugDraw(GDIDebugThing.instance); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 85; timer.SynchronizingObject = this; timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); timer.Start(); }
public Form1() { InitializeComponent(); AnT.InitializeContexts(); print(); }
public Preview_Obj() { InitializeComponent(); GlControl2.InitializeContexts(); Render(); }