PDA

View Full Version : texture , plane and a4



giuseppe500
12-03-2012, 03:16 AM
hello.
I have created a simple 3d engine for my purposes that support texture , vbo ecc....
Now I would create an opengl project that displays scanned a4 documents .
I think to use two triangles that form a rectangle , a plane, then set the scanned image as texture of the plane and send U and S coordinates in a VBO object with only vec3 position and a vec2 UV coordinates.

What are the coordinates that i should use for the plane? pixel? and what is the width and the height?
is sufficent set the width and the height of the plane as a4 for visualize an a4 at video?
and whats are the dpi ? i must take them in consideration? or are only for print?
Thanks.

tonyo_au
12-03-2012, 04:59 AM
If you want it at full size you will need to get the dpi of the screen (usually 96 but it doesn't have to be) and size a window to match an A4 doc; then use an ortho projection (glOrtho) to define the camera projection; the UV will be 0-1 and
render a quad the size of the window.

You should note that this not print quality - a printer will be 600-2400dpi.

giuseppe500
12-03-2012, 06:16 AM
thanks.
I must creating some a4 file image at hight scanner resolution, do the sobel filter in opencl, and visualize the sobel filter result in a windows of qt always in opengl.

1)Is possible do the sobel filter on a hight resolution image that comes from the scanner?
The dpi are more hight , then i can do a more precise filter.
is correct?

2)after the sobel filter i can display a texture(with the sobel filter result) in opengl at the resolution that i want, with a scale that mantains the proportions.and i use an ortho projection
is possible?

tonyo_au
12-03-2012, 08:44 PM
I don't know a lot about sobel filters other then basically how they work.
Your biggest problem with filtering a very high resolution image is that you may not be able to
allocate two texture buffers that big to do it inside OpenGL so filtering via OpenCL is probably the way to go -
you will still need 2 buffers, one to read and one to write as the filter modifies a pixel based on the surrounding pixels.

You can then scale the texture like I described which use a simply bilinear filter to render.

But you may want to look a some sort of scaling at the OpenCL phase which can obviously be more sophisticated.

In general OpenCL is designed for data manipulation whereas as OpenGL is really just for rendering.

Dark Photon
12-04-2012, 04:54 AM
Your biggest problem with filtering a very high resolution image is that you may not be able to
allocate two texture buffers that big to do it inside OpenGL so filtering via OpenCL is probably the way to go -

I would suggest implementing in pure OpenGL first (with basic shaders). Then, if you absolutely need more performance, consider use of GPU compute (GL compute shader, OpenCL, or CUDA). But be aware: it's more difficult to write GPU compute kernels well with maximal efficiency (and no bugs!).

And I would definitely opt for a GL compute shader before I'd suggest OpenCL. Last time I checked, with OpenCL you still have to resort to the glFinish() / clFinish() sledgehammer approach to synchronization (cl_khr_gl_event / ARB_cl_event not supported). But GL compute shader is in the shading language we all know and love.

tonyo_au
12-04-2012, 03:39 PM
And I would definitely opt for a GL compute shader before I'd suggest OpenCL
I agree but how stable are the 4.3 drivers?