You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm already sure I'm doing something stupidly wrong, but this is extremely frustrating since I cannot locate the issue.
Basically I'm trying to draw ANYTHING using this Draw() method:
public const float lim = 1000;
private void Draw(object sender, OpenGLRoutedEventArgs args)
{
var gl = args.OpenGL;
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.LoadIdentity();
gl.LineWidth(10.0f);
gl.PointSize(2.0f);
gl.Color(1, 1, 1);
// y axis
gl.Begin(BeginMode.Lines);
gl.Vertex(-lim, 0);
gl.Vertex(lim, 0);
gl.End();
// x axis
gl.Begin(BeginMode.Lines);
gl.Vertex(0, -lim);
gl.Vertex(0, lim);
gl.End();
for (int i = 0; i < 500; i++)
{
gl.Begin(BeginMode.TriangleFan);
var Segments = 50;
var radius = 1000;
var Position = new Vector2(i, i);
for (var a = 0; a < Segments; a++)
{
float theta = 2f * MathF.PI * a / Segments;
float x = radius * MathF.Sin(theta);
float y = radius * MathF.Cos(theta);
gl.Vertex(Position.X + x, Position.Y + y);
}
gl.End();
}
gl.Flush();
}
But I'm only ever getting a black screen (with the FPS counter working fine).
I've tried comparing my code to this sample, but I really cannot find the problem.
As you can see from the code, I have already made desperate, frustrated attempts to draw large cirlces ANYWHERE, with no success whatsoever.
What am I missing?
The text was updated successfully, but these errors were encountered:
I have the exact same problem. It looks like none of gl.Draw* (* <- Elements, Arrays etc) functions have any effect. I've already checked the VAOs, VBOs and textures.
Tested using WPF, TargetFramework: net8.0-windows
I've also noticed that OpenGL generates InvalidOperation error before each draw call.
Suppose this method is called each time OpenGLDraw event is raised for OpenGLControl.
private void DicomGLViewer_OpenGLDraw(object sender, OpenGLRoutedEventArgs args)
{
if (GL is not null) OpenGLHelpers.ThrowIfGLError(GL);
//while (gl.GetErrorCode() is not ErrorCode.NoError);
GL?.Clear(OpenGL.GL_COLOR_BUFFER_BIT);
glState?.DrawVertices(CurrentDepth);
}
And ThrowIfGLError looks like this:
public static class OpenGLHelpers
{
...
public static void ThrowIfGLError(OpenGL gl)
{
var error = gl.GetErrorCode();
switch (error)
{
case ErrorCode.NoError:
break;
case (var other):
throw new Exception(gl.GetErrorDescription(Convert.ToUInt32(other)));
}
}
}
It throws with 'Invalid Operation' OpenGL error
So this error occurs before doing anything.
My opengl initialization (after OpenGLInitialized event) doesn't produce any errors, so this is quite strange.
Hello,
I'm already sure I'm doing something stupidly wrong, but this is extremely frustrating since I cannot locate the issue.
Basically I'm trying to draw ANYTHING using this
Draw()
method:But I'm only ever getting a black screen (with the FPS counter working fine).
I've tried comparing my code to this sample, but I really cannot find the problem.
As you can see from the code, I have already made desperate, frustrated attempts to draw large cirlces ANYWHERE, with no success whatsoever.
What am I missing?
The text was updated successfully, but these errors were encountered: