Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 544

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 199

Deprecated: Creation of dynamic property Automattic\Jetpack\Connection\Manager::$error_handler is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php on line 91

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Instagram_Gallery::$is_wpcom is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-instagram-gallery.php on line 23

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Mailchimp::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-mailchimp.php on line 17

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Tweetstorm_Gather::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-tweetstorm-gather.php on line 21

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Tweetstorm_Gather::$is_wpcom is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-tweetstorm-gather.php on line 22

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Gutenberg_Available_Extensions::$wpcom_is_site_specific_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/gutenberg-available-extensions.php on line 20

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Memberships::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/memberships.php on line 23

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Memberships::$wpcom_is_site_specific_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/memberships.php on line 24

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Subscribers::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/subscribers.php on line 15

Deprecated: Creation of dynamic property Automattic\Jetpack\Sync\Queue::$random_int is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-queue.php on line 38

Deprecated: Creation of dynamic property Automattic\Jetpack\Sync\Queue::$random_int is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-queue.php on line 38

Deprecated: Creation of dynamic property WPCOM_Widget_Goodreads::$shelves is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/modules/widgets/goodreads.php on line 33

Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /var/www/twodee/blog/wp-includes/script-loader.php on line 348

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_classic_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 347

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 349

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block_side is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 350

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$panels_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 351

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$used_block_buttons is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 354

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 3030

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Warning: Cannot modify header information - headers already sent by (output started at /var/www/twodee/blog/wp-includes/class-wp-block-list.php:14) in /var/www/twodee/blog/wp-includes/feed-rss2.php on line 8
mobile – teaching machines https://twodee.org/blog Fri, 15 Mar 2013 14:36:25 +0000 en-US hourly 1 https://wordpress.org/?v=5.7.1 SIGITE Talk https://twodee.org/blog/5022 https://twodee.org/blog/5022#respond Sat, 13 Oct 2012 03:19:32 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=5022 [...]]]> I’m giving a talk on Paul Wagner’s MOBILE project at SIGITE 2012. Following is a draft of my presentation.

* * *

Many of us have had those nightmares where we discover we’ve been enrolled in a class but forgot to attend. The final exam is in an hour. Thankfully, our panic wakes us. Those of us who are information technology educators suffer a similar nightmare: we’re scheduled to put on a hands-on workshop in a few minutes, and none of the computers are working properly. Panic kicks in and we hope to wake up soon. But we never do, because this nightmare is reality. Conducting any educational activity that involves technology more advanced than pen and paper is fraught with difficulties: software is missing, firewalls block programs from running, machines are inconsistently imaged. These are all problems that are supposed to have been solved! There’s only one way for it all to go smoothly, but so many ways for it to fail.

We face this nightmare recurringly even at the professional level. In the early 2000s, when this project got its start, 50% of the workshops we attended at conferences for technology educators suffered some degree of technology configuration problem that sidetracked the presentation. When the time came for the first author of our paper, Paul Wagner, to put on his own hands-on computer security workshop, he refused to let configuration problems derail him. Instead of working with machines beyond his administrative control, he acquired a bunch of laptops, imaged them with the software he needed, and shipped them to the conference. That was a pretty expensive move, but an NSF CCLI grant helped. The workshop went smoothly, for three years in a row. Then in 2008, he and his team tried a bold move—they didn’t bring the laptops. How’d they do it? Participants brought their own notebook computers and he had them boot from external USB drives that he had previously configured. The workshop ran fine. Afterward a question arose: “can we generalize this setup?” And the MOBILE project was born.

MOBILE stands for the MOBile Interactive Learning Environment. Its premise is simple: let’s eliminate the risk of setting up ad hoc computer labs for workshops. Let’s use others’ machines, but let’s avoid the dangers of doing so. Others’ machines typically require accounts and are protected by cautious system administrators and have all sorts of different operating systems and software on them. Instead, let’s run our own customized and homogeneous teaching environment on top others’ hardware. I wish there was more magic to it, but we can achieve this through very cheap technology and readily available software. Here’s how you’d make your own MOBILE project:

  1. Install a baseline operating system on some machine. This is the foundation of our homogenous workshop environment. It needs to be slim in size in order to fit on USB media or be downloaded in a reasonable amount of time. It needs to be unencumbered by licensing issues to avoid costs. It also needs to be at least somewhat like what participants are used to. Our current choice has been Ubuntu Linux. It’s free and graphical, and we’ve slimmed up as much as possible. We can fit it easily on an 8 GB drive. Normally, installation of an OS requires you to pass through a gauntlet of dialogs to set up your machine. In MOBILE, we turn installation into just a few button clicks using a seed file to automatically configure the installation and create user accounts.
  2. Preinstall software. Hands-on workshops likely involve custom software like interactive development environments like Eclipse or Netbeans, network monitoring software like Wireshark or nmap, libraries like OpenGL or XML parsers, and so on. This needs to be done on only one machine and it can be done by us, the workshop administrators. We avoid the inevitable failure of our participants to follow our perfectly-written instructions, which would mean distracting troubleshooting during our event. As part of this step, we acknowledge that not everyone can use Linux for their workshop. So, one of the pieces of software we include on MOBILE is VirtualBox. If we have licenses, we include virtual machine images for Windows or other flavors of operating systems, like Solaris or 64-bit versions. Since the license agreement for MacOS doesn’t allow running its OS on non-Apple hardware, we haven’t tried virtualizing that OS out.
  3. Create a suite of workshop administration tools. During a workshop, we may want to distribute files to all of our participants dynamically. Or install software that we forgot to preinstall. Or, in a workshop on network security, inspect a participant’s configuration. As part of MOBILE, we provide tools for easily exchanging files and running custom scripts that run on participants’ machines.
  4. Clone template system image to other media. This is done through a tool we name mobileclone. It supports mirroring from one storage device to another. Our workflow has been to set up MOBILE on an external drive, then insert a second and clone onto it. Insert a third and clone on to it. Hire an undergraduate and then we soon end up with twenty external drives without too much trouble. This is the one place where it’s hard to avoid cost. In the workshops we’ve run with MOBILE, we’ve provided USB storage devices. We could avoid this cost by putting a system image up for download. We’ve not done that because the download sizes are large and the process of expanding the image is prone to user error—exactly one of the problems we are trying to avoid.
  5. Distribute cloned systems. Boot from media.
  6. Conduct workshop. Answer questions on content, not configuration. Bask in not running into these problems: software requiring administrator privileges, missing libraries, cold-hearted system administrators, computer labs whose doors are locked (participants can use their own laptops; labs are unnecessary!), and inconsistently configured machines. We know exactly what the menus look like and where software is installed. We can write one set of instructions instead of a Choose Your Own Adventure novel.

That’s the process of using MOBILE.

In training others to use MOBILE, we’ve become acquainted with several initial questions that arise. Let me address a few of those.

  1. Why not just use a virtual machine image? Wouldn’t that be simpler? It’s true, but we envisioned that several problems would still exist with a pure virtual solution. The participant’s host environment would still need to be set up. If the workshop took place in a computer lab rather than on participants’ own notebook computers, guest accounts would be required and we’d have to coax the sysadmins to install the virtual machine software. Distribution of large system images would still be a problem. The indirection of virtual machines can also be a pain to deal with. Working with host machine hardware like network interfaces, USB drives, and graphics card doesn’t always work smoothly.
  2. Aren’t you endangering participants’ machines? No. MOBILE stands on its own media. It runs directly on the hardware of the host machine rather than through some virtualization layer, but the hard drive itself, the part that we really want to protect, is not automatically mounted in MOBILE. Any disk writes or corruptions will happen to the media that MOBILE is running on.
  3. Isn’t this slow? You’re running from external media. It can be slow, yes. It doesn’t have to be. The slowest activity will be disk reads and writes. If a program is resident in memory and doesn’t do a lot of disk I/O, it should run as fast as a program from internal storage. The more RAM in a participant machine, the better.

The next big question is how are we using this? The prototype system was first deployed in a series of four SIGCSE computer security workshops. The evaluations were very positive and the workshops did not get derailed by computer issues. The positive feedback we received from these workshops led us to generalize our tools in the first place. We’ve built modules to test workshops on computer graphics, introductory programming, and Android development. We’re currently creating an environment to support an ACM programming contest site. This past summer, we assembled a focus group of educators to evaluate it. I’ll share a bit of the feedback we’ve received from this group…

That said, our purpose in sharing this tool is to serve our colleagues and make hands-on technology workshops run more smoothly. If you are putting on a workshop in some environment outside of your control, we suggest you give MOBILE a try. Instructions for setting up your initial environment and using the administrative tools are available at http://www.cs.uwec.edu/mobile.

]]>
https://twodee.org/blog/5022/feed 0
Example case studies https://twodee.org/blog/2924 https://twodee.org/blog/2924#respond Mon, 16 Jan 2012 20:12:23 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=2924 OpenGL Example

Installation needs:

  • OpenGL driver
  • GLUT

Code:

#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>

/* ------------------------------------------------------------------------- */

int width = 512;
int height = 512;
float theta = 0.0f;

/* ------------------------------------------------------------------------- */

void display(void) {
  glViewport(0, 0, width, height);

  glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
  glClear(GL_COLOR_BUFFER_BIT);

  glColor3f(0.0f, 0.0f, 0.0f);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glRotatef(theta, 1.0f, 0.0f, 0.0f);
  glutWireTorus(0.3f, 0.7f, 10, 10);

  glutSwapBuffers();
}

/* ------------------------------------------------------------------------- */

void resize_window(int new_width, int new_height) {
  width = new_width;
  height = new_height;
}

/* ------------------------------------------------------------------------- */

void special_keys_handler(int key, int x, int y) {
  switch (key) {
    case GLUT_KEY_UP:
      theta += 5.0f;
      break;
    case GLUT_KEY_DOWN:
      theta -= 5.0f;
      break;
    default:
      break;
  }
  glutPostRedisplay();
}

/* ------------------------------------------------------------------------- */

int main(int argc, char **argv) {
  glutInitDisplayString("alpha rgba double");
  glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
  glutInitWindowSize(width, height);
  glutInit(&argc, argv);

  glutCreateWindow("3-D Application");
  glutDisplayFunc(display);
  glutReshapeFunc(resize_window);
  glutSpecialFunc(special_keys_handler);

  glutMainLoop();

  return 0;
}

/* ------------------------------------------------------------------------- */

Android example

Installation needs:

  • Eclipse
  • Android SDK
  • Eclipse ADT plugin
  • Android virtual device

Code:

public class Randaurant extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
  }

  @Override
  public boolean onTouchEvent(MotionEvent event) {
    TextView label = (TextView) findViewById(R.id.destination);
    label.setText(getRandomRestaurant());
    return true;
  }
  
  private static String getRandomRestaurant() {
    int random = new Random().nextInt(100) + 1;
    if (random < 10) {
      return "Hooligan's";
    } else if (random < 50) {
      return "Acoustic Cafe";
    } else {
      return "Fuji Steakhouse";
    }
  }
}
]]>
https://twodee.org/blog/2924/feed 0