I have asked this question on the Eiffel newsgroup but I was hoping a c-expert 
could see my error.  There are two routines here.  The first is a function that 
returns a pointer to a PIXELFORMATDESCRIPTOR typecast to a type an eiffel 
system can understand (I think).

The second is the one giving the segmentation violation.  It is supposed to set 
up a rendering context for openGL.  If we asssume the arguments are typecast 
correctly, is there an obviouse problem with the pointers.  I don't use c much 
and do not understand the pointers and dereferencing and type casting.

I am trying to follow (and twist it into an Eiffel system) the example given at

http://www.nullterminator.net/opengl32.html

Thanks,

jjj


static EIF_POINTER inline_F2022_28287 (void)
{
  PIXELFORMATDESCRIPTOR *pfd;
  size_t n;
  n = sizeof (PIXELFORMATDESCRIPTOR);
  pfd = (PIXELFORMATDESCRIPTOR *) calloc (1, n);
  ZeroMemory (pfd, n);
  pfd->nSize = n;
  pfd->nVersion = 1;
  pfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
  pfd->iPixelType = PFD_TYPE_RGBA;
  pfd->cColorBits = 24;
  pfd->cDepthBits = 16;
  pfd->iLayerType = PFD_MAIN_PLANE;
  return (EIF_POINTER) pfd;
;

static void inline_F2022_28290 (EIF_POINTER arg1, EIF_POINTER arg2)
{
  HGLRC *hRC;
  PIXELFORMATDESCRIPTOR *ppfd;
  HDC *hDC;
  int iFormat;
  ppfd = (PIXELFORMATDESCRIPTOR *) arg2;
  hDC = (HDC *) arg1;
  iFormat = ChoosePixelFormat (*hDC, ppfd);
  SetPixelFormat (*hDC, iFormat, ppfd);
  *hRC = wglCreateContext (*hDC);
  wglMakeCurrent (*hDC, *hRC);
;
}

Reply via email to