计算机图形学基础第2版[陆枫]程序源代码


计算机图形学基础第2版[陆枫]程序源代码
资源截图
代码片段和文件信息

/* Copyright (c) Mark J. Kilgard 1994. */

/* This program is freely distributable without licensing fees 
   and is provided without guarantee or warrantee expressed or 
   implied. This program is -not- in the public domain. */

/* capturexfont.c connects to an X server and downloads a
   bitmap font from which a C source file is generated
   encoding  the font for GLUT‘s use. Example usage:
   capturexfont.c 9x15 glutBitmap9By15 > glut_9x15.c */

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define MAX_GLYPHS_PER_GRAB 512  /* This is big enough for 2^9
                                    glyph character sets */

static void
outputChar(int num int width int height
  int xoff int yoff int advance int data)
{
  if (width == 0 || height == 0) {
    printf(“#ifdef _WIN32
“);
    printf(“/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
“);
    printf(“   a height or width of zero does not advance the raster position
“);
    printf(“   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
“);
    printf(“static const GLubyte ch%ddata[] = { 0x0 };
“ num);
    printf(“static const BitmapCharRec ch%d = {“ num);
    printf(“%d“ 0);
    printf(“%d“ 0);
    printf(“%d“ xoff);
    printf(“%d“ yoff);
    printf(“%d“ advance);
    printf(“ch%ddata“ num);
    printf(“};
“);
    printf(“#else
“);
  }
  printf(“static const BitmapCharRec ch%d = {“ num);
  printf(“%d“ width);
  printf(“%d“ height);
  printf(“%d“ xoff);
  printf(“%d“ yoff);
  printf(“%d“ advance);
  if (data) {
    printf(“ch%ddata“ num);
  } else {
    printf(“0“);
  }
  printf(“};
“);
  if (width == 0 || height == 0) {
    printf(“#endif
“);
  }
  printf(“
“);
}

/* Can‘t just use isprint because it only works for the range
   of ASCII characters (ie TRUE for isascii) and capturexfont
   might be run on 16-bit fonts. */
#define PRINTABLE(ch)  (isascii(ch) ? isprint(ch) : 0)

void
captureXFont(Display * dpy Font font char *xfont char *name)
{
  int first last count;
  int cnt len;
  Pixmap offscreen;
  Window drawable;
  XFontStruct *fontinfo;
  XImage *image;
  GC xgc;
  XGCValues values;
  int width height;
  int i j k;
  XCharStruct *charinfo;
  XChar2b character;
  GLubyte *bitmapData;
  int x y;
  int spanLength;
  int charWidth charHeight maxSpanLength pixwidth;
  int grabList[MAX_GLYPHS_PER_GRAB];
  int glyphsPerGrab = MAX_GLYPHS_PER_GRAB;
  int numToGrab;
  int rows pages byte1 byte2 index;
  int nullBitmap;

  drawable = RootWindow(dpy DefaultScreen(dpy));

  fontinfo = XQueryFont(dpy font);
  pages = fontinfo->max_char_or_byte2 - fontinfo->min_char_or_byte2 + 1;
  first = (fontinfo->min_byte1 << 8) + fontinfo->min_char_or_byte2;
  last = (fontinfo->max_byte1 << 8) + fontinfo->max_char_or_byte2;
  count = last - first + 1;

  width = fontinfo->max_bounds.rbearing -
    fontinfo->min_bounds.lbearing;
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2008-11-05 11:05  OpenGL程序
     目录           0  2008-11-03 23:42  OpenGL程序OpenGL程序
     目录           0  2008-11-03 23:42  OpenGL程序OpenGL程序dll
     文件      315904  1997-11-21 17:01  OpenGL程序OpenGL程序dllglu.dll
     文件      119568  2000-01-10 12:00  OpenGL程序OpenGL程序dllglu32.dll
     文件      180224  1999-07-29 15:48  OpenGL程序OpenGL程序dllGLUT32.DLL
     文件     1214464  1997-11-21 17:01  OpenGL程序OpenGL程序dllopengl.dll
     文件      692496  2002-07-22 12:05  OpenGL程序OpenGL程序dllOPENGL32.DLL
     目录           0  2008-11-03 23:42  OpenGL程序OpenGL程序include
     目录           0  2008-11-03 23:42  OpenGL程序OpenGL程序includegl
     文件       60468  1998-08-13 02:54  OpenGL程序OpenGL程序includeglFGL.H
     文件        7273  1998-08-13 02:54  OpenGL程序OpenGL程序includeglFGLU.H
     文件       10152  1998-08-13 02:54  OpenGL程序OpenGL程序includeglFGLUT.H
     文件       71555  1997-11-07 02:34  OpenGL程序OpenGL程序includeglgl.h
     文件        5150  1998-08-13 02:54  OpenGL程序OpenGL程序includeglGLSMAP.H
     文件       14367  1997-10-31 02:18  OpenGL程序OpenGL程序includeglglu.h
     文件       20844  1998-08-13 02:54  OpenGL程序OpenGL程序includeglGLUT.H
     文件        8874  1998-08-13 02:54  OpenGL程序OpenGL程序includeglTUBE.H
     目录           0  2008-11-03 23:42  OpenGL程序OpenGL程序lib
     文件       35606  1997-10-31 02:18  OpenGL程序OpenGL程序libglu.lib
     目录           0  2008-11-03 23:42  OpenGL程序OpenGL程序libGLUT
     文件       11056  1998-08-13 02:49  OpenGL程序OpenGL程序libGLUTcapturexfont.c
     文件        2277  1998-08-13 02:46  OpenGL程序OpenGL程序libGLUTGLUT.DEF
     文件      180224  1999-07-29 15:48  OpenGL程序OpenGL程序libGLUTGLUT32.DLL
     文件       17306  1999-07-29 15:48  OpenGL程序OpenGL程序libGLUTGLUT32.EXP
     文件       27096  1999-07-29 15:48  OpenGL程序OpenGL程序libGLUTGLUT32.LIB
     文件         708  1998-08-13 02:54  OpenGL程序OpenGL程序libGLUTglutbitmap.h
     文件       28061  1998-08-13 02:54  OpenGL程序OpenGL程序libGLUTGLUTINT.H
     文件         938  1998-08-13 02:54  OpenGL程序OpenGL程序libGLUTglutstroke.h
     文件        1752  1998-08-13 02:54  OpenGL程序OpenGL程序libGLUTglutwin32.h
     文件       38739  1998-08-13 02:49  OpenGL程序OpenGL程序libGLUTglut_8x13.c
............此处省略81个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)