Drawing text clears pixels set by DrawPixels
- Dominant language
- C#
- Stars
- 804
- Forks
- 294
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 1
Description
I am having a problem using DrawPixels and Drawing text on the same "surface".
I have an OpenGLControl set up to show "static", randomly set pixels shown using DrawPixels in the OpenGLDraw event. If I have DrawFPS set to true, OR if I use DrawText in the same method handler, all the "static" pixels disappear and the text is shown instead. Am I doing something wrong? Is there another way to handle this? Is this behavior by design?
I have included my method below. It shows "static" properly if DrawFPS is set to false. If set to true OR if I uncomment the DrawText, there is no "static", just the drawn text and/or the FPS.
`
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs args)
{
RGBType[] pixels = new RGBType[640 * 480];
GCHandle handle = GCHandle.Alloc(pixels, GCHandleType.Pinned);
Random rndm = new Random();
try
{
IntPtr ptr = handle.AddrOfPinnedObject();
OpenGL gl = openGLControl.OpenGL;
gl.ClearColor(0, 0, 0, 0);
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT);
for (int i = 0; i < 640 * 480; i++)
{
byte temp = (byte)rndm.Next(255);
pixels[i].r = temp;
pixels[i].g = temp;
pixels[i].b = temp;
}
gl.DrawPixels(640, 480, OpenGL.GL_RGB, OpenGL.GL_BYTE, ptr);
int x = rndm.Next(580);
int y = rndm.Next(470);
//gl.DrawText(x, y, 1.0f, 1.0f, 1.0f, "Arial", 12.0f, " Signal Mising! Press F9");
}
finally
{
if (handle.IsAllocated)
handle.Free();
}
}
`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.