PDA

View Full Version : How can i clip this?



Hideki
04-12-2004, 09:48 AM
Hi guys, my first post here.

I just wanna know if someone can help me with this problem.

i did a graphic software where users give 2 arrays and a curve with its axis are drown.

The problem is when i do a zoom, some lines are out from the graphic, i want to make them invisible. I tried gl_clip_plane but didnt work. Can someone help me?

thanks

Hideki
04-12-2004, 10:06 AM
the images show what im trying to say =)

http://www.emorock.net/hidekiemo/img1.gif

http://www.emorock.net/hidekiemo/img2.gif

chowe6685
04-12-2004, 10:37 AM
look at glScissor

Hideki
04-12-2004, 11:07 AM
chowe6685, thanks for the help.

bu im still having problems ..
when im enable the GL_SCISSOR_TEST , everything between the enable and disable disappear ... dont understand =(

i give the coordenates to glScissor() but .. everything disappear

chowe6685
04-12-2004, 12:13 PM
could you post some code?

Hideki
04-13-2004, 08:09 AM
look this

glEnable(GL_SCISSOR_TEST);
glScissor(-30,50,0,0);
glBegin(GL_LINES);
glVertex2d(-50,800);
glVertex2d(100,0);
glEnd();
glDisable(GL_SCISSOR_TEST);

everything dissapear .... even i cut out glScisor everything disappear from the screen

chowe6685
04-13-2004, 08:32 AM
look at the definition for glScissor
http://www.mevis.de/~uwe/opengl/glScissor.html
the second pair of parameters is the height and width, not more coordinates

dvm
04-13-2004, 08:32 AM
Just a small idea, nothing fancy. If you can find exactly where the dots end (the size of the graph) maybe you can super-impose (draw in front of it) four quads in white, around the graph. I'm currenttly having a look at OpenGL gmae programming and another answer comes right up, using cutting planes.
---
Ok here comes the improved version.
First you draw your graph as usual.
Then you set the draw buffer to GL_NONE and draw a quad exactly over the graph (bring it a little closer to draw over the graph) with an equal size.
Then reset the buffer to GL_BACK and draw a bigger quad in white that should cover the whole screen.
If all goes well you should have clipped the graph the way you want to.
Code follows:

DrawGraph();
glDrawBuffer(GL_NONE);
glRecti(-50, -50, 50, 50); //insert the dimensions of the zoomed graph here.
//Might also want to use begin-end instead of glRect*.
glDrawBuffer(GL_BACK);
glRecti(-500, -500, 500, 500); // the dimensions might be a bit over the top, but you get the point.Hope that helps!

Hideki
04-13-2004, 09:09 AM
chowe6685
hrrrmm what i understoo is that the first 2 parameters are the initial point of the box and the other 2 are the final points of the box ... then opengl makes a rect and cut what is inside of it ... isnt it?? but not working =(

moucard
heh your idea can help too .. the second glRecti i have to use it four times yep?? to make 4 rects out from the graph ... i didnt understand why we want the first glRecti ....

thanks

dvm
04-13-2004, 09:25 AM
Well the idea is that by rendering the first recti with GL_NONE as the buffer, it would create a cutting plane; let you see through the bigger quad, so you wouldn't have to draw four quads. The thing is I just tried the idea from the book and I can't make it work. I don't know what's going on. Is it me is it my hardware (probably me, as usual). If I find a solution to this I'll let you know.

Hideki
04-13-2004, 09:31 AM
ah hehe .. =P

so the first recti i put the minimum and maximum of the graph

and the other i put what??
you said
// the dimensions might be a bit over the top, but you get the point.

Deiussum
04-13-2004, 10:54 AM
Originally posted by Hideki:
chowe6685
hrrrmm what i understoo is that the first 2 parameters are the initial point of the box and the other 2 are the final points of the box ... then opengl makes a rect and cut what is inside of it ... isnt it?? but not working =(

Here's from the link that chowe posted:


void glScissor(GLint x,
GLint y,
GLsizei width,
GLsizei height)
It's usually a good idea to actually look at the function spec before making assumptions about what the parameters mean. You know what they say about assumptions, don't you?

Hideki
04-13-2004, 11:07 AM
width, height
Specify the width and height of the scissor box. When a GL context is first attached to a window, width and height are set to the dimensions of that window.

i read that .... the problem is that they dont explain clearly ... width of the scissor box ...for its mean the width like html images and then .... but no ... you dont where the scissor start ...

example: i put glScissor(-40,0,500,800);
it drew the graph from point -40,0 until 57,410
..........................................

Deiussum
04-13-2004, 12:17 PM
Again, I'm finding myself cutting and pasting from chowe's link...



The glScissor function defines a rectangle, called the scissor box, in window coordinates. The first two parameters, x and y, specify the lower-left corner of the box. The width and height parameters specify the width and height of the box.
Window coordinates are based on pixels of the window. For OpenGL window coordinates, 0,0 is the lower left. You seem to be expecting it to be in scene coordinates, which is a totally different concept.