Hi, I’m working on a project that will streamline dynamic pharmacy label printouts. The way my company designs them currently is in HP/GL2 and PCL. That’s very archaic and restrictive.
I have built a program in C# that loads in the source code, parses it and displays it in an OpenGL environment to the screen to preview it before sending it to the printer.
Unfortunately, every time the user clicks over to the preview tab from another tab the mem usage goes up. I’ve been looking all over for a way to get rid of this problem, but I can’t find a good way to remove the old resources instead of just piling up on top of the old.
public void glDrawCube()// To be in OpenGL style it I gave it a gl prefix
{
Texture = new OpenGLTexture2D(textureref);
GL.glTranslatef(-1.0f, -1.0f, fViewPort); // viewport = 0 0 0 and this is 6 deep
if (bRotateCheck == true)
{
GL.glRotatef(fRotate, 1.0f, 1.0f, 1.0f);
}
if (Form1.Stock == "Small")
{
Texture.Bind();
GL.glBegin(GL.GL_QUADS);// start drawing the cube
GL.glColor3fv(fColor); // Color with an array of floats
//Draw the front (only) face of the square
//top right
GL.glVertex3f(fPlusPosition - 0.05f, fPlusPosition + 0.7f, fPlusPosition);
GL.glTexCoord2f(0.0f, 1.0f);
//top left
GL.glVertex3f(fMinusPosition + 0.35f, fPlusPosition + 0.7f, fPlusPosition);
GL.glTexCoord2f(0.0f, 0.0f);
//bottom left
GL.glVertex3f(fMinusPosition + 0.35f, fMinusPosition - 0.4f, fPlusPosition);
GL.glTexCoord2f(1.0f, 0.0f);
//bottom right
GL.glVertex3f(fPlusPosition - 0.05f, fMinusPosition - 0.4f, fPlusPosition);
GL.glTexCoord2f(1.0f, 1.0f);
GL.glEnd();// end drawing the cube
if (bRotateCheck == true)
{
fRotate += 2.5f;
}
}
else
{
Texture.Bind();
GL.glBegin(GL.GL_QUADS);// start drawing the cube
GL.glColor3fv(fColor); // Color with an array of floats
//Draw the front (only) face of the square
//top right
GL.glVertex3f(fPlusPosition + 0.1f, fPlusPosition + 0.5f, fPlusPosition);
GL.glTexCoord2f(0.0f, 1.0f);
//top left
GL.glVertex3f(fMinusPosition + 0.3f, fPlusPosition + 0.5f, fPlusPosition);
GL.glTexCoord2f(0.0f, 0.0f);
//bottom left
GL.glVertex3f(fMinusPosition + 0.3f, fMinusPosition - 0.1f, fPlusPosition);
GL.glTexCoord2f(1.0f, 0.0f);
//bottom right
GL.glVertex3f(fPlusPosition + 0.1f, fMinusPosition - 0.1f, fPlusPosition);
GL.glTexCoord2f(1.0f, 1.0f);
GL.glEnd();// end drawing the square
if (bRotateCheck == true)
{
fRotate += 2.5f;
}
}
}
This is the method that creates a square and textures the base image onto it. I was wondering if there’s a better way to do this, or if there’s a way to clean up any old resources before displaying the new instance of it?
Thanks.