Results 1 to 4 of 4

Thread: Plotting Pixels--how?

  1. #1

    Plotting Pixels--how?

    Is there a simple command, like PlotPixel(x,y,color) in OpenGL? Or do I need to load as a textrue?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Dunblane, Scotland

    Re: Plotting Pixels--how?

    Use glVertex in orthographic projection or use glDrawPixels(x,y); use glColor to set the color. I havn't actualy used glDrawPixels but I will any day now.

    Reality is for idiots only the best over come it!

  3. #3

    Re: Plotting Pixels--how?

    It took me a while, but I finally figured out
    how to write individual pixels to the framebuffer. glDrawPixels is nice, but its slow, and you can't control each and every pixel. Doing it the following way overcomes that problem:

    BYTE *aBitmap = some bitmap data;

    for (y=0.0;y<128.0;y=y+1) {
    for (x=0.0;x<256.0;x=x+1) {
    glColor3f((float)((float)aBitmap[index+2]/255.0), (float)((float)aBitmap[index+1]/255.0), (float)((float)aBitmap[index]/255.0));
    // calculate the index for an x and y.
    index = ((int)x + ((int)y * 256)) * 3;

    This is for a 256X128 texutre at 24 bit
    resolution, hence the need to step by three bytes everytime. Hope this helps... it sure helps me.

  4. #4

    Re: Plotting Pixels--how?

    A couple things I forgot to metion:
    (1) the image data is in BGR format, that is
    blue byte, green byte, red byte.

    (2) the x * .999, and y * .999 is required on
    at least my 3d card in order to keep the
    vertices packed together (no spaces).

    Let me know if anyone can find a way to speed this up.

Similar Threads

  1. 3d plotting
    By gezpu in forum OpenGL: General
    Replies: 1
    Last Post: 10-04-2010, 12:05 PM
  2. Trajectory Plotting
    By NoLowFat in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-25-2006, 08:25 PM
  3. 3D Function Plotting
    By gr00vy in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-21-2005, 10:35 AM
  4. Plotting surfaces
    By raijinken in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-20-2004, 06:56 AM
  5. Plotting using OpenGL
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-28-2003, 06:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean