Exemplo n.º 1
0
/* joystick fn is a bit different */
static void register_joystick(int flag, int interval)
{
    if (flag) {
        glutJoystickFunc(joystick_cb, interval);
    } else {
        glutJoystickFunc(NULL, interval);
    }
}
Exemplo n.º 2
0
/* ARGSUSED */
void
glutjoystickfunc(GLUTjoystickFCB joystick, int pollInterval)
{
#if 0  /* XXX No IRIX joystick support for now. */
  if(joystick == (GLUTjoystickFCB) glutnull_) {
    glutJoystickFunc(NULL, pollInterval);
  } else {
    glutJoystickFunc(fortranJoystickWrapper, pollInterval);
    __glutCurrentWindow->fjoystick = joystick;
  }
#endif
}
Exemplo n.º 3
0
static void registerCallbacks ()
{
  glutIdleFunc(gst_glut_IdleFunc);
  glutKeyboardFunc(gst_glut_KeyboardFunc);
  glutSpecialFunc(gst_glut_SpecialFunc);
  glutReshapeFunc(gst_glut_ReshapeFunc);
  glutVisibilityFunc(gst_glut_VisibilityFunc);
  glutDisplayFunc(gst_glut_DisplayFunc); 
  glutMouseFunc(gst_glut_MouseFunc);
  glutMotionFunc(gst_glut_MotionFunc);
  glutPassiveMotionFunc(gst_glut_PassiveMotionFunc);
  glutEntryFunc(gst_glut_EntryFunc);
  glutKeyboardUpFunc(gst_glut_KeyboardUpFunc);
  glutSpecialUpFunc(gst_glut_SpecialUpFunc);
  glutMenuStateFunc(gst_glut_MenuStateFunc);
  glutMenuStatusFunc(gst_glut_MenuStatusFunc);
  glutOverlayDisplayFunc(gst_glut_OverlayDisplayFunc);
  glutWindowStatusFunc(gst_glut_WindowStatusFunc);
  glutSpaceballMotionFunc(gst_glut_SpaceballMotionFunc);
  glutSpaceballRotateFunc(gst_glut_SpaceballRotateFunc);
  glutSpaceballButtonFunc(gst_glut_SpaceballButtonFunc);
  glutButtonBoxFunc(gst_glut_ButtonBoxFunc);
  glutDialsFunc(gst_glut_DialsFunc);
  glutTabletMotionFunc(gst_glut_TabletMotionFunc);
  glutTabletButtonFunc(gst_glut_TabletButtonFunc);
  glutWMCloseFunc(gst_glut_WMCloseFunc);

#if 0
  glutJoystickFunc(gst_glut_JoystickFunc);
  glutMouseWheelFunc(gst_glut_MouseWheelFunc);
  glutCloseFunc(gst_glut_CloseFunc);
  glutMenuDestroyFunc(gst_glut_MenuDestroyFunc);
#endif
}
Exemplo n.º 4
0
int main(int argc, char *argv[]){

  problem_init();

  glutInit(&argc, argv);
  /* glutInitDisplayMode(GLUT_RGBA); */
  glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
  glutInitWindowPosition(100,100);
  glutInitWindowSize(glwidth,glheight);
  /* glutInitWindowSize(WINWIDTH, WINHEIGHT); */
  glutCreateWindow("tree collision detection");

  glutKeyboardFunc(keyboard);
  glutJoystickFunc(joystick, 10);
  glutMouseFunc(mouse);
  glutMotionFunc(mousemove);

  glutDisplayFunc(display);
  glutIdleFunc(iterate);
  init();
  /*   glutReshapeFunc(reshape); */
  glClearColor(0.0f, 0.0f, .5f, 0.0f);
  glClearDepth(1.0f);

  glutMainLoop();

  return 0;
}
Exemplo n.º 5
0
void
menu(int value)
{
  switch(value) {
  case 1:
    glutJoystickFunc(joystick, 100);
    glutIdleFunc(NULL);
    break;
  case 2:
    glutJoystickFunc(NULL, 0);
    glutIdleFunc(NULL);
    break;
  case 3:
    glutJoystickFunc(joystick, 0);
    glutIdleFunc(joyPoll);
    break;
  }
}
Exemplo n.º 6
0
static VALUE
glut_JoystickFunc(VALUE self, VALUE callback, VALUE _poll_interval) {
	int win = glutGetWindow();
	int poll_interval = NUM2INT(_poll_interval);

	if (win == 0)
		rb_raise(rb_eRuntimeError, "glutJoystickFunc needs current window");

  callback = rb_glut_check_callback(self, callback);

	rb_ary_store(joystick_func, win, callback);

	if (NIL_P(callback))
		glutJoystickFunc(NULL, -1);
	else
		glutJoystickFunc(glut_JoystickFuncCallback0, poll_interval);

	return Qnil;
}
Exemplo n.º 7
0
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutJoystickFunc
 * Signature: (Lscala/Function4;I)V
 */
JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutJoystickFunc
  (JNIEnv * jenv, jobject jobj, jobject arg1, jint arg2) {

  if(jvm == NULL) {
    (*jenv)->GetJavaVM(jenv, &jvm);
  }

  // fixme remove old obj if exists

  glutJoystickFunc_obj = (*jenv)->NewGlobalRef(jenv, arg1);
  return glutJoystickFunc(glutJoystickFuncCallback, arg2);

}
Exemplo n.º 8
0
int main(int argc, char* argv[])
{
	psp_log("main starting\n");

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
        glutInitWindowSize(480, 272);
	glutCreateWindow( __FILE__ );
	glutKeyboardFunc(keydown);
	glutKeyboardUpFunc(keyup);
	glutJoystickFunc(joystick, 0);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);

	GLCHK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, texture));

	glutMainLoop();
	return 0;
}
Exemplo n.º 9
0
void
initWindow(void)
{
  glutIgnoreKeyRepeat(1);

  glutDisplayFunc(display);
  glutVisibilityFunc(visible);
  glutKeyboardFunc(key);
  glutKeyboardUpFunc(keyup);
  glutSpecialFunc(special);
  glutSpecialUpFunc(specialup);
  glutJoystickFunc(joystick, 100);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(0, MAX_X, 0, MAX_Y, 0, MAX_Y);
  glMatrixMode(GL_MODELVIEW); 
  glPointSize(3.0);

  currentWindow = glutGetWindow();
}
Exemplo n.º 10
0
int main(int argc, char *argv[]) {
	
	//initCube(&cube0, 30.0f, 30.0f, 30.0f);
		
	setParticle(particles, isovalue);

	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); // TODO: test on psp
	glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT); // TODO: test on psp
	glutInitWindowPosition(0,0); // TODO: test on psp
	glutCreateWindow(__FILE__);
	glutKeyboardFunc(keydown);
	glutKeyboardUpFunc(keyup);
	glutJoystickFunc(joystick, 0);
	//glutReshapeFunc(reshape);
	//glutReshapeFunc(setupGL);
	glutDisplayFunc(display2);

	setupGL(SCREEN_WIDTH, SCREEN_HEIGHT);

	glutMainLoop();

	return 0;
}
Exemplo n.º 11
0
/////////////////////////////////////////////////////////
// createMess
//
/////////////////////////////////////////////////////////
bool gemglutwindow :: create(void)
{
  if(m_window) {
    error("window already made!");
    return false;
  }


#ifdef FREEGLUT
  // display list sharing (with FreeGLUT)
  if(s_windowmap.size()>0) {
    std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin();
    gemglutwindow*other=NULL;
    other=it->second;
    if(other && other->makeCurrent()) {
      glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT );
    }
  }
#endif

  unsigned int mode=GLUT_RGB | GLUT_DEPTH;
  if(2==m_buffer)
    mode|=GLUT_DOUBLE;
  else
    mode|=GLUT_SINGLE;

  glutInitDisplayMode(mode);

  m_window=glutCreateWindow(m_title.c_str());
  s_windowmap[m_window]=this;

  glutDisplayFunc   (&gemglutwindow::displayCb);
  glutVisibilityFunc(&gemglutwindow::visibleCb);

  glutCloseFunc     (&gemglutwindow::closeCb);
#ifdef FREEGLUT
  glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
#endif

  glutKeyboardFunc(&gemglutwindow::keyboardCb);
  glutSpecialFunc(&gemglutwindow::specialCb);
  glutReshapeFunc(&gemglutwindow::reshapeCb);
  glutMouseFunc(&gemglutwindow::mouseCb);
  glutMotionFunc(&gemglutwindow::motionCb);
  glutPassiveMotionFunc(&gemglutwindow::passivemotionCb);
  glutEntryFunc(&gemglutwindow::entryCb);
  glutKeyboardUpFunc(&gemglutwindow::keyboardupCb);
  glutSpecialUpFunc(&gemglutwindow::specialupCb);
  glutJoystickFunc(&gemglutwindow::joystickCb, 20);

  glutMenuStateFunc(&gemglutwindow::menustateCb);
  glutMenuStatusFunc(&gemglutwindow::menustatusCb);

  glutWindowStatusFunc(&gemglutwindow::windowstatusCb);

  //  glutNameFunc(&gemglutwindow::nameCb);

  if(!createGemWindow()) {
    destroyMess();
    return false;
  }
  titleMess(m_title);
  fullscreenMess(m_fullscreen);

  dispatch();
  return true;
}
Exemplo n.º 12
0
/////////////////////////////////////////////////////////
// createMess
//
/////////////////////////////////////////////////////////
bool gemglutwindow :: create(void)
{
  if(m_window) {
    error("window already made!");
    return false;
  }


#ifdef FREEGLUT
  // display list sharing (with FreeGLUT)
  if(s_windowmap.size()>0) {
    std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin();
    gemglutwindow*other=NULL;
    other=it->second;
    if(other && other->makeCurrent()) {
      glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT );
    }
  }
#endif

  unsigned int mode=GLUT_RGB | GLUT_DEPTH;
  if(2==m_buffer)
    mode|=GLUT_DOUBLE;
  else
    mode|=GLUT_SINGLE;

  glutInitDisplayMode(mode);

#ifdef FREEGLUT
  //  glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
  glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
  glutSetOption(GLUT_INIT_WINDOW_X, m_xoffset);
  glutSetOption(GLUT_INIT_WINDOW_Y, m_yoffset);
  glutSetOption(GLUT_INIT_WINDOW_WIDTH, m_width);
  glutSetOption(GLUT_INIT_WINDOW_HEIGHT, m_height);
#endif

  m_window=glutCreateWindow(m_title.c_str());
  s_windowmap[m_window]=this;

  glutReshapeWindow(m_width, m_height);
  glutPositionWindow(m_xoffset, m_yoffset);

  glutCloseFunc     (&closeCb);

  glutKeyboardFunc(&keyboardCb);
  glutSpecialFunc(&specialCb);
  glutReshapeFunc(&reshapeCb);
  glutKeyboardUpFunc(&keyboardupCb);
  glutSpecialUpFunc(&specialupCb);
  glutJoystickFunc(&joystickCb, 20);

  glutMenuStateFunc(&menustateCb);
  glutMenuStatusFunc(&menustatusCb);

  glutWindowStatusFunc(&windowstatusCb);

#if (defined GLUT_HAS_MULTI) && (GLUT_HAS_MULTI > 0)
  glutMultiEntryFunc(multiEntryCb);
  glutMultiButtonFunc(multiButtonCb);
  glutMultiMotionFunc(multiMotionCb);
  glutMultiPassiveFunc(multiPassivemotionCb);
#else
  glutEntryFunc(&entryCb);
  glutMouseFunc(&mouseCb);
  glutMotionFunc(&motionCb);
  glutPassiveMotionFunc(&passivemotionCb);
#endif

  //  glutNameFunc(&nameCb);
  glutDisplayFunc   (&displayCb);
  glutVisibilityFunc(&visibleCb);


  if(!createGemWindow()) {
    destroyMess();
    return false;
  }
  titleMess(m_title);
  fullscreenMess(m_fullscreen);

  dispatch();
  return true;
}
Exemplo n.º 13
0
void gldriver_joystick_reset(void) {
    glutJoystickFunc(NULL, 0);
    glutJoystickFunc(gldriver_joystick_callback, (int)JOYSTICK_POLL_INTERVAL_MILLIS);
}
Exemplo n.º 14
0
void helper_glutJoystickFunc(IScriptFunction * scriptFunction, int pollInterval)
{
	getCurrentCallbackData()->joystick.reset(scriptFunction);
	glutJoystickFunc(&callback_glutJoystickFunc, pollInterval);
}
Exemplo n.º 15
0
int                /* O - Exit status */
main(int  argc,    /* I - Number of command-line arguments */
     char *argv[]) /* I - Command-line arguments */
    {
    glutInit(&argc, argv);
#ifdef BOOK_COVER
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
#else
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
#endif /* BOOK_COVER */
    glutInitWindowSize(792, 573);
    glutCreateWindow("Terrain Using Vertex Culling Extension");
    glutDisplayFunc(Redraw);
    if (glutDeviceGet(GLUT_HAS_JOYSTICK))
        glutJoystickFunc(Joystick, 200);
    glutKeyboardFunc(Keyboard);
    glutMotionFunc(Motion);
    glutMouseFunc(Mouse);
    glutReshapeFunc(Resize);
    glutSpecialFunc(Special);

    BuildF16();

    LandTexture = TextureLoad("land.bmp", GL_FALSE, GL_LINEAR_MIPMAP_LINEAR,
                              GL_LINEAR, GL_REPEAT);
    SkyTexture  = TextureLoad("sky.bmp", GL_FALSE, GL_LINEAR, GL_LINEAR,
                              GL_CLAMP);

    LoadTerrain(36, -112);

    puts("QUICK HELP:");
    puts("");
    puts("ESC - Quit");
    puts("',' - Slow down, '<' - Slowest");
    puts("'.' - Speed up, '>' - Fastest");
    puts("'3' - Toggle terrain");
    puts("'a' - Toggle aircraft");
    puts("'f' - Toggle fog");
    puts("'l' - Toggle lighting");
    puts("'s' - Toggle sky/clouds");
    puts("'t' - Toggle texturing");
    puts("'w' - Toggle water");
    puts("'W' - Toggle wireframe");

    printf("GL_EXTENSIONS = %s\n", glGetString(GL_EXTENSIONS));

    if (strstr(glGetString(GL_EXTENSIONS), "EXT_cull_vertex") != NULL)
        {
        UseCullVertex        = 1;
	glCullParameterfvEXT = wglGetProcAddress("glCullParameterfvEXT");
	}
    else if (strstr(glGetString(GL_EXTENSIONS), "SGI_cull_vertex") != NULL)
        {
        UseCullVertex        = 1;
	glCullParameterfvEXT = wglGetProcAddress("glCullParameterfvSGI");
	}
    else
        UseCullVertex = 0;

    glutMainLoop();

    return (0);
    }
Exemplo n.º 16
0
int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
        glutInitWindowSize(480, 272);
	glutCreateWindow( __FILE__ );

#if !SYS
	glutJoystickFunc(joystick, 0);
#else
	glutPassiveMotionFunc(motion);
#endif

	glutKeyboardFunc(keydown);
	glutKeyboardUpFunc(keyup);
	glutSpecialFunc(special_down);
	glutSpecialUpFunc(special_up);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);

	GLCHK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE));

	GLCHK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, 
			   GL_RGBA, GL_UNSIGNED_BYTE, firefox_start));
	GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
	GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));

	genmesh();

	GLCHK(glEnableClientState(GL_VERTEX_ARRAY));
	GLCHK(glVertexPointer(3, GL_FLOAT, sizeof(struct vertex), &mesh[0].x));

	GLCHK(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
	GLCHK(glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), &mesh[0].s));

	GLCHK(glEnableClientState(GL_NORMAL_ARRAY));
	GLCHK(glNormalPointer(GL_FLOAT, sizeof(struct vertex), &mesh[0].nx));

	{
		GLfloat ambient[] = { .3,.3,.3,1 };
		GLCHK(glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient));
		
		GLCHK(glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR));
	}

	{
		GLfloat diff[] = { 1,1,1,1 };
		GLfloat spec[] = { 1,1,1,1 };
		GLfloat ambient[] = { .4,.4,.4,1 };

		GLCHK(glMaterialfv(GL_FRONT, GL_DIFFUSE, diff));
		GLCHK(glMaterialfv(GL_FRONT, GL_AMBIENT, ambient));
		GLCHK(glMaterialfv(GL_FRONT, GL_SPECULAR, spec));
		GLCHK(glMateriali(GL_FRONT, GL_SHININESS, 40));
	}

	GLCHK(glLockArraysEXT(0, MESHX*MESHY));

	GLCHK(glEnable(GL_DEPTH_TEST));
	GLCHK(glClearColor(0,0,.5,1));

	GLCHK(glEnable(GL_NORMALIZE));

#if GL_PSP_bezier_patch
	GLCHK(glPatchSubdivisionPSP(8,8));
	//GLCHK(glPatchSubdivisionPSP(16,16));
	//GLCHK(glPatchSubdivisionPSP(64,64));
#endif

//	GLCHK(glPolygonOffset(1,0));
//	GLCHK(glEnable(GL_POLYGON_OFFSET_FILL));

	glutMainLoop();

	return 0;
}
Exemplo n.º 17
0
// glutJoystickFunc callback
void setJoystickFunc(int pollInterval) { glutJoystickFunc(internalJoystickFunc, pollInterval); }
Exemplo n.º 18
0
void clearJoystickFunc(int pollInterval) { glutJoystickFunc(0, pollInterval); }