protected override void OnRenderFrame(FrameEventArgs e) { this.Title = WindowTitle + " FPS: " + (1f / e.Time).ToString("0."); MySphereZOffset += (float)(e.Time * 3.1); MySphereXOffset += (float)(e.Time * 4.2); #region Transform setup GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); // Camera GL.MatrixMode(MatrixMode.Modelview); Matrix4 mv = Matrix4.LookAt(EyePosition, Vector3.Zero, Vector3.UnitY); GL.LoadMatrix(ref mv); GL.Translate(0f, 0f, CameraZoom); GL.Rotate(CameraRotX, Vector3.UnitY); GL.Rotate(CameraRotY, Vector3.UnitX); #endregion Transform setup RenderCsg(); // --------------------------------- if (ShowDebugWireFrame) { GLHelper.Color3(PixelFarm.Drawing.Color.LightGray); GL.Disable(EnableCap.StencilTest); GL.Disable(EnableCap.Lighting); //GL.Disable( EnableCap.DepthTest ); GL.PolygonMode(MaterialFace.Front, PolygonMode.Line); DrawOperandB(); GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.StencilTest); } this.SwapBuffers(); }
private void DrawSnappingMarks(DrawGlContentEventArgs drawEventArgs, double mouseAngle, double alphaValue, Matrix4X4 rotationCenterTransform, double distanceFromCenter, double dotRadius, int numSnapPoints, int markToSnapTo) { var graphics2DOpenGL = new Graphics2DOpenGL(); double snappingRadians = MathHelper.Tau / numSnapPoints; var clippingFrustum = GLHelper.GetClippingFrustum(InteractionContext.World); for (int i = 0; i < numSnapPoints; i++) { double startAngle = i * snappingRadians + mouseAngle; VertexStorage snapShape = new VertexStorage(); snapShape.MoveTo(-10, 0); snapShape.LineTo(5, 7); snapShape.LineTo(5, -7); snapShape.ClosePolygon(); var transformed = new VertexSourceApplyTransform(snapShape, Affine.NewTranslation(distanceFromCenter, 0) * Affine.NewRotation(startAngle)); // new Ellipse(startPosition.x, startPosition.y, dotRadius, dotRadius); var color = Color.Black; if (i == markToSnapTo) { color = Color.Red; } graphics2DOpenGL.RenderTransformedPath(rotationCenterTransform, transformed, new Color(color, (int)(254 * alphaValue)), drawEventArgs.ZBuffered); } }
public override void Draw(DrawGlContentEventArgs e) { bool shouldDrawScaleControls = true; if (Object3DControlContext.SelectedObject3DControl != null && Object3DControlContext.SelectedObject3DControl as ScaleMatrixEdgeControl == null) { shouldDrawScaleControls = false; } var selectedItem = RootSelection; if (selectedItem != null && Object3DControlContext.Scene.ShowSelectionShadow) { // Ensures that functions in this scope run against the original instance reference rather than the // current value, thus avoiding null reference errors that would occur otherwise if (shouldDrawScaleControls) { // don't draw if any other control is dragging if (MouseIsOver) { GLHelper.Render(minXminYMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded); } else { GLHelper.Render(minXminYMesh, theme.TextColor.Blend(theme.BackgroundColor, .35).WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded); } } } base.Draw(e); }
public IActionResult UpdateGLSubCode([FromBody] GlsubCode subcode) { if (subcode == null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = $"{nameof(subcode)} cannot be null" })); } try { GlsubCode result = GLHelper.UpdateGLSubCode(subcode); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); glControl1_Resize(this, EventArgs.Empty); // Ensure the Viewport is set up correctly GLHelper.ClearColor(PixelFarm.Drawing.Color.LightGray); }
public IActionResult GetAccountSubGrouplist(string glaccGroupCode) { if (string.IsNullOrEmpty(glaccGroupCode)) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Account group Can not be null/empty." })); } try { dynamic expando = new ExpandoObject(); expando.GLAccSubGroupList = GLHelper.GetGLAccountSubGroup(glaccGroupCode).Select(a => new { ID = a.SubGroupCode, TEXT = a.SubGroupName }); return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = expando })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult UpdateGLAccUnderSubGroup([FromBody] GlaccUnderSubGroup glaccUnderSubGroup) { if (glaccUnderSubGroup == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(glaccUnderSubGroup)} cannot be null" })); } try { GlaccUnderSubGroup result = GLHelper.UpdateUnderSubGroup(glaccUnderSubGroup); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult RegisterAsigCashAccBranch([FromBody] AsignmentCashAccBranch asignmentCashAccBranch) { try { AsignmentCashAccBranch result = GLHelper.RegisterCashAccToBranches(asignmentCashAccBranch); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "" })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult UpdateaAignmentCashAccBranch([FromBody] AsignmentCashAccBranch asignmentCashAccBranch) { if (asignmentCashAccBranch == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(asignmentCashAccBranch)} cannot be null" })); } try { AsignmentCashAccBranch result = GLHelper.UpdateCashAccToBranches(asignmentCashAccBranch); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = "Updation Failed" })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public void Draw(GuiWidget sender, IObject3D item, bool isSelected, DrawEventArgs e, Matrix4X4 itemMaxtrix, WorldView world) { if (item == scene.DebugItem) { //if (item.Mesh != null) //{ // var debugItem = scene.DebugItem; // GLHelper.Render( // debugItem.Mesh, // debugBorderColor, // debugItem.WorldMatrix(), // RenderTypes.Wireframe, // debugItem.WorldMatrix() * world.ModelviewMatrix); //} var frustum = world.GetClippingFrustum(); var aabb = item.GetAxisAlignedBoundingBox(Matrix4X4.Identity); world.RenderAabb(aabb, Matrix4X4.Identity, debugBorderColor, 1); if (item.Mesh != null) { GLHelper.Render( item.Mesh, debugBorderColor, item.WorldMatrix(), RenderTypes.Wireframe, item.WorldMatrix() * world.ModelviewMatrix); } } }
public IActionResult DeleteAignmentCashAccBranch(string code) { if (string.IsNullOrWhiteSpace(code)) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(code)} cannot be null" })); } try { AsignmentCashAccBranch result = GLHelper.DeleteCashAccToBranches(code); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Deletion Failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
/// <summary> /// Creates a FrameBuffer that wraps a given Texture2D object. This Texture2D will not be disposed when the /// FrameBuffer itself is disposed, unlike other constructors. /// </summary> public FrameBuffer(RenderContext renderContext, Texture2D wrappedTexture) : base(renderContext) { Width = wrappedTexture._width; Height = wrappedTexture._height; Flags = FrameBufferFlags.Color; Handle = GLHelper.CreateFrameBuffer(); GLHelper.EnsureValid(Handle); GLHandle prevFrameBuffer = (GLHandle)GL.GetInteger(GetPName.FramebufferBinding); GL.BindFramebuffer(FramebufferTarget.Framebuffer, Handle); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, wrappedTexture.Handle, 0); GL.BindFramebuffer(FramebufferTarget.Framebuffer, prevFrameBuffer); if (!IsComplete()) { throw new InvalidOperationException(); } }
/* More or less universal functions... */ public static void Initialize(GLHelper glHelper) { Rendering.glHelper = glHelper; glHelper.Textures.AddTexture(EmptyTextureName, Properties.Resources.Empty); glHelper.Shaders.AddProgramWithShaders(DefaultShaderName, File.ReadAllText("Data\\Default.vert"), File.ReadAllText("Data\\Default.frag")); glHelper.Shaders.AddProgramWithShaders(LightMarkerShaderName, File.ReadAllText("Data\\LightMarker.vert"), File.ReadAllText("Data\\LightMarker.frag"), File.ReadAllText("Data\\LightMarker.geom")); glHelper.Shaders.AddProgramWithShaders(LightLineShaderName, File.ReadAllText("Data\\LightMarker.vert"), File.ReadAllText("Data\\LightMarker.frag"), File.ReadAllText("Data\\LightLine.geom")); glHelper.Buffers.AddVertices(AxisMarkerObjectName, new GLVertex[] { new GLVertex(new Vector3(-300.0f, 0.0f, 0.0f), Vector3.Zero, OpenTK.Graphics.Color4.Black, Vector2.Zero), new GLVertex(new Vector3(300.0f, 0.0f, 0.0f), Vector3.Zero, OpenTK.Graphics.Color4.Black, Vector2.Zero), new GLVertex(new Vector3(0.0f, 300.0f, 0.0f), Vector3.Zero, OpenTK.Graphics.Color4.Black, Vector2.Zero), new GLVertex(new Vector3(0.0f, -300.0f, 0.0f), Vector3.Zero, OpenTK.Graphics.Color4.Black, Vector2.Zero) }); glHelper.Buffers.AddIndices(AxisMarkerObjectName, new uint[] { 0, 1, 2, 3 }, PrimitiveType.Lines); glHelper.Buffers.AddVertices(LightMarkerObjectName, new GLVertex[] { new GLVertex(Vector3.Zero, Vector3.Zero, OpenTK.Graphics.Color4.White, Vector2.Zero) }); glHelper.Buffers.AddIndices(LightMarkerObjectName, new uint[] { 0 }, PrimitiveType.Points); Lights[0] = new LightStruct(); Lights[0].Enabled = true; Lights[0].Position = Vector4.Zero; Lights[0].Intensities = new Vector3(0.75f, 0.75f, 0.75f); Lights[0].AmbientCoefficient = 0.5f; Lights[1] = new LightStruct(); Lights[1].Enabled = true; Lights[1].Intensities = new Vector3(0.4f, 0.7f, 1.0f); Lights[1].AmbientCoefficient = 0.05f; Lights[2] = new LightStruct(); Lights[2].Enabled = true; Lights[2].Intensities = new Vector3(1.0f, 0.7f, 0.4f); Lights[2].AmbientCoefficient = 0.05f; Lights[3] = new LightStruct(); Lights[3].Enabled = true; Lights[3].Intensities = new Vector3(0.4f, 0.1f, 0.7f); Lights[3].AmbientCoefficient = 0.05f; Lights[4] = new LightStruct(); Lights[4].Enabled = true; Lights[4].Intensities = new Vector3(0.7f, 1.0f, 0.4f); Lights[4].AmbientCoefficient = 0.05f; }
//public synchronized void update(final GL10 pGL) { public void Update(GL10 pGL) { lock (_methodLock) { //final ArrayList<Letter> lettersPendingToBeDrawnToTexture = this.mLettersPendingToBeDrawnToTexture; List <Letter> lettersPendingToBeDrawnToTexture = this.mLettersPendingToBeDrawnToTexture; if (lettersPendingToBeDrawnToTexture.Count > 0) { int hardwareTextureID = this.mTexture.GetHardwareTextureID(); float textureWidth = this.mTextureWidth; float textureHeight = this.mTextureHeight; for (int i = lettersPendingToBeDrawnToTexture.Count - 1; i >= 0; i--) { Letter letter = lettersPendingToBeDrawnToTexture[i]; Bitmap bitmap = this.GetLetterBitmap(letter.mCharacter); GLHelper.BindTexture(pGL, hardwareTextureID); GLUtils.TexSubImage2D(GL10Consts.GlTexture2d, 0, (int)(letter.mTextureX * textureWidth), (int)(letter.mTextureY * textureHeight), bitmap); bitmap.Recycle(); } lettersPendingToBeDrawnToTexture.Clear(); //System.gc(); // TODO: Verify if this is a good match: System.gc() -> Dispose() ... leaving it to standard GC at present } } }
public IActionResult DeleteTblAccountGroup(int code) { //if (string.IsNullOrWhiteSpace(code)) // return BadRequest($"{nameof(code)} cannot be null"); try { TblAccountGroup result = new GLHelper().DeleteTblAccountGroup(code); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Deletion failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult UpdateVoucherTypes([FromBody] VoucherTypes vouchertype) { if (vouchertype == null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = "Request cannot be null" })); } try { VoucherTypes result = GLHelper.UpdateVoucherType(vouchertype); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult GetTblAccountGroupList() { try { var tblAccountGroupList = new GLHelper().GetTblAccountGroupList(); if (tblAccountGroupList.Count > 0) { dynamic expando = new ExpandoObject(); expando.tblAccountGroupList = tblAccountGroupList; return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = expando })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "No Data Found." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
protected override void OnInitDraw(GL10 pGL) { base.OnInitDraw(pGL); GLHelper.DisableTextures(pGL); GLHelper.DisableTexCoordArray(pGL); GLHelper.LineWidth(pGL, this.mLineWidth); }
public IActionResult RegisterTblAccGroup([FromBody] TblAccountGroup tblAccGrp) { if (tblAccGrp == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(tblAccGrp)} can not be null" })); } try { TblAccountGroup result = new GLHelper().RegisterTblAccGroup(tblAccGrp); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Registration failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public override void ActionApproved() { base.ActionApproved(); SaleOrderEntities entity = (SaleOrderEntities)CurrentModuleEntity; List <ARSaleOrderItemsInfo> invetoryCheckList = new List <ARSaleOrderItemsInfo>(); ICProductsController objProductsController = new ICProductsController(); ICProductsInfo objProductsInfo = new ICProductsInfo(); entity.SaleOrderItemsList.ForEach(o => { objProductsInfo = (ICProductsInfo)objProductsController.GetObjectByID(o.FK_ICProductID); if (objProductsInfo == null) { return; } if (o.ARSaleOrderItemGrantedFrom == ProductGrantedFrom.Inventory) { invetoryCheckList.Add((ARSaleOrderItemsInfo)o.Clone()); } }); if (!IsValidInventoryStockQty(invetoryCheckList)) { return; } ARSaleOrdersInfo mainObject = (ARSaleOrdersInfo)entity.MainObject; ARSaleOrdersController objSaleOrdersController = new ARSaleOrdersController(); mainObject.ARSaleOrderStatus = "Approved"; entity.UpdateMainObject(); GLHelper.PostedTransactions(CurrentModuleName, mainObject.ARSaleOrderID, ModulePostingType.SaleOrder); InvalidateToolbar(); }
public IActionResult GetGLSubCodeList() { try { var subCodeList = GLHelper.GetGLSubCodeList(); if (subCodeList.Count > 0) { dynamic expando = new ExpandoObject(); expando.GLSubCodeList = subCodeList; return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = expando })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "No Data Found." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public static void RenderAabb(this WorldView world, AxisAlignedBoundingBox bounds, Matrix4X4 matrix, Color color, double width, double extendLineLength = 0) { GLHelper.PrepareFor3DLineRender(true); Frustum frustum = world.GetClippingFrustum(); for (int i = 0; i < 4; i++) { Vector3 sideStartPosition = Vector3.Transform(bounds.GetBottomCorner(i), matrix); Vector3 sideEndPosition = Vector3.Transform(bounds.GetTopCorner(i), matrix); Vector3 bottomStartPosition = sideStartPosition; Vector3 bottomEndPosition = Vector3.Transform(bounds.GetBottomCorner((i + 1) % 4), matrix); Vector3 topStartPosition = sideEndPosition; Vector3 topEndPosition = Vector3.Transform(bounds.GetTopCorner((i + 1) % 4), matrix); if (extendLineLength > 0) { GLHelper.ExtendLineEnds(ref sideStartPosition, ref sideEndPosition, extendLineLength); GLHelper.ExtendLineEnds(ref topStartPosition, ref topEndPosition, extendLineLength); GLHelper.ExtendLineEnds(ref bottomStartPosition, ref bottomEndPosition, extendLineLength); } // draw each of the edge lines (4) and their touching top and bottom lines (2 each) world.Render3DLineNoPrep(frustum, sideStartPosition, sideEndPosition, color, width); world.Render3DLineNoPrep(frustum, topStartPosition, topEndPosition, color, width); world.Render3DLineNoPrep(frustum, bottomStartPosition, bottomEndPosition, color, width); } GL.Enable(EnableCap.Lighting); }
public IActionResult DeleteGLSubCode(string code) { if (string.IsNullOrWhiteSpace(code)) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = $"{nameof(code)} cannot be null" })); } try { GlsubCode result = GLHelper.DeleteGLSubCode(code); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Deletion failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public static void RenderAxis(this WorldView world, Vector3 position, Matrix4X4 matrix, double size, double lineWidth) { GLHelper.PrepareFor3DLineRender(true); Frustum frustum = world.GetClippingFrustum(); Vector3 length = Vector3.One * size; for (int i = 0; i < 3; i++) { var min = position; min[i] -= length[i]; Vector3 start = Vector3.Transform(min, matrix); var max = position; max[i] += length[i]; Vector3 end = Vector3.Transform(max, matrix); var color = Agg.Color.Red; switch (i) { case 1: color = Agg.Color.Green; break; case 2: color = Agg.Color.Blue; break; } // draw each of the edge lines (4) and their touching top and bottom lines (2 each) world.Render3DLineNoPrep(frustum, start, end, color, lineWidth); } GL.Enable(EnableCap.Lighting); }
public override void DrawGlContent(DrawGlContentEventArgs e) { IObject3D selectedItem = RootSelection; // We only draw rotation controls if something is selected if (selectedItem != null) { // make sure the image is initialized RenderOpenGl.ImageGlPlugin.GetImageGlPlugin(rotationImageWhite, true); // We only draw the rotation arrows when the user has not selected any interaction volumes (they are not actively scaling or rotating anything). if (InteractionContext.SelectedInteractionVolume == null) { var color = MouseOver ? Color.Red : Color.Black; GLHelper.Render(rotationHandle, new Color(color, 254), TotalTransform, RenderTypes.Shaded); } // If the user is over the control or has clicked on it if (mouseMoveInfo != null || mouseDownInfo != null || MouseOver) { DrawRotationCompass(selectedItem, e); } } base.DrawGlContent(e); }
public static void RenderCylinderOutline(this WorldView world, Matrix4X4 worldMatrix, Vector3 center, double Diameter, double Height, int sides, Color color, double lineWidth = 1, double extendLineLength = 0) { GLHelper.PrepareFor3DLineRender(true); Frustum frustum = world.GetClippingFrustum(); for (int i = 0; i < sides; i++) { var rotatedPoint = new Vector3(Math.Cos(MathHelper.Tau * i / sides), Math.Sin(MathHelper.Tau * i / sides), 0) * Diameter / 2; var sideTop = Vector3.Transform(center + rotatedPoint + new Vector3(0, 0, Height / 2), worldMatrix); var sideBottom = Vector3.Transform(center + rotatedPoint + new Vector3(0, 0, -Height / 2), worldMatrix); var rotated2Point = new Vector3(Math.Cos(MathHelper.Tau * (i + 1) / sides), Math.Sin(MathHelper.Tau * (i + 1) / sides), 0) * Diameter / 2; var topStart = sideTop; var topEnd = Vector3.Transform(center + rotated2Point + new Vector3(0, 0, Height / 2), worldMatrix); var bottomStart = sideBottom; var bottomEnd = Vector3.Transform(center + rotated2Point + new Vector3(0, 0, -Height / 2), worldMatrix); if (extendLineLength > 0) { GLHelper.ExtendLineEnds(ref sideTop, ref sideBottom, extendLineLength); } world.Render3DLineNoPrep(frustum, sideTop, sideBottom, color, lineWidth); world.Render3DLineNoPrep(frustum, topStart, topEnd, color, lineWidth); world.Render3DLineNoPrep(frustum, bottomStart, bottomEnd, color, lineWidth); } // turn the lighting back on GL.Enable(EnableCap.Lighting); }
public override void DrawGlContent(DrawGlContentEventArgs e) { bool shouldDrawMoveControls = true; if (InteractionContext.SelectedInteractionVolume != null && InteractionContext.SelectedInteractionVolume as MoveInZControl == null) { shouldDrawMoveControls = false; } var selectedItem = RootSelection; if (selectedItem != null) { if (shouldDrawMoveControls) { // don't draw if any other control is dragging if (MouseOver) { GLHelper.Render(upArrowMesh, theme.PrimaryAccentColor, TotalTransform, RenderTypes.Shaded); } else { GLHelper.Render(upArrowMesh, theme.TextColor, TotalTransform, RenderTypes.Shaded); } } } base.DrawGlContent(e); }
// internal void SetDataFromBitmap(BitmapData data) // { // GL.TextureSubImage2D(Handle, // 0, // 0, // 0, // Width, // Height, // PixelFormat.Bgra, // PixelType.UnsignedByte, // data.Scan0); // } public void Reload(AssetManager assetManager) { Texture2D texture = null; if (BoundContext != null) { Unbind(BoundContext); } try { using var stream = assetManager.GetStreamFromPath(SourcePath); var createdTexture = AssetManager.Texture2DLoader.Load(assetManager, assetManager.RenderContext, stream, SourcePath); texture = createdTexture; } catch (Exception e) { _log.Error("Error reloading Texture2D: " + e.Message); } if (texture != null) { var initialHandle = this.Handle; GL.DeleteTexture(Handle); this.Handle = texture.Handle; this.Height = texture.Height; this.Width = texture.Width; GLHelper.TextureParameter(assetManager.RenderContext, TextureTarget.Texture2D, this, TextureParameterName.TextureMinFilter, (int)_minFilter); GLHelper.TextureParameter(assetManager.RenderContext, TextureTarget.Texture2D, this, TextureParameterName.TextureMagFilter, (int)_magFilter); GLHelper.TextureParameter(assetManager.RenderContext, TextureTarget.Texture2D, this, TextureParameterName.TextureWrapS, (int)_wrapModeS); GLHelper.TextureParameter(assetManager.RenderContext, TextureTarget.Texture2D, this, TextureParameterName.TextureWrapT, (int)_wrapModeT); GL.GenerateTextureMipmap(Handle); _log.Info($"Texture reloaded successfully! {initialHandle} -> {Handle}"); } }
public override void OnDraw(Graphics2D graphics2D) { if (!mouseOver) { ResetTextures(); } var screenSpaceBounds = this.TransformToScreenSpace(LocalBounds); world = new WorldView(screenSpaceBounds.Width, screenSpaceBounds.Height); var forward = -Vector3.UnitZ; var directionForward = Vector3.TransformNormal(forward, interactionLayer.World.InverseModelviewMatrix); var up = Vector3.UnitY; var directionUp = Vector3.TransformNormal(up, interactionLayer.World.InverseModelviewMatrix); world.RotationMatrix = Matrix4X4.LookAt(Vector3.Zero, directionForward, directionUp) * Matrix4X4.CreateScale(.8); GLHelper.SetGlContext(world, screenSpaceBounds, lighting); GLHelper.Render(cube, Color.White, Matrix4X4.Identity, RenderTypes.Shaded); GLHelper.UnsetGlContext(); base.OnDraw(graphics2D); }
/// <summary> /// Add your game rendering code here. /// </summary> /// <param name="e">Contains timing information.</param> /// <remarks>There is no need to call the base implementation.</remarks> protected override void OnRenderFrame(FrameEventArgs e) { GL.Clear(ClearBufferMask.ColorBufferBit); //GL.Enable(EnableCap.Blend); //GL.Enable(EnableCap.PolygonSmooth); //GL.Disable(EnableCap.DepthTest); //glEnable(GL_BLEND); //glEnable(GL_POLYGON_SMOOTH); //glDisable(GL_DEPTH_TEST); GL.Begin(BeginMode.Triangles); GLHelper.Color3(PixelFarm.Drawing.Conv.ToColor(Color.MidnightBlue)); GL.Vertex2(-1.0f, 1.0f); GLHelper.Color3(PixelFarm.Drawing.Conv.ToColor(Color.SpringGreen)); GL.Vertex2(0.0f, -1.0f); GLHelper.Color3(PixelFarm.Drawing.Conv.ToColor(Color.Ivory)); GL.Vertex2(1.0f, 1.0f); GL.End(); this.SwapBuffers(); }