PDA

View Full Version : Emulating Writing on Surface



Arnab
09-03-2008, 02:33 AM
Hi all

I'm interested in emulating writing on a surface. My current idea:

i) map a blank texture onto a plane
ii)use a mouse to explore the surface
iii) where the mouse is (when button pressed), the pixel on the surface will be changed to a chosen colour.

Questions:

i) is this possible?
ii) is there such thing as a canvas in openGL?
iii) any suggestions on how I can achieve this?

Regards

Zengar
09-03-2008, 03:36 AM
Can you explain what "emulating writing on a surface" means? And what do you mean by "canvas"?

Nighthawk
09-03-2008, 03:53 AM
You can can change rectanglular areas of an existing texture via glTexSubImage2D(), even single pixels.

So just update the texel where the mouse cursor is. The texel coordinate you have to calculate yourself, OpenGL won't do it for you.

But i'm not sure if i understood the question...

Arnab
09-03-2008, 06:03 AM
Its actually similar to paint applications. You can free write on the screen.

I just want to create a simple application that can write something on a plane by using mouse interaction.

Zengar
09-03-2008, 06:05 AM
In this case I would "draw" on a texture and submit the dirty regions via TexSubImage and subsequently displaying the texture on the screen.

Arnab
09-03-2008, 06:08 AM
What parameters does texsubimage take? Coordinates?

Nighthawk
09-03-2008, 06:45 AM
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/texsubimage2d.html

The x/y-offsets are ints.

Arnab
09-03-2008, 06:58 AM
i shall give it a try but I'm still new in textures :(