|
|
发表于 2014-3-22 19:59:21
|
显示全部楼层
可是我又在山上......这会在山下的机房......写字符绘制函数- Shared Sub WordsToTex(ByVal Type As Integer, ByVal Index As Integer, ByRef Context As String, ByRef Color As System.Drawing.Color, ByRef FontName As String, _
- ByVal FontSize As Integer, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal Width As Integer, ByVal Height As Integer)
- Dim Image As System.Drawing.Bitmap = New Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
- Dim GDI As System.Drawing.Graphics = Graphics.FromImage(Image)
- Dim BpData As System.Drawing.Imaging.BitmapData
- Dim Rect As Rectangle = New Rectangle(0, 0, Image.Width, Image.Height)
- Dim Border As System.Drawing.Rectangle = New Rectangle(0, 0, Width, Height)
- Dim FontFamily As System.Drawing.FontFamily = New FontFamily(FontName)
- Dim Font As System.Drawing.Font = New Font(FontFamily, FontSize)
- GDI.FillRectangle(Brushes.Black, Border)
- GDI.DrawString(Context, Font, Brushes.White, PositionX, PositionY)
- BpData = Image.LockBits(Rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
- Gl.glGenTextures(1, Textures(Type, Index))
- Gl.glColor4f(1, 1, 1, 1)
- Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE)
- Gl.glBindTexture(Gl.GL_TEXTURE_2D, Textures(Type, Index))
- Gl.glTexImage2D(Gl.GL_TEXTURE_2D, MipmapLevel, Gl.GL_RGBA, Image.Width, Image.Height, 0, Gl.GL_BGR_EXT, _
- Gl.GL_UNSIGNED_BYTE, BpData.Scan0)
- Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR)
- Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR)
- Image.UnlockBits(BpData)
- Image.Dispose()
- GDI.Dispose()
- End Sub
复制代码 |
|