How to eliminate a hidden line?

i am doing a cad program which the user can draw a line interactively.The entire object will be redraw again every time i draw a line.But when the number of object is too big the program start to run slowly
I think its something related to the Depth Test and GlDepthFunc() but i don’t know how to do it .
Beside that i would like to know why autocad can run smoothly even thought when we are drawing a complicated object (meaning that many points and lines)
Hope someone can help.

ARB_buffer_region
KTX_buffer_region

to save the background is one quick way.

Thanks for your help but can you tell me which function to call ARB_BUFFER_REGION and how to use it.Do u have any example or which homepage to get this example.

With ARB_buffer_region, the needed parts are

#include <GL/wglext.h>

//We need this
HANDLE HandleToBufferRegion;

//First must create a handle to region
wglCreateBufferRegionARB(hdc, 0, WGL_BACK_COLOR_BUFFER_BIT_ARB | WGL_DEPTH_BUFFER_BIT_ARB);

//For saving the region
wglSaveBufferRegionARB(HandleToBufferRegion, 0, 0, (int)Width, (int)Height);

//For restoring the region
wglRestoreBufferRegionARB(HandleToBufferRegion,
0, 0, //x=0 y=0 lower left corner of the window
(int)Width, (int)Height, //width and height of area to copy
0, 0); //x and y position in buffer region

//To destroy (free video memory)
if(HandleToBufferRegion)
glExtDestroyBufferRegionARB(HandleToBufferRegion);

[This message has been edited by V-man (edited 12-20-2002).]

Originally posted by V-man:
[b]With ARB_buffer_region, the needed parts are

#include <GL/wglext.h>

//We need this
HANDLE HandleToBufferRegion;

//First must create a handle to region
wglCreateBufferRegionARB(hdc, 0, WGL_BACK_COLOR_BUFFER_BIT_ARB | WGL_DEPTH_BUFFER_BIT_ARB);

//For saving the region
wglSaveBufferRegionARB(HandleToBufferRegion, 0, 0, (int)Width, (int)Height);

//For restoring the region
wglRestoreBufferRegionARB(HandleToBufferRegion,
0, 0, //x=0 y=0 lower left corner of the window
(int)Width, (int)Height, //width and height of area to copy
0, 0); //x and y position in buffer region

//To destroy (free video memory)
if(HandleToBufferRegion)
glExtDestroyBufferRegionARB(HandleToBufferRegion);

[This message has been edited by V-man (edited 12-20-2002).][/b]

ARB_buffer_region can works well but the problem is not everyone’s computer have Geforce(display card), i try to use autocad and it runs smoothly even in a computer that doesn’t has graphic card. I try to use glReadPixel and glDrawPixel here is my code

unsigned char *colorSave;

void CSbomView::SaveCurrentView(int index)
{
int port[4];
glGetIntegerv(GL_VIEWPORT,port);

if(colorSave != NULL)
    free(colorSave);

colorSave = (unsigned char*)malloc(port[2] * port[3] * 4 * sizeof(unsigned char));


glReadPixels(port[0],port[1], port[2],port[3], GL_BGR_EXT , GL_UNSIGNED_BYTE,
    colorSave);

}

void CSbomView::RestoreCurrentView(int index)
{
int port[4];
glGetIntegerv(GL_VIEWPORT,port);

GLint	previousColorBuffer;

glPushMatrix();
glLoadIdentity();

if(port[2]&lt;=port[3])
	glRasterPos3f(-SIZE, -SIZE* (GLfloat)port[3] / (GLfloat)port[2], 0);
else
	glRasterPos3f(-SIZE*(GLfloat)port[2]/(GLfloat)port[3], -SIZE, 0);

glDisable(GL_DEPTH_TEST);
glDisable(GL_STENCIL_TEST);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glGetIntegerv(GL_DRAW_BUFFER, &previousColorBuffer);
glDrawBuffer(GL_BACK);
glDrawPixels(port[2], port[3], GL_BGR_EXT , GL_UNSIGNED_BYTE, colorSave);
glDrawBuffer(previousColorBuffer);
glEnable(GL_DEPTH_TEST);  

glPopMatrix();

}
this code work well in Geforce, but very bad in Onboard display card.
can you please show me which part i am wrong and please suggest any efficient way that can apply in any computer that doesn’t has a graphic card. Thanks

“this code work well in Geforce, but very bad in Onboard display card.”

There was a recent discussion about this kind of thing.
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/009694.html

I think those onboard solutions (Intel?) are not suitable for 3D. A Gf2MX is ~50$ by now.

autocad and a software call ac3d (www.ac3d.org), they can restore background very fast even in Onboard display card. Do you think they use Opengl or Direct3d?if they r using OpenGl, how they do it? use glDrawPixels or have altenative way?

Is it using a texture is faster than glDrawPixels?

Please help me ! Thanks

Originally posted by V-man:
[b]“this code work well in Geforce, but very bad in Onboard display card.”

There was a recent discussion about this kind of thing.
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/009694.html

I think those onboard solutions (Intel?) are not suitable for 3D. A Gf2MX is ~50$ by now.

[/b]

static GLuint texName;

void CSbomView::SaveCurrentLamaView(int index)
{
int port[4];
glGetIntegerv(GL_VIEWPORT,port);

if(colorSave != NULL)
    free(colorSave);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

// glPixelStorei(GL_PACK_ALIGNMENT, 1);
// glReadBuffer(GL_BACK);

colorSave = (unsigned char*)malloc(port[2] * port[3] * 4 * sizeof(unsigned char));

glReadPixels(port[0],port[1], port[2],port[3], GL_RGB , GL_UNSIGNED_BYTE,
    colorSave);

glGenTextures(1,&texName);
glBindTexture(GL_TEXTURE_2D,texName);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,port[2],port[3],0,GL_RGB,GL_UNSIGNED_BYTE,colorSave);

}

void CSbomView::RestoreCurrentlamaView(int index)
{
int port[4];
glGetIntegerv(GL_VIEWPORT,port);

GLint	previousColorBuffer;

glPushMatrix();
glLoadIdentity();

glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,texName);

if(port[2]&gt;port[3]){
	glBegin(GL_POLYGON);
	glTexCoord2f(0.0, 0.0);glVertex3f( -SIZE* (GLfloat)port[2] / (GLfloat)port[3], -SIZE, 0);
	glTexCoord2f(1.0, 0.0);glVertex3f(  SIZE* (GLfloat)port[2] / (GLfloat)port[3], -SIZE, 0);
	glTexCoord2f(1.0, 1.0);glVertex3f(  SIZE* (GLfloat)port[2] / (GLfloat)port[3], SIZE, 0);
	glTexCoord2f(0.0, 1.0);glVertex3f( -SIZE* (GLfloat)port[2] / (GLfloat)port[3], SIZE,0);
	glEnd();
}
else {
	glBegin(GL_QUADS);
	glTexCoord2f(0.0, 0.0);glVertex3f( -SIZE, -SIZE* (GLfloat)port[3] / (GLfloat)port[2], 0);
	glTexCoord2f(1.0, 0.0);glVertex3f( -SIZE, SIZE* (GLfloat)port[3] / (GLfloat)port[2], 0);
	glTexCoord2f(1.0, 1.0);glVertex3f(  SIZE, SIZE* (GLfloat)port[3] / (GLfloat)port[2], 0);
	glTexCoord2f(0.0, 1.0);glVertex3f(	SIZE, -SIZE* (GLfloat)port[3] / (GLfloat)port[2], 0);
	glEnd();
}

glFlush();
glDisable(GL_TEXTURE_2D);

glPopMatrix();

}
Can you check the code please, why my texture just blank. Thanks

port[2] and port[3] are probably no power-of-two values.

[This message has been edited by Relic (edited 06-12-2003).]

Originally posted by Relic:
[b]port[2] and port[3] are probably no power-of-two values.

[This message has been edited by Relic (edited 06-12-2003).][/b]

my screen size is not always power of 2 size, i don’t know how to make it to power of 2 size, is it use glTexSubImage2D? Can you just edit the code segment that i have submit. thanks

No, I thought you get paid for this. Remember this is an “OpenGL coding: advanced” forum.

Originally posted by Relic:
No, I thought you get paid for this. Remember this is an “OpenGL coding: advanced” forum.

Relic, i know its just a simple question, but i need to know it urgent! The reason i ask the question here is i know there are many expert in advance forum. Since i have create a topic in advance forum and i am not going to ask the same question in beginner forum now to avoid duplicate question. Can anyone tell me how to save the background (in any width and height which is not power of 2)in a texture.
Can someone just correct the code that i have summit above. Thanks in advance