IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenGL Discussion :

Font et dépendance windows


Sujet :

OpenGL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Homme Profil pro
    Consultant MOA
    Inscrit en
    Juillet 2004
    Messages
    289
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : Consultant MOA
    Secteur : Conseil

    Informations forums :
    Inscription : Juillet 2004
    Messages : 289
    Par défaut Font et dépendance windows
    Salut à tous,

    Dans quasiment tous les tutorials, j'ai vu que pour charger une font on utilisait les méthodes CreateFont et qu'on la stockait dans un tableau de GLYPHMETRICSFLOAT, structure propre à windows.

    Y'a-t-il un moyen de s'en passer et de rester portable ?

    Merci

  2. #2
    Membre émérite
    Avatar de Happy
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2005
    Messages
    665
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Autre

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juin 2005
    Messages : 665
    Par défaut
    Salut,

    Une methode simple est comme le livre d'openg l'indique:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    const GLubyte FONTS[] [12]= {
                             {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0xd8, 0x90, 0x48, 0x00},	//  "
                             {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},	//" "
    						 {0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00},	//  !
    						 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x48, 0xd8, 0xd8, 0x00},	//  "
    						 {0x00, 0x00, 0x00, 0x50, 0x50, 0xfc, 0x28, 0x28, 0xfc, 0x28, 0x28, 0x00},	//  #
    						 {0x00, 0x00, 0x20, 0x70, 0xa8, 0x28, 0x30, 0x60, 0xa0, 0xa8, 0x70, 0x20},	//  $
    						 {0x00, 0x00, 0x00, 0x88, 0x94, 0x54, 0x28, 0x50, 0xa8, 0xa4, 0x44, 0x00},	//  %
    						 {0x00, 0x00, 0x00, 0x74, 0x88, 0x94, 0xa0, 0x40, 0x80, 0x90, 0x60, 0x00},	//  &
    						 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x30, 0x30, 0x00},	//  '
    						 {0x08, 0x10, 0x20, 0x20, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x08},	//  (
    						 {0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40},	//  )
    						 {0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xa8, 0x70, 0x70, 0xa8, 0x20, 0x00},	//  *
    						 {0x00, 0x00, 0x00, 0x20, 0x20, 0xf8, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00},	//  +
    						 {0x00, 0x20, 0x10, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},	//  ,
    						 {0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},	//  -
    						 {0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},	//  .
    						 {0x00, 0x00, 0x80, 0x80, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x00},	//  /
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x70, 0x00},	//  0
    						 {0x00, 0x00, 0x00, 0xf8, 0x20, 0x20, 0x20, 0x20, 0xa0, 0x60, 0x20, 0x00},	//  1
    						 {0x00, 0x00, 0x00, 0xf8, 0x80, 0x40, 0x20, 0x10, 0x08, 0x88, 0x70, 0x00},	//  2
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x08, 0x08, 0x30, 0x08, 0x88, 0x70, 0x00},	//  3
    						 {0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xf8, 0x90, 0x50, 0x30, 0x10, 0x00},	//  4
    						 {0x00, 0x00, 0x00, 0xf0, 0x08, 0x08, 0x88, 0xf0, 0x80, 0x80, 0xf8, 0x00},	//  5
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0xf0, 0x80, 0x40, 0x30, 0x00},	//  6
    						 {0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x10, 0x10, 0x08, 0x88, 0xf8, 0x00},	//  7
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70, 0x00},	//  8
    						 {0x00, 0x00, 0x00, 0x60, 0x10, 0x08, 0x78, 0x88, 0x88, 0x88, 0x70, 0x00},	//  9
    						 {0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00},	//  :
    						 {0x00, 0x20, 0x10, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00},	//  ;
    						 {0x00, 0x00, 0x00, 0x0c, 0x30, 0xc0, 0x30, 0x0c, 0x00, 0x00, 0x00, 0x00},	//  <
    						 {0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00},	//  =
    						 {0x00, 0x00, 0x00, 0xc0, 0x30, 0x0c, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00},	//  >
    						 {0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x20, 0x10, 0x08, 0x88, 0x70, 0x00},	//  ?
    						 {0x00, 0x00, 0x00, 0x38, 0x40, 0x98, 0xa8, 0xa8, 0x98, 0x48, 0x30, 0x00},	//  @
    						 {0x00, 0x00, 0x00, 0x88, 0x88, 0xf8, 0x50, 0x50, 0x20, 0x20, 0x20, 0x00},	//  A
    						 {0x00, 0x00, 0x00, 0xf0, 0x88, 0x88, 0x88, 0xf0, 0x88, 0x88, 0xf8, 0x00},	//  B
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x80, 0x80, 0x80, 0x80, 0x88, 0x70, 0x00},	//  C
    						 {0x00, 0x00, 0x00, 0xe0, 0x90, 0x88, 0x88, 0x88, 0x88, 0x90, 0xe0, 0x00},	//  D
    						 {0x00, 0x00, 0x00, 0xf8, 0x80, 0x80, 0x80, 0xf0, 0x80, 0x80, 0xf8, 0x00},	//  E
    						 {0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xf0, 0x80, 0x80, 0xf8, 0x00},	//  F
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x98, 0x80, 0x80, 0x88, 0x70, 0x00},	//  G
    						 {0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x88, 0x00},	//  H
    						 {0x00, 0x00, 0x00, 0x70, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x00},	//  I
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00},	//  J
    						 {0x00, 0x00, 0x00, 0x88, 0x90, 0xa0, 0xc0, 0xc0, 0xa0, 0x90, 0x88, 0x00},	//  K
    						 {0x00, 0x00, 0x00, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00},	//  L
    						 {0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0xa8, 0xd8, 0xd8, 0x88, 0x00},	//  M
    						 {0x00, 0x00, 0x00, 0x88, 0x98, 0x98, 0xa8, 0xa8, 0xc8, 0xc8, 0x88, 0x00},	//  N
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00},	//  O
    						 {0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xf0, 0x88, 0x88, 0x88, 0xf0, 0x00},	//  P
    						 {0x00, 0x0c, 0x10, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00},	//  Q
    						 {0x00, 0x00, 0x00, 0x88, 0x90, 0xa0, 0xf0, 0x88, 0x88, 0x88, 0xf0, 0x00},	//  R
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x08, 0x08, 0x70, 0x80, 0x88, 0x70, 0x00},	//  S
    						 {0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xf8, 0x00},	//  T
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x00},	//  U
    						 {0x00, 0x00, 0x00, 0x20, 0x20, 0x50, 0x50, 0x88, 0x88, 0x88, 0x88, 0x00},	//  V
    						 {0x00, 0x00, 0x00, 0x50, 0x50, 0x50, 0xa8, 0xa8, 0xa8, 0x88, 0x88, 0x00},	//  W
    						 {0x00, 0x00, 0x00, 0x88, 0x88, 0x50, 0x20, 0x20, 0x50, 0x88, 0x88, 0x00},	//  X
    						 {0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x50, 0x50, 0x88, 0x88, 0x00},	//  Y
    						 {0x00, 0x00, 0x00, 0xf8, 0x80, 0x40, 0x20, 0x20, 0x10, 0x08, 0xf8, 0x00},	//  Z
    						 {0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00},	//  [
    						 {0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x00},	//  \               */
    						 {0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00},	//  ]
    						 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x50, 0x50, 0x20, 0x20, 0x00},	//  ^
    						 {0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},	//  _
    						 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00},	//  `
    						 {0x00, 0x00, 0x00, 0x68, 0x98, 0x88, 0x88, 0x88, 0x78, 0x00, 0x00, 0x00},	//  a
    						 {0x00, 0x00, 0x00, 0xf0, 0x88, 0x88, 0x88, 0xc8, 0xb0, 0x80, 0x80, 0x00},	//  b
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x80, 0x80, 0x88, 0x70, 0x00, 0x00, 0x00},	//  c
    						 {0x00, 0x00, 0x00, 0x68, 0x98, 0x88, 0x88, 0x88, 0x78, 0x08, 0x08, 0x00},	//  d
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x80, 0xf8, 0x88, 0x70, 0x00, 0x00, 0x00},	//  e
    						 {0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0xf0, 0x40, 0x30, 0x00},	//  f
    						 {0x00, 0x70, 0x08, 0x68, 0x98, 0x88, 0x88, 0x88, 0x78, 0x00, 0x00, 0x00},	//  g
    						 {0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0xc8, 0xb0, 0x80, 0x80, 0x00},	//  h
    						 {0x00, 0x00, 0x00, 0x30, 0x20, 0x20, 0x20, 0x20, 0x60, 0x00, 0x20, 0x00},	//  i
    						 {0x00, 0xe0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00, 0x10, 0x00},	//  j
    						 {0x00, 0x00, 0x00, 0x88, 0x90, 0xa0, 0xc0, 0xa0, 0x90, 0x80, 0x80, 0x00},	//  k
    						 {0x00, 0x00, 0x00, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00},	//  l
    						 {0x00, 0x00, 0x00, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xd0, 0x00, 0x00, 0x00},	//  m
    						 {0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0xc8, 0xb0, 0x00, 0x00, 0x00},	//  n
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, 0x00},	//  o
    						 {0x00, 0x80, 0x80, 0xf0, 0x88, 0x88, 0x88, 0xc8, 0xb0, 0x00, 0x00, 0x00},	//  p
    						 {0x00, 0x08, 0x08, 0x68, 0x98, 0x88, 0x88, 0x88, 0x78, 0x00, 0x00, 0x00},	//  q
    						 {0x00, 0x00, 0x00, 0xe0, 0x40, 0x40, 0x40, 0x60, 0xd8, 0x00, 0x00, 0x00},	//  r
    						 {0x00, 0x00, 0x00, 0x70, 0x88, 0x10, 0x60, 0x88, 0x70, 0x00, 0x00, 0x00},	//  s
    						 {0x00, 0x00, 0x00, 0x30, 0x48, 0x40, 0x40, 0x40, 0xf0, 0x40, 0x40, 0x00},	//  t
    						 {0x00, 0x00, 0x00, 0x68, 0x98, 0x88, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00},	//  u
    						 {0x00, 0x00, 0x00, 0x20, 0x20, 0x50, 0x50, 0x88, 0x88, 0x00, 0x00, 0x00},	//  v
    						 {0x00, 0x00, 0x00, 0x50, 0x50, 0xa8, 0xa8, 0x88, 0x88, 0x00, 0x00, 0x00},	//  w
    						 {0x00, 0x00, 0x00, 0x88, 0x50, 0x20, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00},	//  x
    						 {0x00, 0x80, 0x40, 0x20, 0x20, 0x50, 0x50, 0x88, 0x88, 0x00, 0x00, 0x00},	//  y
    						 {0x00, 0x00, 0x00, 0xf8, 0x80, 0x40, 0x20, 0x10, 0xf8, 0x00, 0x00, 0x00},	//  z
    						 {0x18, 0x20, 0x20, 0x20, 0x20, 0xc0, 0x20, 0x20, 0x20, 0x20, 0x18, 0x00},	//  {
    						 {0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20},	//  |
    						 {0xc0, 0x20, 0x20, 0x20, 0x20, 0x18, 0x20, 0x20, 0x20, 0x20, 0xc0, 0x00},	//  }
    						 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x64, 0x00, 0x00, 0x00, 0x00}   //  ~
                                };
     
    void text(int x, int y,string text)
    {
        if ( x < 0 || y < 0); else
        {
            glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
            glRasterPos2i(x,y+12);
            for(int i = 0; i < text.size(); ++i)
            glBitmap(6, 12, 0.0, 0.0, 7, 0.0, FONTS[text[i]-31]);
        }
    }
    Cet example est pris depuis un moteur 3d nommé: Utopia
    Il faut etre en 2d pour utiliser, gluortho2d();

  3. #3
    Membre éclairé
    Homme Profil pro
    Consultant MOA
    Inscrit en
    Juillet 2004
    Messages
    289
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : Consultant MOA
    Secteur : Conseil

    Informations forums :
    Inscription : Juillet 2004
    Messages : 289
    Par défaut
    Merci pour cette réponse

    C'est vrai que j'ai oublié de le dire, mais je voudrais pouvoir charger les fonts ttf, le problème vient du fait que je ne sais pas si ces polices sont spécifiques à Windows ou pas.
    Si oui, le couplage n'est pas important. Si non existe-t-il un moyen de les charger sans méthodes spécifiques à Windows ?

  4. #4
    Membre émérite
    Avatar de Happy
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2005
    Messages
    665
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Autre

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juin 2005
    Messages : 665
    Par défaut
    Je crois que FreeType2 faira l'affaire: http://www.freetype.org/index2.html

  5. #5
    Rédacteur
    Avatar de Laurent Gomila
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651

Discussions similaires

  1. Réponses: 2
    Dernier message: 08/07/2013, 17h21
  2. Fontes différentes Mac - Windows
    Par defacta dans le forum Mise en page CSS
    Réponses: 1
    Dernier message: 17/11/2011, 15h15
  3. [fonts/polices]rendu différent linux/windows
    Par couetbis dans le forum Jasper
    Réponses: 2
    Dernier message: 19/06/2009, 11h34
  4. [WINDOWS]Installation des fonts
    Par nabil1 dans le forum Autres Logiciels
    Réponses: 47
    Dernier message: 24/04/2006, 13h54
  5. [Font] utiliser une même police sur Windows et sur Linux ?
    Par iubito dans le forum Interfaces Graphiques en Java
    Réponses: 6
    Dernier message: 10/05/2005, 16h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo