|
Das deutsche QBasic- und FreeBASIC-Forum Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
|
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
Autor |
Nachricht |
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 05.06.2008, 12:34 Titel: FreeType und OpenGL |
|
|
Hi,
ich hab für mein Online-Spiel eine include-file geschrieben, mit der ich freetype unter OpenGL nutzen kann. Leider funktioniert es nicht, der Text wird nicht angezeigt. Ich hab alles + Beispiel-Source hier hochgeladen: http://rapidshare.com/files/120237027/FTGL.zip.html
Ich hoffe ihr könnt mir helfen + danke für die Antworten |
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 05.08.2008, 17:13 Titel: |
|
|
hm, ok, da mir da keiner helfen kann/will, frag ich anders:
hat jemand ein beispiel (code, tutorial, irgendwas) in dem freetype und openGL zusammen benutzt werden? (NeHe´s tut kenn ich, aber das kapier ich nich richtig)
am besten wäre es natürlich wenn das ganze in freebasic geschrieben wäre, muss aber nicht unbedingt sein
danke |
|
Nach oben |
|
|
Eastler_dart
Anmeldungsdatum: 25.09.2005 Beiträge: 177 Wohnort: Baden-Würtemberg + Sachsen
|
Verfasst am: 10.08.2008, 21:54 Titel: |
|
|
Hi sts,
hab grad deine Frage gelesen - grübel - Hirn zermater
egal, falls ich dich falsch verstanden haben, sorry, ich schreib trotzdem, was ich darüber denke
Häng selber grad in OpenGL. Wollte einfach Text anzeigen im OpenGL-Fenster, DAS GEHT NICHT.
Hab Vieles probiert, die FreeBasic-Anzeigebefehle wie Print, Point, Line und Co. laufen alle ins Leere.
In ein für OpenGL geöffnetes Fenster kann man keine Pixel reinschmuggeln. Sowas muß man mit OpenGL-Befehlen machen.
Und aus diesem Rumprobieren schließe ich, daß du an genau dem Punkt hängen bleibst.
Deine FreeType-Anzeigen werden vielleicht nicht angezeigt, weil man im OpenGL-Fenster nix anzeigen kann ! ? ?
Hab auch alternativ schon probiert, einfach ein zweites Fenster zu öffnen, solche Tricks ließt man ja, wenn man nach OpenGL-Tricks sucht.
Unter den anderen Programmiersprachen mag das ja gehen, aber FreeBasic weigert sich strikt, mehr als ein Fenster zu haben.
Wenn du also irgendwas anzeigen willst, aber dafür nicht OpenGL bemühen möchtest, gibts nur eine einzige Notlösung:
Dein Programm nicht mit dem Parameter für gui kompilieren, dann kommt beim Starten des Programms ein Textconsolefenster und noch dazu dein OpenGL-Fenster.
mit folgendem Konstrukt kannst du dann in das Konsole-Fenster schreiben: Code: | DIM AS INTEGER ConNr
ConNr = FREEFILE
open "con" FOR OUTPUT AS #ConNr
PRINT #ConNr, "das ist ein Anzeigetext"
PRINT #ConNr, "das die Zweite Zeile"
CLOSE #ConNr
|
Bestimmt ist dir dabei klar, daß diese Ausgaben auf ein Text-Console-Fenster laufen, mit Grafik ist dort drin nix los,
nur reine Textausgaben.
Mir hilft dieser Trick, Variableninhalte oder so mal anzuzeigen,
solange ich an meinem Prog rumbastle.
Hoffe es hilft
Eastler _________________ Kaum macht mans richtig, schon geht's |
|
Nach oben |
|
|
1500_PMEDIA_IS_BACK
Anmeldungsdatum: 09.08.2008 Beiträge: 5
|
Verfasst am: 10.08.2008, 22:13 Titel: |
|
|
Ich hab mich nie wirklich mit FType2 beschäftigt. Ich bin mir aber sicher, dass es möglich ist, damit einen FBGFX-Grafikpuffer zu befüllen, diesen in eine OpenGL-Textur umzuwandeln - und zu verwenden.
Spiele machen dies für gew. mit einer vorgerenderten Font-Textur, wie sie z.B. mit dem Bitmap Font Builder (http://www.lmnopc.com/bitmapfontbuilder/) erstellt werden können. Eine Routine zum verwenden (muss leicht abgewandelt werden) findet sich in Stormy's 2D for OpenGL-Tutorial, welches auch die anderen "Arbeitsweisen" von OpenGL ein wenig hinterleuchtet. Leider ist offenbar derzeitig der Downloadlink down. |
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 12.08.2008, 17:54 Titel: |
|
|
danke für die antworten.
ich hab zuerst versucht, mir ein fontsystem wie das von Stormy´s 2D-tutorial zu basteln, was aber daran scheiterte das die TGA-lade-routine, die ich benutze, aus irgendeinem grund meine TGA´s (mit GIMP erstellt) nicht laden kann. (ich hab die TGA dann mal geöffnet, und als BMP gespeichert. dabei hab ich darauf geachtet das er nur 24 bit speichert. wenn ich dann mit Stormy´s fontsystem die BMP geladen hab, konnte ich die buchstaben sehen, aber BMP´s unterstützen ja keinen alpha-channel, deshalb hatte ich ein schwarzes rechteck um den buchstaben herum)
dann hab ich versucht, von FreeType die zeichen rendern zu lassen und daraus eine textur zu machen. das hat irgendwie auch nicht hingehauen. ich werd mich gleich daran setzen und es noch mal probieren, zum glück hat fb ja freetype-beispiele mitgeliefert (ich hatte auch versucht, NeHe´s freetype-lib von VC++ nach fb zu portieren, aber fb meint, die freetype-befehle die er verwendet, gäbe es nicht.)
und wenn jemand weiß warum ich meine tga´s nicht laden kann, wäre ich für eine antwort sehr dankbar |
|
Nach oben |
|
|
Stormy
Anmeldungsdatum: 10.09.2004 Beiträge: 567 Wohnort: Sachsen - wo die schönen Frauen wachsen ;)
|
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 13.08.2008, 12:12 Titel: |
|
|
ok danke, ich werds mal ausprobieren.
ich hab nochmal versucht, mir eine kleine OpenGL-FreeType-lib zu schreiben. leider krieg ich einen haufen fehler, kann mir jemand beim debuggen helfen?
Code: |
'// myFreetype include file
'// COPYRIGHT 2008 by DarkRainbow software
type font_data
h as single
textures as GLuint
list_base as GLuint
end type
declare function next_p2 (a as integer) as integer
declare sub make_dlist (face as FT_Face, ch as byte, list_base as GLuint, tex_base as GLuint)
declare sub FontInit (FontData as font_Data, filename as string, height as Uinteger)
declare sub FontClean (FontData as font_Data)
declare sub pushScreenCoordinatesMatrix
declare sub pop_projection_matrix
declare sub glPrint (ft_font as font_data, x as single, y as single, fmt as string)
function next_p2 (a as integer) as integer
dim rval as integer
rval = 1
do until rval>a
rval *= 2
loop
return rval
end function
sub make_dlist (face as FT_Face, ch as byte, list_base as GLuint, tex_base as GLuint)
if FT_Load_Char (face, asc(ch), FT_LOAD_DEFAULT) then end
FT_Render_Glyph(Face->Glyph, FT_RENDER_MODE_NORMAL)
dim bitmap as FT_Bitmap ptr
bitmap = @Face->Glyph->Bitmap
'// Use Our Helper Function To Get The Widths Of
'// The Bitmap Data That We Will Need In Order To Create
'// Our Texture.
dim wwidth as integer
dim height as integer
wwidth = next_p2(bitmap->width)
height = next_p2(bitmap->rows)
'// Allocate Memory For The Texture Data.
dim expanded_data(2*wwidth*height) as GLubyte
'// Here We Fill In The Data For The Expanded Bitmap.
'// Notice That We Are Using A Two Channel Bitmap (One For
'// Channel Luminosity And One For Alpha), But We Assign
'// Both Luminosity And Alpha To The Value That We
'// Find In The FreeType Bitmap.
'// We Use The if-command To Say That Value Which We Use
'// Will Be 0 If We Are In The Padding Zone, And Whatever
'// Is The FreeType Bitmap Otherwise.
dim j as integer
dim i as integer
for j = 0 to height-1
for i = 0 to wwidth-1
if i>=bitmap->width or j>=bitmap->rows then
expanded_data(2*(i+j*wwidth)) = 0
expanded_data(2*(i+j*wwidth)+1) = 0
else
expanded_data(2*(i+j*wwidth)) = bitmap->buffer(i+bitmap->width*j)
expanded_data(2*(i+j*wwidth)+1) = bitmap->buffer(i+bitmap->width*j)
end if
next i
next j
'// Now We Just Setup Some Texture Parameters.
glBindTexture GL_TEXTURE_2D, tex_base(ch)
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
'// Here We Actually Create The Texture Itself, Notice
'// That We Are Using GL_LUMINANCE_ALPHA To Indicate That
'// We Are Using 2 Channel Data.
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, expanded_data)
'// Now We Create The Display List
glNewList(list_base+ch, GL_COMPILE)
glBindTexture(GL_TEXTURE_2D, tex_base)
glPushMatrix
'// First We Need To Move Over A Little So That
'// The Character Has The Right Amount Of Space
'// Between It And The One Before It.
glTranslatef(bitmap_glyph->left, 0, 0)
'// Now We Move Down A Little In The Case That The
'// Bitmap Extends Past The Bottom Of The Line
'// This Is Only True For Characters Like 'g' Or 'y'.
glTranslatef(0, bitmap_glyph->top-bitmap.rows, 0)
'// Now We Need To Account For The Fact That Many Of
'// Our Textures Are Filled With Empty Padding Space.
'// We Figure What Portion Of The Texture Is Used By
'// The Actual Character And Store That Information In
'// The x And y Variables, Then When We Draw The
'// Quad, We Will Only Reference The Parts Of The Texture
'// That Contains The Character Itself.
dim x as long
dim y as long
x = bitmap->width / wwidth
y = bitmap->rows / height
'// Here We Draw The Texturemapped Quads.
'// The Bitmap That We Got From FreeType Was Not
'// Oriented Quite Like We Would Like It To Be,
'// But We Link The Texture To The Quad
'// In Such A Way That The Result Will Be Properly Aligned.
glBegin(GL_QUADS)
glTexCoord2d(0, 0)
glVertex2f(0, bitmap->rows)
glTexCoord2d(0, y)
glVertex2f(0, 0)
glTexCoord2d(x, y)
glVertex2f (bitmap->width, 0)
glTexCoord2d (x, 0)
glVertex2f(bitmap->width, bitmap->rows)
glEnd
glPopMatrix
glTranslatef((face->glyph->advance.x shr 6) ,0,0)
glEndList
end sub
sub FontInit (FontData as font_Data, filename as string, height as Uinteger)
'dim textures(128) as GLuint
FontData.h = height
dim library as FT_Library
if FT_Init_FreeType(@library) then end
dim face as FT_Face
if FT_New_Face(library, filename, 0, @face) then end
FT_Set_Pixel_Sizes(face, 0, height)
list_base=glGenLists(128)
glGenTextures(128, FontData.textures)
dim i as Ubyte
for i = 0 to 128-1
make_dlist(face, i, list_base, FontData.textures)
next i
FT_Done_Face(face)
FT_Done_FreeType(library)
end sub
sub FontClean (FontData as font_Data)
glDeleteLists(FontData.list_base, 128)
glDeleteTextures(128, FontData.textures)
end sub
sub pushScreenCoordinatesMatrix
glPushAtrib GL_TRANSFORM_BIT
dim viewport(4) as GLint
glGetIntegerv GL_VIEWPORT, viewport
glMatrixMode(GL_PROJECTION)
glPushMatrix
glLoadIdentity
gluOrtho2D(viewport(0), viewport(2), viewport(1), viewport(3)
glPopAttrib
end sub
sub pop_projection_matrix
glPushAttrib GL_TRANSFORM_BIT
glMatrixMode GL_PROJECTION
glPopMatrix
glPopAttrib
end sub
'sub glPrint (ft_font as font_data, x as single, y as single, fmt as string)
sub glPrint (ft_font as font_data, x as single, y as single, text as string)
pushScreenCoordinateMatrix
dim font as GLuint
font = ft_font.list_base
dim h as single
h = ft_font.h / 0.63f
'dim text(256) as string
'// pointer to list of arguments ?!?! va_list ap;
glPushAttrib (GL_LIST_BIT or GL_CURRENT_BIT or GL_ENABLE_BIT or GL_TRANSFORM_BIT)
glMatrixMode GL_MODELVIEW
glDisable GL_LIGHTING
glEnable GL_TEXTURE_2D
glDisable GL_DEPTH_TEST
glEnable GL_BLEND
glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
glListBase font
dim modelview_matrix(16) as single
glGetFloatv GL_MODELVIEW_MATRIX, modelview_matrix
dim i as integer
for i = 0 to lines.size-1
glPushMatrix
glLoadIdentity
glTranslatef(x, y-h*i, 0)
glMultMatrixf modelview_matrix
glCallList asc(mid(text, i))
glPopMatrix
next i
glPopAttrib
pop_projection_matrix
end sub
|
/edit:
ich versuchs nochmal zu kompilieren und stell dann mal die Fehlermeldung hier rein... |
|
Nach oben |
|
|
3238333938
Anmeldungsdatum: 19.08.2008 Beiträge: 3
|
Verfasst am: 19.08.2008, 18:30 Titel: |
|
|
Ja an diesem Thema kann man sich sehr gut die Zähne aussbeissen, wenn man nicht die richtigen Bibliotheken hat...
FontGL jedoch, ist genauso schnell wie auch einfach zu benutzten...
FontGL.bi
Code: |
/'***************************************************************************/
/* */
/* FontGL.h */
/* */
/* FontGL: An OpenGL font-rendering library. */
/* */
/* Copyright 2006-2007 by Eric Newman. */
/* Contact: e.newman@mat.ucsb.edu */
/* */
/* FontGL may be freely used and modified for non-commercial purposes by */
/* any individual, organization, or entity. However, please be kind and */
/* cite the author's work where appropriate. */
/* */
/***************************************************************************'/
' FreeBasic version by Merick
#ifndef FONTGL_INCLUDE_BI
#define FONTGL_INCLUDE_BI
#ifdef __FB_LINUX__
#include "GL/gl.bi"
#include "GL/glu.bi"
#endif
#ifdef __FB_WIN32__
#include once "gl/gl.bi"
#include once "gl/glu.bi"
#endif
#ifndef FALSE
#define FALSE 0
#define TRUE (Not FALSE)
#endif
#include once "freetype2/freetype.bi"
#define ASCII_SIZE 255 ' number of characters to use
Type FontGLColor
r As Single
g As Single
b As Single
a As Single
End Type
Type FontGL
Public:
Declare Constructor (Byval fontName As String, Byval fontSize As Integer, Byval antiAliased As Integer = true, Byval cacheGlyphs As Integer = false)
Declare Destructor ( )
' renders a text string at the specified 3D position
Declare Sub render(x As Single, y As Single, z As Single, text As String)
' returns the width of a text string in pixels
Declare Function advance(text As String) As Single
' returns the "above-line" height of the font in pixels
Declare Function ascender() As Single
' returns the "below-line" height of the font in pixels
Declare Function descender() As Single
' returns the total height of the font in pixels
Declare Function size() As Integer
' sets the color of the font
Declare Sub setColor(R As Single, G As Single, B As Single, A As Single)
' these texture functions are necessary if your app
' creates/destroys multiple windows while running.
' you might also want to set cacheGlyphs to true
' (keeps the font in main memory - a bit faster)
Declare Sub initTextures()
Declare Sub uninitTextures()
Private:
FontGL_Library As FT_Library Ptr
face As FT_Face
Color_ As FontGLColor Ptr
textures As GLuint Ptr
widths As Integer Ptr
vOffsets As Integer Ptr
fontsize As Integer
textureSize As Integer
antialiased As Integer
cacheglyphs As Integer
glyphImages(ASCII_SIZE) As Ubyte Ptr
Declare Sub loadTexture(textureNum As Integer, glyphImage As Ubyte Ptr)
Declare Sub loadGlyph(glyphNum As Integer, glyphImage As Ubyte Ptr)
End Type
#EndIf
|
FontGL.bas
Code: | /'**************************************************************************
*
* FontGL.cpp
*
* FontGL: An OpenGL font-rendering library.
*
* Copyright 2006-2007 by Eric Newman.
* Contact: e.newman@mat.ucsb.edu
*
* FontGL may be freely used and modified for non-commercial purposes by
* any individual, organization, or entity. However, please be kind and
* cite the author's work where appropriate.
*
***************************************************************************'/
' FreeBasic version by Merick
' Changes by 28398 Laboratories
' Added FontGL.setColor
'
' Changes by JohnB
'
' 20080103
' Changed New() to New[]
' Had to fix the render glTexCoord and glVertex, flipped the texcoods and negated vOffset, ie, -(-) = +
' For my style, changed String Ptr to String.
'
' 20080322
' Found another New() changed to New[]
' Fixed error in For endvalue in FontGL.loadGlyph, fixed problem with gap in non AA fonts
'
' small fonts still fuzzy, need to compare to SDL_TTF
'
'
#include once "FontGL.bi"
Constructor FontGL (Byval fName As String, Byval fSize As Integer, Byval aAliased As Integer = true, Byval cGlyphs As Integer = false)
FontGL_Library = New FT_Library
FT_Init_FreeType(FontGL_Library)
face = 0
FT_New_Face(*FontGL_Library, fName, 0, @face)
fontsize = fSize
antialiased = aAliased
cacheglyphs = cGlyphs
If (face) Then FT_Set_Char_Size(face, 0, fontsize * 64, 0, 0)
Color_ = New FontGLColor
setColor(1.0, 1.0, 1.0, 1.0)
widths = New Integer[ASCII_SIZE]
vOffsets = New Integer[ASCII_SIZE]
textures = New GLuint[ASCII_SIZE]
memset(widths, 0, sizeof(Integer) * ASCII_SIZE)
memset(vOffsets, 0, sizeof(Integer) * ASCII_SIZE)
memset(textures, 0, sizeof(Integer) * ASCII_SIZE)
textureSize = 1
While (textureSize < fontsize)
textureSize *= 2
Wend
' If cacheglyphs = true Then
' Dim As Integer i
' For i= 0 To ASCII_SIZE-1
' glyphImages(i) = New Ubyte [textureSize * textureSize * 2]
' loadGlyph(i, glyphImages(i))
' Next
' Endif
initTextures()
End Constructor
Destructor FontGL()
uninitTextures()
If cacheglyphs = true Then
Dim As Integer i
For i = 0 To ASCII_SIZE -1
Delete glyphImages(i)
Next
Endif
Delete textures
Delete widths
Delete vOffsets
Delete Color_
If (face) Then FT_Done_Face(face)
FT_Done_FreeType(*FontGL_Library)
Delete FontGL_Library
End Destructor
Sub FontGL.initTextures()
glGenTextures(ASCII_SIZE, textures)
If cacheglyphs = true Then
Dim As Integer i
For i = 0 To ASCII_SIZE -1
glyphImages(i) = New Ubyte [textureSize * textureSize * 2]
loadGlyph(i, glyphImages(i))
loadTexture(i, glyphImages(i))
Delete glyphImages(i)
Next
Else
' Dim As Ubyte Ptr glyphImage = New Ubyte(textureSize * textureSize * 2)
Dim As Ubyte Ptr glyphImage = New Ubyte[textureSize * textureSize * 2]
Dim As Integer i
For i = 0 To ASCII_SIZE -1
loadGlyph(i, glyphImage)
loadTexture(i, glyphImage)
Next
Delete glyphImage
Endif
End Sub
Sub FontGL.loadGlyph(glyphNum As Integer, glyphImage As Ubyte Ptr)
memset(glyphImage, 0, textureSize * textureSize * 2)
If (face) Then
Dim As Integer j, k, l
Dim As Integer glyph_index
glyph_index = FT_Get_Char_Index(face, glyphNum)
If antialiased = true Then
FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT)
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL)
Else
FT_Load_Glyph(face, glyph_index, FT_LOAD_MONOCHROME)
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO)
Endif
widths[glyphNum] = face->glyph->advance.x/64
vOffsets[glyphNum] = face->glyph->bitmap_top
Dim As FT_Bitmap Ptr bitmap = @(face->glyph->bitmap)
If antialiased = true Then
For j = 0 To bitmap->rows -1
For k = 0 To bitmap->width -1
glyphImage[(j * textureSize * 2) + (k * 2)] = 255
glyphImage[(j * textureSize * 2) + (k * 2) + 1] = bitmap->buffer[j * bitmap->width + k]
Next
Next
Else
Dim As Ubyte temp
For j = 0 To bitmap->rows -1
For k = 0 To bitmap->pitch -1
For l = 7 To 0 Step -1
temp = (bitmap->buffer[j * bitmap->pitch + k] Shr l) And 1
If temp Then
glyphImage[(j * textureSize * 2) + ((k * 8 + (7 - l)) * 2)] = 255
glyphImage[(j * textureSize * 2) + ((k * 8 + (7 - l)) * 2) + 1] = 255
Endif
Next
Next
Next
Endif
Endif
End Sub
Sub FontGL.loadTexture(textureNum As Integer, glyphImage As Ubyte Ptr)
glBindTexture(GL_TEXTURE_2D, textures[textureNum])
glTexImage2D(GL_TEXTURE_2D, 0, 2, textureSize, textureSize, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, glyphImage)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
End Sub
Sub FontGL.uninitTextures()
glDeleteTextures(ASCII_SIZE, textures)
End Sub
Function FontGL.advance(text As String) As Single
Dim As Single total = 0
Dim As Integer i
Dim As ZString Ptr text_ = StrPtr(text)
For i = 0 To (Len(text)-1)
total += widths[text_[i]]
Next
Return total
End Function
Sub FontGL.render(x As Single, y As Single, z As Single, text As String)
glPushAttrib(GL_ENABLE_BIT)
glEnable(GL_TEXTURE_2D)
glEnable(GL_BLEND)
glDisable(GL_DEPTH_TEST)
Dim As GLint blendDest, blendSource
glGetIntegerv(GL_BLEND_DST, @blendDest)
glGetIntegerv(GL_BLEND_SRC, @blendSource)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glPushMatrix()
glTranslatef(x, y, z)
glColor4f(Color_->r, Color_->g, Color_->b, Color_->a)
Dim As Integer w, vOffset
Dim As Integer i
For i =0 To (Len(text)-1)
w = widths[text[i]]
vOffset = vOffsets[text[i]]
glBindTexture(GL_TEXTURE_2D, textures[text[i]])
glBegin(GL_QUADS)
' glTexCoord2f(0.0, 0.0): glVertex3f(0.f, (-vOffset), 0.f)
' glTexCoord2f(0.0, 1.0): glVertex3f(0.f, (-vOffset + textureSize), 0.f)
' glTexCoord2f(1.0, 1.0): glVertex3f(textureSize, (-vOffset + textureSize), 0.f)
' glTexCoord2f(1.0, 0.0): glVertex3f(textureSize, (-vOffset), 0.f)
glTexCoord2f(0.0, 1.0): glVertex3f(0.f, (vOffset), 0.f)
glTexCoord2f(0.0, 0.0): glVertex3f(0.f, (vOffset + textureSize), 0.f)
glTexCoord2f(1.0, 0.0): glVertex3f(textureSize, (vOffset + textureSize), 0.f)
glTexCoord2f(1.0, 1.0): glVertex3f(textureSize, (vOffset), 0.f)
glEnd()
glTranslatef(w, 0.f, 0.f)
Next
glPopMatrix()
glPopAttrib()
glBlendFunc(blendSource, blendDest)
End Sub
Sub FontGL.setColor(R As Single, G As Single, B As Single, A As Single)
With *this.Color_
.r = R
.g = G
.b = B
.a = A
End With
End Sub |
|
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 20.08.2008, 12:14 Titel: |
|
|
ok ich probiers mal aus...
achja: habs mit "ursprung unten links" versucht, hilf leider auch nix...
der header ist richtig, ich hab mir das mal mit nem hexeditor angesehen. egal ob mit oder ohne komprimierung, ich krieg immer ne weiße oder graue textur zurück... |
|
Nach oben |
|
|
28398
Anmeldungsdatum: 25.04.2008 Beiträge: 1917
|
Verfasst am: 21.08.2008, 19:59 Titel: |
|
|
Für die Optimierungsfreaks: Man kann auch die internen Strukturen der Klasse in eine Datei speichern und später wieder einlesen 100% schneller als FreeType 2 ;D |
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 23.08.2008, 17:26 Titel: |
|
|
@3238333938
puh, hast du vielleicht ein stück beispielcode für mich? das wäre nett |
|
Nach oben |
|
|
28398
Anmeldungsdatum: 25.04.2008 Beiträge: 1917
|
Verfasst am: 23.08.2008, 20:13 Titel: |
|
|
Code: | Dim As FontGL fgl = ("Arial", 12, TRUE, TRUE)
'fgl.initTextures() ' nur noetig bei mehreren fenstern
fgl.setColor(200, 200, 200, 255) ' grau
fgl.render(1.7, 2.0, -1.0, "Hello Wordl!")
'fgl.uninitTextures() ' nur noetig bei mehreren fenstern |
1500_PMEDIA_IS_BACK hat Folgendes geschrieben: | Ich hab mich nie wirklich mit FType2 beschäftigt. Ich bin mir aber sicher, dass es möglich ist, damit einen FBGFX-Grafikpuffer zu befüllen, diesen in eine OpenGL-Textur umzuwandeln - und zu verwenden.
Spiele machen dies für gew. mit einer vorgerenderten Font-Textur, wie sie z.B. mit dem Bitmap Font Builder (http://www.lmnopc.com/bitmapfontbuilder/) erstellt werden können. Eine Routine zum verwenden (muss leicht abgewandelt werden) findet sich in Stormy's 2D for OpenGL-Tutorial, welches auch die anderen "Arbeitsweisen" von OpenGL ein wenig hinterleuchtet. Leider ist offenbar derzeitig der Downloadlink down. |
Ich habe kenne kein aktuelles Spiel, was diese Technologie verwendet. Oblivion, Crysis, F.E.A.R., HL2 usw. usf. verwenden TrueType Fonts.
Allein schon um UTF nutzen zu können, ist es deutlich sinnvoller TTF zu nutzen. Von der Qualität will ich gar nicht erst reden. |
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 26.08.2008, 16:48 Titel: |
|
|
danke.
und HL2 ist klasse |
|
Nach oben |
|
|
28398
Anmeldungsdatum: 25.04.2008 Beiträge: 1917
|
Verfasst am: 26.08.2008, 17:51 Titel: |
|
|
sts hat Folgendes geschrieben: | und HL2 ist klasse | |
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 27.08.2008, 12:21 Titel: |
|
|
sorry, aber das beispiel geht nicht. er meckert bei Code: | Dim As FontGL fgl = ("Arial", 12, TRUE, TRUE) |
fbc hat Folgendes geschrieben: | "expecting ")" found ","" |
|
|
Nach oben |
|
|
28398
Anmeldungsdatum: 25.04.2008 Beiträge: 1917
|
Verfasst am: 27.08.2008, 15:48 Titel: |
|
|
Code: | DIM AS FontGL fgl = ("Arial", 12) |
|
|
Nach oben |
|
|
darkinsanity aka sts
Anmeldungsdatum: 01.11.2006 Beiträge: 456
|
Verfasst am: 05.09.2008, 14:30 Titel: |
|
|
das geht leider auch nicht. anscheinend mag fb das mit constructor und destructor nicht. wenn ich die einfach zu subs mache, und sie aufrufe, funktioniert das nicht, ich bekomme einen schwarzen bildschirm. _________________ Traue keinem Computer, den du nicht aus dem Fenster werfen kannst -- Steve Wozniak |
|
Nach oben |
|
|
|
|
Du kannst keine Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum nicht antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen.
|
|