World Coordinate System: You Choose! E.g., use km from Prime Meridian & Equator set_visible_world (-2000, 4010, -1950, 4025) world: (-1950,4034.7) world: (-2000,4000.3) Maintains aspect ratio
Screen (Pixel) Coordinates: Fixed world: (-1950,4034.7) world: (-2000,4000.3) screen (900, 619)
Panning & Zooming: EasyGL Transforms world: (-1960,4026.5) easygl changes the mapping from world screen pixels Calls your drawscreen () Only a part of your picture shows up on screen world: (-1990,4007.8)
Panning & Zooming: EasyGL Transforms You can draw everything But will only see the part that maps to the screen world: (-1960,4026.5) world: (-1990,4007.8)
Pan & Zoom (Transform) Implications Your drawscreen() callback can always draw the whole map (world) Only proper part will show up on screen Costs some CPU time to draw objects that aren’t on screen, but less than you might expect (pre-clipped) Don’t call set_visible_world() in drawscreen() Would disable panning and zooming
Screen Coordinates for Fixed Overlays What if I want to draw a scale in the upper-left? Don’t want it to move / resize with pan & zoom set_coordinate_system (GL_SCREEN); // All drawing in screen (pixel) coords until you call set_coordinate_system (GL_WORLD) 0 1 km
Level of Detail Zoomed way in can show small details (street names, small streets, …) Zoomed way out draw every detail:
Level of Detail Utilities setfont (10); // 10 point font 10/72 inch high t_point center (-1970, 4020); drawtext (center, “Awesome street”); float streetLength = 0.2; // 200 m long. drawtext (center, “Awesome street”, streetLen, streetLen); Fonts are in screen coordinates, not world coordinates. What if this text is much longer than the street? Awesome Street My Street Electric Avenue AYour Street Sesame Street E. Street Easy Street Text won’t be drawn if it is wider or higher than these numbers, in world coordinates drawtext (t_point cen, string text, bound_x = FLT_MAX, bound_y=FLT_MAX) Last two parameters optional: default to huge boundary (always draw)
Level of Detail Utilities t_bound_box get_visible_world(); Returns a rectangle the world coordinates of the screen edges Use to decide if you’re zoomed in or not bool LOD_screen_area_test(t_bound_box test, float screen_area_threshold); Returns true if the (world coordinate) test rectangle will fill more than screen_area_threshold pixels
Hit Testing Mouse clicked here What did I click on?
Hit Testing easygl does not know what you drew “Immediate mode” graphics Draws the pixels for a line, etc. Does not remember the line! Hit testing: you must code act_on_button_press (x, y, button_info) What is closest to that (x,y)? Code demo … Hit testing & highlighting
Constant Redraws Screen Can Flash clearscreen(), then draw Can see flashes as graphics appear & disappear
Single vs. Double Buffering Single Buffer (default) set_drawing_buffer(OFF_SCREEN) drawline() … drawline() … copy_off_screen_buffer_to_screen() Last line in your drawscreen() callback No redraw flashes movement looks smoother
Friday: Guest Lecture Leaders from 3 major tech companies in Southern Ontario Shawn Malhotra, Director, Intel Deshanand Singh, Senior Manager, Amazon Paul Leventis, Technical lead & manager, Google Topics Project management & communication at each company What each looks for in engineers