Emulating Writing on Surface

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

Can you explain what “emulating writing on a surface” means? And what do you mean by “canvas”?

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…

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.

In this case I would “draw” on a texture and submit the dirty regions via TexSubImage and subsequently displaying the texture on the screen.

What parameters does texsubimage take? Coordinates?

http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/texsubimage2d.html

The x/y-offsets are ints.

i shall give it a try but I’m still new in textures :frowning: