Ejemplo n.º 1
0
AppWindow::AppWindow ( const char* label, int x, int y, int w, int h )
    : GlutWindow ( label, x, y, w, h )
{
    addMenuEntry ( "Option 0", evOption0 );
    addMenuEntry ( "Option 1", evOption1 );

    _viewaxis = true;
    _fovy = GS_TORAD(60.0f);
    _rotx = gspi/8.0f;
    _roty = gspi/4.0f;
    _w = w;
    _h = h;

    rt = 0.25f;
    rb = 0.25f;
    numfaces = 16;
    textureChoice = false;
    blendFactor = 0.75f;
    
    _lasttime = gs_time();
    _animateinc = 0.1f;
    _animate = true;
    _normals = false;
    _flatn = true;
    _phong = false;

    initPrograms ();
    initTextures ();
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
    //  initialize the GLUT library.
    glutInit(&argc, argv);
    // set the display mode
    glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DEPTH | GLUT_DOUBLE);
    // set the window size
    glutInitWindowSize(windowWidth, windowHeight);
    // creates a top-level window.
    glutCreateWindow("LengXuegang's Homework");
    // initialize the extension entry points
    GLenum error = glewInit();
    if (GLEW_OK != error)
    {
        fprintf(stderr, "Error: %s\n", glewGetErrorString(error));
        exit(-1);
    }

    FreeImage_Initialise(false);

    const char *version = FreeImage_GetVersion();
    fprintf(stdout, "version: %s", version);

    const char *copyright = FreeImage_GetCopyrightMessage();
    fprintf(stdout, "copyright: %s", copyright);

    initPrograms();

    GLint n = initVertex();
    if (n < 0)
    {
        fprintf(stderr, "init vertex failed");
        exit(-1);
    }

    GLint uModelMatrix = glGetUniformLocation(program->getProgramID(), "u_ModelMatrix");
    // GLint uMvpMatrix = glGetUniformLocation(program, "u_MvpMatrix");
    GLint uNormalMatrix = glGetUniformLocation(program->getProgramID(), "u_NormalMatrix");
    GLint uLightColor = glGetUniformLocation(program->getProgramID(), "u_LightColor");
    GLint uLightPosition = glGetUniformLocation(program->getProgramID(), "u_LightPosition");
    GLint uAmbientLight = glGetUniformLocation(program->getProgramID(), "u_AmbientLight");

    glUniform3f(uLightColor, 0.5, 0.9, 0.1);
    glUniform3f(uLightPosition, 1.0, 2.0, 3.0);
    glUniform3f(uAmbientLight, 0.6, 0.6, 0.6);

    // glUniformMatrix4fv(uModelMatrix, )
    // glUniformMatrix4fv(uNormalMatrix, )
    // sets the display callback for the current window.
    glutDisplayFunc(display);
    // sets the reshape callback for the current window.
    glutReshapeFunc(reshape);
    // sets the special keyboard callback for the current window.
    // glutSpecialFunc(specialKey);
    // enters the GLUT event processing loop.
    glutMainLoop();

    return 0;
}
Ejemplo n.º 3
0
 my_Descriptor()
 : h_Descriptor()
   {
     m_Name   = "fx_freeze";
     m_Author = "ccernn";
     appendParameter( new h_ParFloat("buffer","ms",PF_DEFAULT,1000,1,1000) );
     appendParameter( new h_ParFloat("size",  "",  PF_DEFAULT,1,   0,1) );
     appendParameter( new h_ParFloat("speed", "",  PF_DEFAULT,1,   0,2) );
     appendParameter( new h_ParFloat("start", "",  PF_DEFAULT,0,   0,1) );
     appendParameter( new h_ParText ("freeze","",  PF_DEFAULT,0,   2, str_freeze) );
     appendParameter( new h_ParText ("mode","",    PF_DEFAULT,1,   2, str_loopmode) );
     initPrograms(10,&m_Parameters);
   }
Ejemplo n.º 4
0
AppWindow::AppWindow ( const char* label, int x, int y, int w, int h )
    : GlutWindow ( label, x, y, w, h ), sceneRoot(new Node()), modelGroup("meshes/manifest.json", textureCache), mechwarriorRate(vec2(0.0f,0.0f)), mechwarriorRotateRate(0.0f)
{
    initPrograms ();
    
    sceneRoot->Id() = "Scene Root";
    
    // Create an instance of the mechwarrior model
    mechwarriorInstance = modelGroup.NewInstance("robot02");
    mechwarriorInstance->GetNode()->Id() = "Mechwarrior";
    sceneRoot->AddChild(mechwarriorInstance->GetNode());
    
    // Create a textured quad for the ground (tile the texture 50 times across its surface
    ground = new GLTexturedQuad(textureCache, "textures/terrain.png");
    ground->Build(groundProgram, 50.0);
    ground->GetNode()->LocalTransform().Scale() = vec3(100,1,100);
    ground->GetNode()->LocalTransform().Translation() = vec3(0,-0.001,0);
    ground->GetNode()->Id() = "Ground";
    sceneRoot->AddChild(ground->GetNode());
    
    // Setup the cameras
    cameraSelection = false;
    mechCamera = new Node();
    mechCamera->LocalTransform().Rotation() = glm::angleAxis(-glm::pi<float>(), vec3(0,1,0));
    mechCamera->LocalTransform().Translation() = glm::vec3(0,0.35,-0.95);
    mechCameraRotator = new Node();
    mechCameraRotator->LocalTransform().Translation() = glm::vec3(0,0.5,0);
    mechCameraRotator->AddChild(mechCamera);
    
    groundCamera = new Node();
    groundCamera->LocalTransform().Translation() = vec3(1, 0.65, 1);
    groundCamera->LocalTransform().Rotation() = glm::angleAxis(glm::pi<float>() / 4.0f, vec3(0,1,0)) * glm::angleAxis(-glm::pi<float>() / 16.0f, vec3(1,0,0));
    sceneRoot->AddChild(groundCamera);
    
    // Initial state for some tracking
    keys['z'] = false;
    keys['x'] = false;
    specials[GLUT_KEY_UP] = false;
    specials[GLUT_KEY_RIGHT] = false;
    specials[GLUT_KEY_LEFT] = false;
    specials[GLUT_KEY_DOWN] = false;
    
    manualPoseAnimation = new AnimationSource;
    manualPoseAnimation->Bind(mechwarriorInstance->GetModel()->Skeleton());
    manualPoseAnimation->Update(0, 0);
}
Ejemplo n.º 5
0
// Set things up and run
int main(int argc, char** argv) {
	makeWindow(argc, argv);
	acquireSharedOpenCLContext();
	initObjects();
	initPrograms();
	initFramebuffers();
	initShaders();
	setupGlutCallbacks();

	camera.pos = MakeVector(0, 0, -12);
	camera.up = MakeVector(0, 1, 0);
	camera.front = MakeVector(0, 0, 1);
	
	glutSetCursor(GLUT_CURSOR_NONE);
	glutMainLoop();

	releaseSharedOpenCLContext();
}
Ejemplo n.º 6
0
AppWindow::AppWindow ( const char* label, int x, int y, int w, int h )
          :GlutWindow ( label, x, y, w, h )
 {
   initPrograms ();
   addMenuEntry ( "Option 0", evOption0 );
   addMenuEntry ( "Option 1", evOption1 );
   _viewaxis = true;
   _fovy = GS_TORAD(120.0f);
   _rotx = _roty = 0;
   _w = w;
   _h = h;
   rotate = 0;
   speed = 0; _turnlr = 0;
   xview = 0; yview = 0;
   animate = false;
   sunx = 0.5f; suny = 1.0f; sunz = 0.8f;
   camera = true;
   sunanim = true;
 }
Ejemplo n.º 7
0
GLUSboolean init()
{
    initPrograms();

    g_pCylinderMesh = new Mesh("./model/UnitCylinder.xml");
    g_pPlaneMesh = new Mesh("./model/LargePlane.xml");
    g_pCubeMesh = new Mesh("./model/UnitCube.xml");

    glusWindowSetMouseFunc(mouseButton);
    glusWindowSetMouseMoveFunc(mouseMotion);
    glusWindowSetMouseWheelFunc(mouseWheel);

    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glFrontFace(GL_CW);

    const float depthZNear = 0.0f;
    const float depthZFar = 1.0f;

    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glDepthFunc(GL_LEQUAL);
    glDepthRange(depthZNear, depthZFar);
    glEnable(GL_DEPTH_CLAMP);

    glGenBuffers(1, &g_projectionUniformBuffer);
    glBindBuffer(GL_UNIFORM_BUFFER, g_projectionUniformBuffer);
    glBufferData(GL_UNIFORM_BUFFER, sizeof(ProjectionBlock), NULL, GL_DYNAMIC_DRAW);

    glBindBufferRange(GL_UNIFORM_BUFFER, g_projectionBlockIndex, g_projectionUniformBuffer,
            0, sizeof(ProjectionBlock));

    glBindBuffer(GL_UNIFORM_BUFFER, 0);

    return GLUS_TRUE;
}
void ShaderProgramManager::init( void )
{
	initPrograms();
	MAGICAL_RETURN_IF_ERROR();
}
Ejemplo n.º 9
0
/*
 * Go evaluator main program
 */
int main(int argc, char **argv) {
  int narg;

#ifdef HAVE_LOCALECONV
  setlocale(LC_ALL,"");		/* set up locale */
#endif

#ifdef LOCALEDIR
  bindtextdomain(PACKAGE,LOCALEDIR);
  textdomain(PACKAGE);
#endif

  initLogfile((char *) "-");
  initFileIo();        /* Set up special file handling */

  strMsg(entryPoint, NumberOf(entryPoint), "lo.boot@__boot"); /* standard entry point */

  if ((narg = getOptions(argc, argv)) < 0) {
    outMsg(logFile, _("usage: %s [-v] [-L log] [-g host:port] [-V] [-b boot:ver] [-m entry] [-r repo] [-d wd]"
                        " [-h sizeK] [-s sizeK] [-d rootdir] args ...\n"), argv[0]);
    exit(1);
  }

  // Set up repository directory
  if (uniIsLit(repoDir, "")) { // overridden?
    char *dir = getenv("LO_DIR"); /* pick up the installation directory */
    if (dir == NULL)
      dir = LODIR;                  /* Default installation path */
    uniCpy(repoDir, NumberOf(repoDir), dir);
  }

  // set up working directory
  if (uniIsLit(loCWD, "")) {
    char cbuff[MAXPATHLEN];
    char *cwd = getcwd(cbuff, NumberOf(cbuff)); /* compute current starting directory */
    if (cwd == NULL)
      syserr("cant determine current directory");
    else
      strMsg(loCWD, NumberOf(loCWD), "%s/", cwd);
  }

  if (loadManifest(repoDir) != Ok) {
    outMsg(logFile, "error in loading repository from %s", repoDir);
    exit(99);
  }

  /* IMPORTANT -- Keep the order of these set up calls */
  initGlobal(initHeapSize);    /* start up the global space */
  initClass();        /* Initialize the class handlers */
  initPrograms();      /* Initialize program handling */
  initDict();        /* Start up the dictionaries */
  install_escapes();      /* Initialize the escape table */
  initFiles();        /* initialize file tables */
  init_args(argv, argc, narg);    /* Initialize the argument list */
  init_time();        /* Initialize time stuff */

  setupSignals();

#ifdef EXECTRACE
  if (traceCount)
    atexit(dumpInsCount);
#endif

  bootstrap(entryPoint, bootPkg, bootVer);

  return EXIT_SUCCEED;          /* exit the lo system cleanly */
}