Permalink
Browse files

setalpha so that blending works properly with fonts in opengl

  • Loading branch information...
1 parent e568a16 commit f757caf8381b950eb9abec880e1285a4859896bb @dwrensha dwrensha committed Oct 21, 2012
Showing with 90 additions and 51 deletions.
  1. +10 −2 examples/opengl/font.sml
  2. +8 −0 examples/opengl/game.sml
  3. +7 −5 sdlml/sdl-sig.sml
  4. +54 −43 sdlml/sdl.sml
  5. +11 −1 sdlml/sdlml.c
View
@@ -4,17 +4,25 @@ structure Font = struct
" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ^
"`-=[]\\;',./~!@#$%^&*()_+{}|:\"<>?"
+ val surf = Graphics.requireimage "media/graphics/font.png"
+
+ val () = SDL.setalpha surf false false 0w0
+
structure Normal = FontFn
- (val surf = Graphics.requireimage "media/graphics/font.png"
+ (val surf = surf
val charmap = charmap
val width = 9
val height = 16
val styles = 6
val overlap = 1
val dims = 3)
+ val surfhuge = Graphics.requireimage "media/graphics/fonthuge.png"
+
+ val () = SDL.setalpha surfhuge false false 0w0
+
structure Huge = FontFn
- (val surf = Graphics.requireimage "media/graphics/fonthuge.png"
+ (val surf = surfhuge
val charmap = charmap
val width = 27
val height = 48
View
@@ -48,6 +48,8 @@ struct
val message = make_message "font uses glDrawPixels; robot uses texture mapping"
+ val message2 = make_message "sweeeeeeeeet"
+
fun load_texture surface =
let
val w = SDL.surface_width surface
@@ -137,6 +139,12 @@ struct
glPixelZoom 1.0 ~1.0;
blit message;
+ (* draw message2 *)
+ glColor3f 1.0 1.0 1.0;
+ glRasterPos2d ~4.5 3.0;
+ glPixelZoom 1.0 ~1.0;
+ blit message2;
+
glEnable GL_TEXTURE_2D;
glColor3f 1.0 1.0 1.0;
View
@@ -348,7 +348,7 @@ sig
val clippixel : surface * int * int * color -> unit
val getpixel : surface * int * int -> color
- val getpixels : surface -> MLton.Pointer.t
+ val getpixels : surface -> MLton.Pointer.t
val is_rgb : surface -> bool
val get_bytes_per_pixel : surface -> int
@@ -358,7 +358,7 @@ sig
val drawcircle : surface * int * int * int * color -> unit
(* drawline (surf, x0, y0, x1, y1, color) *)
val drawline : surface * int * int * int * int * color -> unit
- (* drawrect (surf, x0, y0, x1, y1, color)
+ (* drawrect (surf, x0, y0, x1, y1, color)
Axis aligned hollow rectangle. Includes corners. *)
val drawbox : surface * int * int * int * int * color -> unit
@@ -376,6 +376,8 @@ sig
(* invalidates the surface *)
val freesurface : surface -> unit
+ val setalpha : surface -> bool -> bool -> Word8.word -> unit
+
val version : unit -> { major : int, minor : int, patch : int }
(* These are not separate structures because they rely on access to the
@@ -401,8 +403,8 @@ sig
(* make an alpha rectangle with a vertical gradient between the two
specified colors. bias should be between 0 and 1; a higher bias
means the gradient will have more of the bottom color. *)
- val makealpharectgrad : { w : int, h : int,
- ctop : color, cbot : color,
+ val makealpharectgrad : { w : int, h : int,
+ ctop : color, cbot : color,
bias : real } -> surface
(* create a version of the surface that's 50% transparent *)
@@ -411,7 +413,7 @@ sig
(* make a surface twice as wide and twice as tall, doing nearest-neighbor
interpolation. *)
val surf2x : surface -> surface
-
+
val blit16x : surface * int * int * int * int * surface * int * int -> unit
end
Oops, something went wrong.

0 comments on commit f757caf

Please sign in to comment.