Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /trunk/sml3d/src/glfw/test/monitor-test.sml
ViewVC logotype

View of /trunk/sml3d/src/glfw/test/monitor-test.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1296 - (download) (annotate)
Sun Sep 15 13:02:25 2013 UTC (5 years, 6 months ago) by jhr
File size: 1361 byte(s)
  Add monitor test program
(* monitor-test.sml
 *
 * COPYRIGHT (c) 2013 The SML3d Project (http://sml3d.cs.uchicago.edu)
 * All rights reserved.
 *
 * Test program for GLFW joystick.
 *)

structure Main =
  struct

    structure M = GLFW.Monitor

    fun prMode curMode (mode as {size, redBits, greenBits, blueBits, refreshRate}) =
	  print(concat[
	      if (mode = curMode) then "  * " else "    ",
	      Int.toString(#w size), "x", Int.toString(#h size),
	      ", r:", Int.toString redBits, ", g:", Int.toString greenBits,
	      ", b:", Int.toString blueBits, ", ", Int.toString refreshRate, "Hz\n"
	    ])

    fun main () = let
	  val _ = GLFW.init()
	  val mon0 = M.primary()
	  fun monInfo mon = let
		val isPrimary = M.same(mon0, mon)
		val name = M.name mon
		val {width, height} = M.physicalSize mon
		val pos = M.position mon
		val SOME vMode = M.videoMode mon
		in
		  print(concat[
		      name, if isPrimary then " [PRIMARY] " else " ",
		      Int.toString width, "mm x ", Int.toString height, "mm at (",
		      Int.toString(#x pos), ",", Int.toString(#y pos), ")\n"
		    ]);
		  List.app (prMode vMode) (M.videoModes mon)
		end
	  in
	    List.app monInfo (M.monitors());
	    GLFW.terminate()
	  end
	    handle GLFW.Error.GLFW_ERROR(_, msg) => (
		   print(concat["ERROR: ", msg, "\n"]);
		   GLFW.terminate())
		 | _ => GLFW.terminate()

    val _ = main()

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0