Click here to Skip to main content
15,881,882 members
Articles / Multimedia / DirectX

Rendering Text with Direct2D & DirectWrite

Rate me:
Please Sign up or sign in to vote.
4.94/5 (39 votes)
3 Jan 2015CPOL8 min read 105.4K   2.8K   76  
Direct2D, DirectWrite, Windows API, C++, std::shared_ptr and more
#include "stdafx.h"

/*
 * -- SuperLU routine (version 2.0) --
 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
 * and Lawrence Berkeley National Lab.
 * November 15, 1997
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include "hnum_pzsp_defs.h"

#define TLEN	80

namespace harlinn
{
    namespace numerics
    {
        namespace SuperLU
        {
            namespace DoubleComplex
            {

                /* Eat up the rest of the current line */
                static void dumptitle(char *title)
                {
                    int c, i = 0;
	  
                    while ((c = getchar()) != '\n') title[i++] = c;
                    title[i] = '\0';
                }

                void
                zreadmt(int *m, int *n, int *nonz, doublecomplex **nzval, int **rowind, int **colptr)
                {
                /*
                 * Output parameters
                 * =================
                 *   (a,asub,xa): asub[*] contains the row subscripts of nonzeros
                 *	in columns of matrix A; a[*] the numerical values;
                 *	row i of A is given by a[k],k=xa[i],...,xa[i+1]-1.
                 *
                 */
                    int    i, k, nnz;
                    int    lasta;
                    char   title[TLEN];
                    doublecomplex *a;
                    int    *asub;
                    int    *xa;
    
                    /* 	Matrix format:
                     *         up to 60 characters           title
                     *         integer nrow                  number of rows
                     *         integer ncol                  number of cols
                     *         integer nonz	             number of nonzeros
                     *         (for each column:)
                     *               integer nnz             number of nzs in col
                     *                       integer index   row index of nonzero
                     *                       real value      value of nonzero
                     */

                    lasta = 0;
                    dumptitle(title);
                    printf("%s\n", title);

                    scanf("%d%d%d", m, n, nonz);
                    zallocateA(*n, *nonz, nzval, rowind, colptr); /* Allocate storage */
                    a    = *nzval;
                    asub = *rowind;
                    xa   = *colptr;

                    for (i = 0; i < *n; i++) {
	                scanf("%d", &nnz);
	                xa[i] = lasta;
                        for (k = 0; k < nnz; k++) {
	                    scanf("%d%lf%lf\n", &asub[lasta], &a[lasta].r, &a[lasta].i);
	                    --asub[lasta];	/* C convention: 0-based indexing */
                            lasta++;
                        }
                    }
                    if ( *nonz < lasta ) {
	                fprintf(stderr, "nnz inconsistent: *nonz %d, lasta %d\n",*nonz,lasta);
	                exit(-1);
                    }
    
                    xa[*n] = lasta--;

                #ifdef CHK_INPUT
                    for (i = 0; i < *n; i++) {
	                printf("Col %d, xa %d\n", i, xa[i]);
	                for (k = xa[i]; k < xa[i+1]; k++)
	                    printf("%d %16.11e\n", asub[k], a[k]);
                    }
                #endif

                }

            };
        };
    };
};


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Sea Surveillance AS
Norway Norway
Chief Architect - Sea Surveillance AS.

Specializing in integrated operations and high performance computing solutions.

I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.

Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...

A few Highlights:

  • High performance application server development
  • Model Driven Architecture and Code generators
  • Real-Time Distributed Solutions
  • C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
  • Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
  • AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
  • Oracle WebLogic, IBM WebSphere
  • Corba, COM, DCE, WCF
  • AspenTech InfoPlus.21(IP21), OsiSoft PI


More information about what I do for a living can be found at: harlinn.com or LinkedIn

You can contact me at espen@harlinn.no

Comments and Discussions