coloring a pixel

O

osmium

unknown said:
some one can give me a portable source codes that color a pixel?
(env *nix)

The consensus meaning of "portable" means the code should compile and run on
any platform that has a standards compliant C compiler. So your question is
faulty from the get go. Try posting your question to a germane newsgroup --
people here are very reluctant to answer off-topic questions.
 
U

unknown

osmium said:
The consensus meaning of "portable" means the code should compile and run
on any platform that has a standards compliant C compiler. So your
question is
faulty from the get go. Try posting your question to a germane newsgroup
-- people here are very reluctant to answer off-topic questions.

sorry..

... ..
 
J

Jonathan Bartlett

unknown said:
some one can give me a portable source codes that color a pixel?
(env *nix)

No such thing. It depends very much on your environment, even on *nix.
Using xlib? Using SVGALib? Using OpenGL?

Jon
 
U

unknown

Jonathan said:
No such thing. It depends very much on your environment, even on *nix.
Using xlib? Using SVGALib? Using OpenGL?

using OpenGL how can i do it?
where i can found some docs about handling graphics under *nix platforms?

thanks for your support
 
T

Thomas Matthews

unknown said:
some one can give me a portable source codes that color a pixel?
(env *nix)

Well, I haven't ranted on this topic in a while so
here goes:

There is no standard for a pixel, other than the vague
definition that it is a picture element. A pixel could
be a vertical line, a dot (circle) or a vector, perhaps
even something more complex. Thus, it is not portable
already.

Not all platforms have displays. Those platforms that
have displays, may not have pixels or have access to
those pixels. Thus pixels are not portable.

For Raster display systems, pixels are usually either
dots or vertical lines (check your monitor). Here
are some varying attributes for a pixel:
dimensions (width and height, maybe depth)
black & white vs. color
discreet values vs. blends
intensity
The fact is that there is no standard for the above
attributes. Some platforms may add more attributes
to a pixel, such as blinking. Thus more reasons why
pixels are not portable.

Let us assume that a pixel can be colored. Now the
questions are:
1. How many colors?
2. Standard colors, such as cobalt blue and purple?
How does one turn a pixel "olive green" on a Windows
platform and have it the same value on a Unix machine?

Finally, let us think about the issues about additive
colors versus subtractive colors. Colors on a CRT
{Cathode Ray Tube} may not be the same as on an ink
jet printer.

The best answer for how to do graphics is to consult
the documents for your platform.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
K

Keith Thompson

Thomas Matthews said:
There is no standard for a pixel, other than the vague
definition that it is a picture element. A pixel could
be a vertical line, a dot (circle) or a vector, perhaps
even something more complex. Thus, it is not portable
already.

<OT>
I've never heard the term "pixel" used to refer to anything other than
a single dot on a display. FOLDOC defines it as "The smallest
resolvable rectangular area of an image, either on a screen or stored
in memory." (I suppose a vector-based display wouldn't have pixels as
such.)
</OT>

If you had a portable definition of some image format (say, TIFF
images), it would make sense to ask how, given that format, you can
set the color for a given pixel. But I don't think that's what the OP
was asking for -- and given the image format definition, it should be
obvious how to set a pixel.
 
J

Jason Sewall

I can't say no to an aspiring graphics guy, even it's off topic.

Go to www.opengl.org and look up the opengl reference manual there (i.e.
the "red book"). Its free to download and gaze at and it should help you
get started.

You'll probably want to look at GLUT, which is a very simple way of
making a window (and a "context") that OpenGL can use.

As for the OpenGL things you'll want to examine, there are 3 ways I can
think of "drawing a pixel" in opengl off the top of my head. You can
write straight to the framebuffer with glWritePixels(), you can draw
points with glBegin(GL_POINTS), or you can write the pixels to a texture
and display that. I've done all of these things and for your purpose, I
would probably just use glWritePixels(). It can be a little tricky to
work out the format stuff, but it's the fastest and simplest thing to do
if you don't need to use other opengl features at the same time.

As for the portability, I know that OpenGL is available for windows,
linux, and OS X. GLUT is pretty ancient and poorly maintained, but it
still works and I've gotten it to run on Windows and Linux. Good luck.

Jason
 
C

CBFalconer

Bertel said:
No, it's not possible to color pixels in portable code.

Aren't pixels those little things with wings that hide under four
leafed clovers? They certainly aren't defined in the C standard.
I always thought they were green by definition. Maybe unknown
wants them to blush about his off-topic posting.
 
J

Jonathan Bartlett

using OpenGL how can i do it?
where i can found some docs about handling graphics under *nix platforms?

Assuming you have your OpenGL context set up, you can just do

glBegin(GL_POINTS);
glVertex2d(PointX,PointY);
glEnd();

This code is a good example of how to initialize an OpenGL Window:

http://www.cs.arizona.edu/classes/cs433/spring02/opengl/code/triangle.c

Be sure to compile with at least "-lGL -lGLU -lGLUT" (you may need
others, too).

You may have to install the GLUT libraries and development environments
as not all Linux distributions come with them, even if they come w/
OpenGL (GLUT makes dealing with the windowing environment consistent and
cross-platform, which you can also do w/ SDL if you wanted to).

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top