Login Page - Create Account

Support Board


Date/Time: Wed, 04 Dec 2024 19:42:26 +0000



[Programming Help] - Graphics.DrawPolygon with OpenGL enabled only draws polygons with less than 4 points

View Count: 96

[2024-11-17 05:16:03]
User806065 - Posts: 2
Hi, I had to enabled OpenGL in order for my project to render properly because I was facing issues with the GraphicsBrush not resetting properly. However, once OpenGL is enabled, the DrawPolygon function will no longer work for polygons with more than 4 points. It's very frustrating to work with. If I have OpenGL disabled, then my shapes are rendered properly, but I have no way of changing the brush. If I have OpenGL enabled, my shapes don't render at all, but I've confirmed that the brush changes correctly.

void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc)
{
  n_ACSIL::s_GraphicsBrush GraphicsBrush;
  GraphicsBrush.m_BrushType = n_ACSIL::s_GraphicsBrush::BRUSH_TYPE_SOLID;
  GraphicsBrush.m_BrushColor.SetColorValue(COLOR_BLUE);
  sc.Graphics.SetBrush(GraphicsBrush);

n_ACSIL::s_GraphicsPen GraphicsPen;
GraphicsPen.m_PenStyle = n_ACSIL::s_GraphicsPen::e_PenStyle::PEN_STYLE_SOLID;
GraphicsPen.m_Width = 2;
  GraphicsPen.m_PenColor.SetColorValue(COLOR_BLUE);
  sc.Graphics.SetPen(GraphicsPen);
  
  n_ACSIL::s_GraphicsPoint polygon1[4];
  n_ACSIL::s_GraphicsPoint polygon2[5]; // only plots polygons with 4 points or less
  
  polygon1[0].X = 0;
  polygon1[0].Y = 0;
  
  polygon1[1].X = 100;
  polygon1[1].Y = 0;
  
  polygon1[2].X = 100;
  polygon1[2].Y = 100;
  
  polygon1[3].X = 0;
  polygon1[3].Y = 100;
  
  polygon2[0].X = 100;
  polygon2[0].Y = 100;
  
  polygon2[1].X = 200;
  polygon2[1].Y = 100;
  
  polygon2[2].X = 200;
  polygon2[2].Y = 200;
  
  polygon2[3].X = 150;
  polygon2[3].Y = 200;
  
  polygon2[4].X = 100; // when these lines are uncommented, the second polygon does not show up on the chart
  polygon2[4].Y = 250;
  
  sc.Graphics.DrawPolygon(polygon1);
  sc.Graphics.DrawPolygon(polygon2);
  
  sc.Graphics.ResetBrush();
sc.Graphics.ResetPen();
}

I made this little snippet to test my issue. With OpenGL disabled, the five-sided polygon will render, but with OpenGL enabled it will not. Any help would be appreciated. Thank you.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account