> You can assign dbuf->write to whatever you want, regardless of the
> pixelsize or color depth (which need not be the same), and you
> don't have to write exactly one pixel at a time if you don't want
> to.

But it looks like there is some strange behavior, that leads me to the
result that it's important what typ is asigned.

> The format of the direct buffer is specified by the 'layout' and 'buffer'
> fields in the ggi_directbuffer struct.

Yes, I read that in the ggi-api docu.

> In most cases you can access the framebuffer in whatever way you want,
> but check the 'noaccess' and 'align' members of ggi_directbuffer to be
> sure. Also note that 'align' only tells you about restrictions the
> graphics card may impose, modern CPUs will take a large performance
> hit if you do unaligned 16-, 32-, or 64-bit accesses, and many of
> them does not allow it at all.

I have a Matrox Milenium, there are no restrictions with this card
acording to align and noacces.

> pixelvalue for any mode. You assign it just like you asign any other
> integer:
> 
>         void *pointer = dbuf->write;
>         ggi_pixel pix;
> 
>         *(uint8*)pointer = pix;
>         *(uint16*)pointer = pix;
>         *(uint32*)pointer = pix;
> 
> for 8, 16 and 32 bit pixel-sizes respectively.

But there are misterious results.

My test application should simply draw a red, green and blue color run
above each other. The color run should start at black left and end at full
color on the right side of the window.

My application only runs when uint8 or uint32 is chosen for *pixelPointer.

Using uint16 results in a segmentation fault when there is written to the
direct buffer. The same is true when I alter the slimy.c file to use
uint16 instead of uint8.

Using uint32 only displays a black window. Maybe the ggiMapColor returns
values that are not displayed.

When using uint8 only approximatly a quater of the window width but the
whole height is used by the application for painting. Same is true for the
slimy test app.

Colors are only grayscale when run with uint8 though the card should
support truecolor, X at least uses it. But this is probably because uint8
is used that means 256 colors available.

All versions get a segmentation fault when ggiClose is called under the X
target.
If run under kgicon there is no seg. fault; same situation with slimy.c .

When I use XGGI running on kgicon and run the blackbox window manager, I
get an endless loop after exit from blackbox that writes this on the
screen:

TERMINATING ON SIGNAL 11:

When I switch to an other virtual console and type something, the loop is
ended.

I'm using libggi 2.0.0 on a Linux 2.2.12 Pentium machine.


> You missed the documentation page?

Sorry for unclearness. I meant, did I miss a direct buffer specific
documentation like "the big GGI frame buffer programmers guide" or
thelike?
I read the ggi/gii api docu and the other files offered on the docu page.


gr. matthias

*******************************************************************

If this helps here is my test application:

#include <stdlib.h>
#include <stdio.h>
#include <ggi/ggi.h>

const ggi_directbuffer *directBuffer;
ggi_visual_t visual;

void fail( char *reason )
{
  fprintf( stderr, "%s", reason ); 
  if ( visual != NULL )
    {
      ggiClose( visual );
      ggiExit();
    }

  exit(1); 
}

void setGraphics( void );

int main( int argc, char *argv[] )
{
  uint16 x, y, stride;
  ggi_mode mode;
  ggi_pixel pixelValue; // *pixelPointer; 
  ggi_color colour;
  uint8 *pixelPointer;

  visual = NULL;

  if ( ggiInit() != 0 )
    {
      ggiPanic( "Fatal error: Couldnt initialize GGI!\n" );
    }

  if ( ( visual = ggiOpen( NULL ) ) == NULL )
    {
      ggiPanic( "Fatal error: Couldnt open visual!\n" );
    }

  setGraphics();

  if ( ggiResourceAcquire( directBuffer->resource, GGI_ACTYPE_WRITE ) != 0
)
    {
      fail( "Error acquiring DirectBuffer\n" );
    }
  pixelPointer = directBuffer->write;

  stride = directBuffer->buffer.plb.stride;

  for ( y = 0; y < 85; y++ )
    {
      for ( x = 0; x < 256; x++ )
        {
          //colour.r = x;
          //colour.g = 0;
          //colour.b = 0;
          //pixelValue = ggiMapColor( visual, &colour );

          *(uint8 *)pixelPointer++ = x;
        }
      pixelPointer += stride - mode.virt.x;
    }
  for ( y = 0; y < 85; y++ )
    {
      for ( x = 0; x < 256; x++ )
        {
          //colour.r = 0;
          //colour.g = x;
          //colour.b = 0;
          //pixelValue = ggiMapColor( visual, &colour );

          *(uint8 *)pixelPointer++ = x;
        }
      pixelPointer += stride - mode.virt.x;
    }
  for ( y = 0; y < 85; y++ )
    {
      for ( x = 0; x < 256; x++ )
        {
          //colour.r = 0;
          //colour.g = 0;
          //colour.b = x;
          //pixelValue = ggiMapColor( visual, &colour );

          *(uint8 *)pixelPointer++ = 2 * x;
        }
      pixelPointer += stride - mode.virt.x;
    }

  ggiResourceRelease( directBuffer->resource );

  ggiFlush( visual );

  ggiGetc( visual );

  if ( ggiClose( visual ) != 0 )
    {
      ggiPanic( "error: Couldnt close visual!\n" );
    }

  if ( ggiExit() != 0 )
    {
      ggiPanic( "error in leaving GGI!\n" );
    }
  return 0;
}

void setGraphics( void )
{
  int x,y;
  int i;
  ggi_color colour;
  ggi_mode *mode = (ggi_mode *)malloc( sizeof( ggi_mode ) );

  mode->frames = 1;
  mode->visible.x = 256;
  mode->visible.y = 255;
  mode->virt.x = mode->visible.x;
  mode->virt.y = mode->visible.y;
  mode->size.x = mode->size.y = 0;
  mode->graphtype = GT_32BIT;
  mode->dpp.x = mode->dpp.y = 1;

  ggiSetFlags( visual, GGIFLAG_ASYNC );

  ggiCheckMode( visual, mode );

  ggiSetMode( visual, mode );

  if ( ggiDBGetNumBuffers( visual ) == 0 )
    {
      fail( "Number of direct buffers equals zero!\n" );
    }

  if ( ( directBuffer = ggiDBGetBuffer ( visual, 0 ) ) == NULL )
    {
      fail( "No DirectBuffer available.\n" );
    }
  
  if ( ( directBuffer->type & GGI_DB_SIMPLE_PLB ) == 0 )
    {
      fail( "Error: non-standard display buffer\n" );
    }

  for( i = 0; i < 256; i++ )
    {
      colour.r = i;
      colour.g = 0;
      colour.b = 0;
      ggiSetPalette( visual, i, 1, &colour );
    }
  for( i = 0; i < 256; i++ )
    {
      colour.r = 0;
      colour.g = i;
      colour.b = 0;
      ggiSetPalette( visual, i + 256, 1, &colour );
    }
  for( i = 0; i < 256; i++ )
    {
      colour.r = 0;
      colour.g = 0;
      colour.b = i;
      ggiSetPalette( visual, i + 512, 1, &colour );
      }
}

Reply via email to