glDrawPixels

Why doesn’t this create a red square

void makeImage(void){
        int a,b;
        for(a=0;a<99;a++){
                for(b=0;b<99;b++){
                        rasters[a][b][0]=1;
                        rasters[a][b][1]=0;
                        rasters[a][b][2]=0;
                }
        }
}

here is the glDrawPixels function

  glDrawPixels(100,100,GL_RGB,GL_UNSIGNED_BYTE,rasters);

Try this instead:

void makeImage(void){
        int a,b;
        for(a=0;a<99;a++){
                for(b=0;b<99;b++){
                        rasters[a][b][0]=0xff;
                        rasters[a][b][1]=0;
                        rasters[a][b][2]=0;
                }
        }
}

Hi !

You do get a red square, it’s just very little red :cool: each byte has a value between 0-255 so the example above should give you a very red square, 0x80 (128) a dull red square and so on.

Mikael

I still have a black screen here is my code now

GLubyte rasters[100][100][3];

void makeImage(void){
        int a,b;
        for(a=0;a<100;a++){
                for(b=0;b<100;b++){
                        rasters[a][b][0]=255;
                        rasters[a][b][1]=0;
                        rasters[a][b][2]=0;
                }
        }
}
  glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
  glDrawPixels(100,100,GL_RGB,GL_UNSIGNED_BYTE,rasters);

Hi !

Look’s ok to me, are you sure the rest of the code is correct, can you render something else ?

Mikael

I don’t know what was wrong but I retyped the whole code and now it works thanx. Do these functions ex: glDrawPixels glCopy Pixels… only work in ortho view?