コード例 #1
0
ファイル: output.cpp プロジェクト: brycekelleher/bsp
static void EmitAreaBlock(bsptree_t *tree, FILE *fp)
{
	NumberAreasRecursive(tree->areas, 0);

	EmitHeader("areas", fp);

	EmitInt(tree->numareas, fp);

	for (area_t *a = tree->areas; a; a = a->next)
		EmitArea(a, fp);
}
コード例 #2
0
ファイル: output.cpp プロジェクト: brycekelleher/bsp
static void EmitNodeBlock(bsptree_t *tree, FILE *fp)
{
	NumberNodesRecursive(tree->root, 0);

	EmitHeader("nodes", fp);

	EmitInt(tree->numnodes, fp);
	EmitInt(tree->numleafs, fp);
	
	for (int i = 0; i < tree->numnodes; i++)
		EmitNode(i, tree->root, fp);
}
コード例 #3
0
ファイル: cmsps2.c プロジェクト: LuaDist/lcms2
static
cmsUInt32Number  GenerateCRD(cmsContext ContextID,
							 cmsHPROFILE hProfile, 
							 cmsUInt32Number Intent, cmsUInt32Number dwFlags,
							 cmsIOHANDLER* mem)
{    
	cmsUInt32Number dwBytesUsed;

	if (!(dwFlags & cmsFLAGS_NODEFAULTRESOURCEDEF)) {

		EmitHeader(mem, "Color Rendering Dictionary (CRD)", hProfile);
	}


	// Is a named color profile?
	if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {

		if (!WriteNamedColorCRD(mem, hProfile, Intent, dwFlags)) {
			return 0;
		}
	}
	else {

		// CRD are always implemented as LUT 

		if (!WriteOutputLUT(mem, hProfile, Intent, dwFlags)) {
			return 0;
		}
	}

	if (!(dwFlags & cmsFLAGS_NODEFAULTRESOURCEDEF)) {

		_cmsIOPrintf(mem, "%%%%EndResource\n");
		_cmsIOPrintf(mem, "\n%% CRD End\n");
	}

	// Done, keep memory usage
	dwBytesUsed = mem ->UsedSpace;

	// Finally, return used byte count
	return dwBytesUsed;

	cmsUNUSED_PARAMETER(ContextID);
}
コード例 #4
0
ファイル: output.cpp プロジェクト: brycekelleher/bsp
static void EmitPortalBlock(bsptree_t *tree, FILE *fp)
{
	EmitHeader("portals", fp);

	EmitInt(tree->numportals, fp);
	for (portal_t *p = tree->portals; p; p = p->treenext)
	{
		EmitInt(p->srcleaf->nodenumber, fp);
		EmitInt(p->dstleaf->nodenumber, fp);

		polygon_t *polygon = p->polygon;
		EmitInt(polygon->numvertices, fp);
		for (int i = 0; i < polygon->numvertices; i++)
		{
			EmitFloat(polygon->vertices[i][0], fp);
			EmitFloat(polygon->vertices[i][1], fp);
			EmitFloat(polygon->vertices[i][2], fp);
		}
	}
}
コード例 #5
0
ファイル: output.cpp プロジェクト: brycekelleher/bsp
static void EmitAreaRenderModel(area_t *a, FILE *fp)
{
	EmitHeader("rmodel", fp);
	EmitString(fp, "area%04i", a->areanumber);

	BeginMesh();
	for (areatri_t *t = a->trilist->head; t; t = t->next)
	{
		// fixme: function to create these
		meshvertex_t v0, v1, v2;
		v0.xyz = t->vertices[0];
		v0.normal = t->normals[0];
		v1.xyz = t->vertices[1];
		v1.normal = t->normals[1];
		v2.xyz = t->vertices[2];
		v2.normal = t->normals[2];

		InsertTri(v0, v1, v2);
	}
	EndMesh();

	// emit the vertex block
	int numvertices = NumVertices();
	EmitInt(numvertices, fp);
	for (int i = 0; i < numvertices; i++)
	{
		meshvertex_t v = GetVertex(i);
		EmitFloat(v.xyz[0], fp);
		EmitFloat(v.xyz[1], fp);
		EmitFloat(v.xyz[2], fp);
		EmitFloat(v.normal[0], fp);
		EmitFloat(v.normal[1], fp);
		EmitFloat(v.normal[2], fp);
	}

	// emit the index block
	int numindicies = NumIndicies();
	EmitInt(numindicies, fp);
	for (int i = 0; i < numindicies; i++)
		EmitInt(GetIndex(i), fp);
}
コード例 #6
0
ファイル: output.cpp プロジェクト: brycekelleher/bsp
static void EmitStaticRenderModel(smodel_t *m, FILE *fp)
{
	static int count = 0;

	EmitHeader("rmodel", fp);
	EmitString(fp, "staticmodel%04i", count);
	
	// emit the vertex block
	EmitInt(m->numvertices, fp);
	for (int i = 0; i < m->numvertices; i++)
	{
		EmitFloat(m->vertices[i][0], fp);
		EmitFloat(m->vertices[i][1], fp);
		EmitFloat(m->vertices[i][2], fp);
		EmitFloat(0.0f, fp);
		EmitFloat(0.0f, fp);
		EmitFloat(1.0f, fp);
	}

	// emit the index block
	EmitInt(m->numindicies, fp);
	for (int i = 0; i < m->numindicies; i++)
		EmitInt(m->indicies[i], fp);
}
コード例 #7
0
ファイル: fstobdf.c プロジェクト: Bluerise/bitrig-xenocara
int
main(int argc, char *argv[])
{
    FSServer   *fontServer;
    Font        fontID,
                dummy;
    FSBitmapFormat bitmapFormat;
    FSXFontInfoHeader fontHeader;
    FSPropInfo  propInfo;
    FSPropOffset *propOffsets;
    unsigned char *propData;

    FILE       *outFile;
    char       *fontName;
    char       *serverName;
    int         i;

    fontName = NULL;
    serverName = NULL;
    outFile = stdout;

    for (i = 1; i < argc; i++) {
	if (!strncmp(argv[i], "-s", 2)) {
	    if (argv[++i])
		serverName = argv[i];
	    else
		usage(argv[0]);
	} else if (!strncmp(argv[i], "-fn", 3)) {
	    if (argv[++i])
		fontName = argv[i];
	    else
		usage(argv[0]);
	}
    }

    if (fontName == NULL)
	usage(argv[0]);

    fontServer = FSOpenServer(serverName);
    if (!fontServer) {
	const char *sn = FSServerName(serverName);
	if (sn)
	    fprintf(stderr, "%s: can't open font server \"%s\"\n",
	      	    argv[0], sn);
	else
	    fprintf(stderr, "%s:  No font server specified.\n",
		    argv[0]);
	exit(0);
    }
    bitmapFormat = 0;
    fontID = FSOpenBitmapFont(fontServer, bitmapFormat, (FSBitmapFormatMask) 0,
			      fontName, &dummy);
    if (!fontID) {
	printf("can't open font \"%s\"\n", fontName);
	exit(0);
    }
    FSQueryXInfo(fontServer, fontID, &fontHeader, &propInfo, &propOffsets,
		 &propData);

    if (!EmitHeader(outFile, &fontHeader, &propInfo, propOffsets, propData))
	Fail(argv[0]);
    if (!EmitProperties(outFile, &fontHeader, &propInfo, propOffsets, propData))
	Fail(argv[0]);
    if (!EmitCharacters(outFile, fontServer, &fontHeader, fontID))
	Fail(argv[0]);
    fprintf(outFile, "ENDFONT\n");

    FSFree((char *) propOffsets);
    FSFree((char *) propData);
    exit (0);
}
コード例 #8
0
ファイル: main.c プロジェクト: yoshiylife/OZonUnix
main(int argc, char **argv)
{
  int i = 1, not_emit = 0, mem_debug = 0;
  char *vid, filename[256], *name, *oz_root, class_sc, *cpath = NULL;
#if 0
  int shared = 0;
#endif

  Mode = NORMAL;

  while (i < argc && *argv[i] == '-')
    {
      if (!strcmp(argv[i], "-d")) 
	{
	  Debug = 1;
	}
      else if (!strcmp(argv[i], "-d2")) 
	{
	  Debug = 2;
	}
      else if (!strcmp (argv[i], "-n"))
	{
	  not_emit = 1;
	}
      else if (!strcmp (argv[i], "-g"))
	{
	  int j, num = atoi(argv[++i]);

	  for (j = 0; j < num; j++)
	    SetTypeParameter (argv[++i]);

	  Generic = 1;
	}
#if 0
      else if (!strcmp (argv[i], "-s"))
	{
	  shared = 1;
	}
#endif
      else if (!strcmp (argv[i], "-c"))
	{
	  ClassPath = argv[++i];
	}
      else if (!strcmp (argv[i], "-p0"))
	{
	  Mode = THIS_CLASS;
	}
      else if (!strcmp (argv[i], "-p1"))
	{
	  Mode = USED_CLASSES;
	}
      else if (!strcmp (argv[i], "-p2"))
	{
	  Mode = INHERITED_CLASSES;
	}
      else if (!strcmp (argv[i], "-p3"))
	{
	  Mode = ALL_CLASSES;
	}
      else if (!strcmp (argv[i], "-pg"))
	{
	  Generic = 1;
	  Mode = GENERIC_PARAMS;
	}
      else if (!strcmp (argv[i], "-object"))
	{
	  Object = 1;
	}
#ifdef NONISHIOKA
      else if (!strcmp (argv[i], "-md"))
	{
	  mem_debug = atoi (argv[++i]);
	}
#else
#ifdef MALLOC_DEBUG
      else if (!strcmp (argv[i], "-md"))
	{
	  mem_debug = atoi (argv[++i]);
	}
#endif
#endif
      i++;
    }

#ifdef NONISHIOKA
  malloc_debug (mem_debug);
#else
#ifdef MALLOC_DEBUG
  malloc_debug (mem_debug);
#endif
#endif

  if (!(oz_root = getenv ("OZROOT")))
    {
      fprintf (stderr, "You must set OZROOT\n");
      exit (1);
    }
  if (!ClassPath)
    {
      cpath = "lib/boot-class";
      ClassPath = (char *) malloc (strlen (oz_root) + strlen (cpath) + 1);
      sprintf (ClassPath, "%s/%s", oz_root, cpath);
    }

  Pass = 0;
  Part = NOT_PART;

  if (Mode != NORMAL)
    {
#if 0
      if (shared)
	{
	  if (Mode == INHERITED_CLASSES)
	    {
	      print_usage ();
	      exit (1);
	    }
	  
	  yyfile = argv[i];
	  Part = PUBLIC_PART;
	}
      else if (Mode == GENERIC_PARAMS)
#endif
      if (Mode == GENERIC_PARAMS)
	{
	  yyfile = argv[i];
	}
      else if (Mode == USED_CLASSES || Mode == ALL_CLASSES)
	{
	  if (i + 1 == argc)
	    {
	      print_usage ();
	      exit (1);
	    }
	  
	  if (!strchr (argv[i], '.'))
	    {
	      Part = atoi (argv[i++]);
	      yyfile = argv[i];
	    }
	  else
	    {
	      yyfile = argv[i++];
	      LoadSchool (argv[i++]);
	      Part = PRIVATE_PART;
	    }
	}
      else
	yyfile = argv[i];

      if (!(yyin = fopen (yyfile, "r")))
	{
	  fprintf(stderr, "cannot open file: %s\n", argv[i]);
	  exit(1);
	}

      /* octal escaping */
      yyin = EucToOctalEscape (yyin, oz_root);

      yyparse ();

      if (Part == PRIVATE_PART)
	{
	  Pass = 1;
	  yylineno = 1;
	  rewind (yyin);
	  yyparse ();
	}

      fclose (yyin);

      return Error;
    }

#if 0
  if ((shared && i + 2 >= argc) || (!shared && i + 3 >= argc))
#endif
  if (i + 3 >= argc)
    {
      print_usage ();
      exit(1);
    }
  
#if 0
  if (shared)
    {
      Part = PUBLIC_PART;
      name = argv[i++];
    }
  else
    {
#endif
      Part = atoi (argv [i++]);
      name = argv[i++];
  
      if (Object && strcmp (name, "Object"))
	{
	  fprintf (stderr, "this class not `Object'\n");
	  exit (1);
	}
#if 0
    }
#endif

  yyfile = argv[i++];
  LoadSchool (argv[i]);

  vid = GetVID (name, Part);

  if (Debug)
    PrintSchool (-1, 0);

  if (!not_emit)
    switch (Part) 
      {
      case PUBLIC_PART:
	sprintf (filename, "%s/%s/public.z", ClassPath, vid);
	PublicOutputFileZ = file_open (filename);
	
	sprintf (filename, "%s/%s/public.h", ClassPath, vid);
	PublicOutputFileH = file_open (filename);

	class_sc = GetClassSC (name);

	if (class_sc == SC_RECORD || class_sc == SC_STATIC) 
	  {
	    if (class_sc == SC_STATIC)
	      {
		sprintf (filename, "%s/%s/private.i", ClassPath, vid);
		PrivateOutputFileI = file_open (filename);
	      }

	    sprintf (filename, "%s/%s/private.l", ClassPath, vid);
	    PrivateOutputFileL = file_open (filename);
#if 0
	    vid = GetVID (name, 2);
#endif
	    sprintf (filename, "%s/%s/private.c", ClassPath, vid);
	    PrivateOutputFileC = file_open (filename);
	  }

	if (class_sc && class_sc != SC_ABSTRACT)
	  {
	    sprintf (filename, "%s/%s/private.d", ClassPath, vid);
	    PrivateOutputFileD = file_open (filename);
	  }

	break;

      case PROTECTED_PART:
	sprintf (filename, "%s/%s/protected.z", ClassPath, vid);
	ProtectedOutputFileZ = file_open (filename);
	
	sprintf (filename, "%s/%s/protected.h", ClassPath, vid);
	ProtectedOutputFileH = file_open (filename);
	break;

    case PRIVATE_PART:
	sprintf (filename, "%s/%s/private.l", ClassPath, vid);
	PrivateOutputFileL = file_open (filename);
	
	sprintf (filename, "%s/%s/private.i", ClassPath, vid);
	PrivateOutputFileI = file_open (filename);
	      
	sprintf (filename, "%s/%s/private.d", ClassPath, vid);
	PrivateOutputFileD = file_open (filename);
	  
	sprintf (filename, "%s/%s/private.h", ClassPath, vid);
	PrivateOutputFileH = file_open (filename);
	      
	sprintf (filename, "%s/%s/private.c", ClassPath, vid);
	PrivateOutputFileC = file_open (filename);
	break;
      }

  CreateObjectClass ();
  LoadClass (yyfile, name, oz_root);

  if (!not_emit)
    switch (Part)
      {
      case PUBLIC_PART:
	if (!Error)
	  {
	    EmitClassFileZ (ThisClass, Part);
	    EmitHeader (ThisClass);
	    if (ThisClass->cl == TC_StaticObject)
	      {
		EmitClassFileI (ThisClass);
		fclose (PrivateOutputFileI);
	      }
	  }

	if (ThisClass->cl == TC_Record || ThisClass->cl == TC_StaticObject)
	  {
	    fclose (PrivateOutputFileL);
	    fclose (PrivateOutputFileC);
	  }

	if (ThisClass->cl != TC_Object)
	  fclose (PrivateOutputFileD);

	fclose (PublicOutputFileZ);
	fclose (PublicOutputFileH);
	break;
      case PROTECTED_PART:
	if (!Error)
	  {
	    EmitClassFileZ (ThisClass, Part);
	    EmitHeader (ThisClass);
	  }
	fclose (ProtectedOutputFileZ);
	fclose (ProtectedOutputFileH);
	break;
      case PRIVATE_PART:
	if (!Error)
	  {
	    EmitClassFileI (ThisClass);
	    EmitHeader (ThisClass);
	  }
	fclose (PrivateOutputFileL);
	fclose (PrivateOutputFileI);
	fclose (PrivateOutputFileD);
	fclose (PrivateOutputFileH);
	fclose (PrivateOutputFileC);
	break;
      }

  return Error;
}