Example #1
0
void init(void)
{
  // vertex buffer object, used for uploading the geometry

  dumpInfo(); // Dump driver info to stdout

  // Load Model
  bunny = LoadModelPlus("bunnyplus.obj");
  bunny_model2 = LoadModelPlus("bunnyplus.obj");

  // GL inits
  glClearColor(1,1,1,0);
  //glClearColor(0.2,0.2,0.5,0); // Color in buffer upon clear buffer
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  glEnable(GL_DEPTH_TEST);
  printError("GL inits");

  // Load and compile shader
  program = loadShaders("lab2-7.vert", "lab2-7.frag"); // These are the programs that run on GPU
  printError("init shader");



  // --------------------------------------

  glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), 1, GL_TRUE, projectionMatrix);

  printError("init arrays");
}
int main(int argc, char** argv)
{
   int menuA;
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   /* add command line argument "classic" for a pre-3.x context */
   if ((argc != 2) || (strcmp (argv[1], "classic") != 0)) {
      glutInitContextVersion (3, 1);
      glutInitContextFlags (GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG);
   }
   glutInitWindowSize (500, 500); 
   glutInitWindowPosition (100, 100);
   glutCreateWindow (argv[0]);
   dumpInfo ();
   init ();
   glutDisplayFunc(display); 
   glutReshapeFunc(reshape);
   glutKeyboardFunc (keyboard);

   /* Add a menu. They have their own context and should thus work with forward compatible main windows too. */
   menuA = glutCreateMenu(samplemenu);
   glutAddMenuEntry("Sub menu A1 (01)",1);
   glutAddMenuEntry("Sub menu A2 (02)",2);
   glutAddMenuEntry("Sub menu A3 (03)",3);
   glutSetMenu(menuA);
   glutAttachMenu(GLUT_RIGHT_BUTTON);

   glutMainLoop();
   return 0;
}
Example #3
0
int main(int argc, char** argv) {
	GLuint displayMode = GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH;
	GLuint windowWid = 800, windowHgt = 600, topLtXpos = 100, 
		topLtYpos = 100;
	GLenum err;
    glutInit(&argc, argv); // init OpenGL w/ windowing system
	
    glutInitDisplayMode(displayMode);//(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowSize(windowWid, windowHgt);
    glutInitWindowPosition(topLtXpos, topLtYpos); // pos fm top left corner
    window1 = glutCreateWindow(argv[0]); 	// window title = argv[0]

    if (GLEW_OK != (err = glewInit())) {
        fprintf(stderr, "glewInit() Error: %s\n", 
            glewGetErrorString(err));
        exit(EXIT_FAILURE);
    }
    dumpInfo();
   	init();	// set OpenGL state variables f/ viewing, attributes
   
	// per active window callback(s)
    glutDisplayFunc(display); // set display callback
    glutReshapeFunc(reshape); // set reshape callback
    glutKeyboardFunc(keyboard); // set keyboard callback
    //glutSpecialFunc(specialKey); // set special keyboard callback
    glutMouseFunc(mouseButton); // set mouse callback
    
    // global callback(s)
    glutIdleFunc(idle); // set idle callback

    glutMainLoop();
    
    cleanUp();
   	exit(EXIT_SUCCESS);
}
Example #4
0
void init(void)
{
    // vertex buffer object, used for uploading the geometry
    unsigned int vertexBufferObjID;
    // Reference to shader program


    dumpInfo();

    // GL inits
    glClearColor(0.2,0.2,0.5,0);
    glDisable(GL_DEPTH_TEST);
    printError("GL inits");

    // Load and compile shader
    program = loadShaders("lab1-3.vert", "lab1-1.frag");
    printError("init shader");

    // Upload geometry to the GPU:

    // Allocate and activate Vertex Array Object
    glGenVertexArrays(1, &vertexArrayObjID);
    glBindVertexArray(vertexArrayObjID);
    // Allocate Vertex Buffer Objects
    glGenBuffers(1, &vertexBufferObjID);

    // VBO for vertex data
    glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID);
    glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
    glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
    // End of upload of geometry

    printError("init arrays");
}
Example #5
0
void DumpSections( void )
{
    dw_sectnum  sect;

    sortTables();
    for( sect = 0; sect < DW_DEBUG_MAX; ++sect ) {
        if( sect > 0 )
            printf( "\n" );
        printf( "%s:\n", sectionNames[sect] );
        switch( sect ) {
        case DW_DEBUG_ABBREV:
            dumpAbbrevs( Sections[sect].data, Sections[sect].max_offset );
            break;
        case DW_DEBUG_INFO:
            dumpInfo( Sections[sect].data, Sections[sect].max_offset );
            break;
        case DW_DEBUG_LINE:
            dumpLines( Sections[sect].data, Sections[sect].max_offset );
            break;
        case DW_DEBUG_REF:
            dumpRef( Sections[sect].data, Sections[sect].max_offset );
            break;
        case DW_DEBUG_ARANGES:
            dumpARanges( Sections[sect].data, Sections[sect].max_offset );
            break;
        case DW_DEBUG_STR:
            // Strings are displayed when dumping other sections
            break;
        default:
            dumpHex( Sections[sect].data, Sections[sect].max_offset, 0 );
            break;
        }
    }
}
Example #6
0
void init(void)
{	
  dumpInfo();

	// GL inits
	glClearColor(1,1,1,0);;
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_CULL_FACE);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	printError("GL inits");

  // Airplane
  Dynamics_Init(&forward, &up, &right, &position, &velocity);
  Airplane_Init(&thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag);
  
  // Camera
  Camera_Init(firstPersonView, &forward, &up, &position, velocity, &camera_position, &camera_look, camMatrix);
  
  // Terrain and skybox
  World_Init(&camera_position, &camera_look);

  // Init game
  Game_Init();
	
  // Projection matrix
  frustum(-0.1, 0.1, -0.1, 0.1, 0.2, 200.0, projMatrix);
	
  printError("init arrays");	
}
Example #7
0
int aclic03() {

    auto className = "edm3::A";
    dumpInfo(className);

    return 0;
}
Example #8
0
static void add_client(AppeSocket *sock, int client_fd, char *client_ip, int client_port)
{
    int i;
    AppeRemote *remote = sock->remote;

    DEBUG("add_client: enter\n");
    struct timeval timeout_r;
    timeout_r.tv_sec = 0;
    timeout_r.tv_usec = 10000;
    setsockopt(client_fd, SOL_SOCKET, SO_RCVTIMEO, (const void*)&timeout_r, sizeof(timeout_r));

    struct timeval timeout_s;
    timeout_s.tv_sec = 0;
    timeout_s.tv_usec = 10000;
    setsockopt(client_fd, SOL_SOCKET, SO_SNDTIMEO, (const void*)&timeout_s, sizeof(timeout_s));

    int buf_size = 1024 * 1024;
    setsockopt(client_fd, SOL_SOCKET, SO_SNDBUF, (const void*)&buf_size, sizeof(int));
    setsockopt(client_fd, SOL_SOCKET, SO_RCVBUF, (const void*)&buf_size, sizeof(int));

    pthread_mutex_lock(&sock->s_mutex);
    for (i = 0; i < CONNECT_MAX_REMOTE_NUM; i++) {
        if (remote[i].remote_fd == -1) {
            remote[i].remote_fd = client_fd;
            memset(remote[i].remote_ip, 0, sizeof(remote[i].remote_ip));
            strcpy(remote[i].remote_ip, client_ip);
            remote[i].remote_port = client_port;
            break;
        }
    }
    dumpInfo(sock);
    pthread_mutex_unlock(&sock->s_mutex);
    DEBUG("add_client: leave\n");
}
Example #9
0
void init(void)
{
    position.x = 10;position.y = 10;position.z = 0;
    windspeed = 0.0;
    look_at.x = 0.0;look_at.y = 10.0;look_at.z = 0.0;

	dumpInfo();

	// GL inits
	glClearColor(0.2,0.2,0.5,0);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);

	printError("GL inits");

	// Load and compile shader
	printError("init shader");

    init_billboard();
    for(int i = 0; i < NUMBER_OF_WINDMILLS; ++i) {
        init_windmill(&my_windmills[i], i);
	}

    //LoadTGATextureSimple("maskros512.tga", &bunnyTextureID);
	glutTimerFunc(20, &OnTimer, 0);

	printError("init arrays");
}
// _______________________________________________________
void KeyWordDetector::init(void (*keywordHandler)(int), void (*templateHandler)(int)) {
  // Store the handler function
  keywordHandlerFunction = keywordHandler;
  templateHandlerFunction = templateHandler;
  
  // Since the audio board uses different spi pins, we need to change those here
  if (!theBreadBoard) {
    SPI.setMOSI(7);
    SPI.setSCK(14);
  }
  // Init the SD card
  if (DEBUG_KD_MORE) Serial.print("Initializing SD card...");
  pinMode(SD_CS, OUTPUT);
  if (!SD.begin(SD_CS)) {
    if (DEBUG_KD_MORE) Serial.println("initialization failed!");
  } else {
    if (DEBUG_KD_MORE) Serial.println("initialization done.");
  }
  
  
  // Read all available MFCC data from SD card
  for (int i = 0; i < 100; i++) {
    if (SD_readMFCCData(i)) {
      if (DEBUG_KD_MORE) {
        Serial.print("Template size: ");
        Serial.print(templateKeywordFrameCount);
        Serial.println(" frames");
        //printV(templateMFCCs, templateKeywordFrameCount*NUM_MFCCS, true);
      }
      
      // Determine the longest and shortes keyword
      if (templateKeywordFrameCount < shortestTemplateSize)  shortestTemplateSize = templateKeywordFrameCount;
      if (templateKeywordFrameCount > longestTemplateSize)  longestTemplateSize = templateKeywordFrameCount; 
    } else {
      numberOfStoredTemplates = i;
      break;
    }
  }
  
  if (DEBUG_KD) {
    Serial.print("Total number of templates: ");
    Serial.println(numberOfStoredTemplates);
    Serial.print("Longest template: ");
    Serial.println(longestTemplateSize);
    Serial.print("Shortest template: ");
    Serial.println(shortestTemplateSize);
  }
  
  // Calculate the size of the needed FFT
  initFFT();
  // Generate the Mel filter bank
  generateMelFilterBank();
  // Geneerate the window function
  generateWindowFunction();
  // Calculate needed DCT coefficients
  computeDCTCoeff26(dctCoeff);
  
  if (DEBUG_KD) dumpInfo();
}
Example #11
0
int main(int argc, char *argv[])
{
    // A Scene is more "Program/Window" I think?
    Scene theScene;

    // Should init be done in the constructor? Is it more RAII?
    theScene.initScene("My Amazing Demo");
    dumpInfo();
    
    std::shared_ptr<Camera> myCamera = theScene.getCamera();
    //myCamera->setProjection(1.0, 50.0, -.5, .5, .5, -.5);
    
    myCamera->lookAt(Eigen::Vector3f(0, 10, 0), Eigen::Vector3f(0, 10, 1));

    GLuint numSeeds = 200000;
    GLfloat seeds[3*numSeeds];
    srand(300); // Random displacement for now
 
    for(int i = 0; i < 3*numSeeds; i += 3) {
        float rx = (rand() % 100)/100.0;
        float rz = (rand() % 100)/100.0;
        
        seeds[i] = rx + (i % 1000)/20.0;
        seeds[i+1] = 0;
        seeds[i+2] = rz + (i / 100)/20.0;
    }
    
    GLuint grassProgram = loadShaders("data/shaders/seeds.vs", "data/shaders/grass.gs", "data/shaders/grass.fs");
    
    auto someGrass = std::shared_ptr<Node>(new GrassNode(grassProgram, seeds, numSeeds));
    
    #define GROUND_SIZE 100.0f
    GLfloat groundGlyphPosition[] = {-GROUND_SIZE, 0.0f, GROUND_SIZE,
                                GROUND_SIZE, 0.0f, GROUND_SIZE,
                                GROUND_SIZE, 0.0f, -GROUND_SIZE,
                                -GROUND_SIZE, 0.0f, -GROUND_SIZE};

    GLuint groundGlyphIndices[] = {0, 1, 2, 2, 3, 0};
    GLfloat groundTexturePos[] = {0, 0,
                              100, 0,
                              100, 100,
                              0, 100};
    printError("pre made ground");
    GLuint grassID = 0;
    LoadTGATextureSimple("data/grass.tga", &grassID);
    GLuint groundProgram = loadShaders("data/shaders/billboard.vert", NULL, "data/shaders/billboard.frag");
    MeshNode* tmp = new MeshNode(groundProgram, groundGlyphPosition, 4u, groundGlyphIndices, 6u, groundTexturePos, 8u);
    tmp->addTexture(grassID, "texUnit");
    auto ground = std::shared_ptr<Node>(tmp);
    printError("made ground");
    theScene.add(ground);
    printError("add ground");
    theScene.add(someGrass);
    printError("add grass");
    theScene.mainLoop();
}
Example #12
0
void init(void)
{
	// vertex buffer object, used for uploading the geometry
	unsigned int vertexBufferObjID;
	unsigned int bunnyIndexBufferObjID;
	unsigned int bunnyNormalBufferObjID;
	unsigned int bunnyTexCoordBufferObjID;
	GLuint colorBufferObjID;

	glutPassiveMotionFunc(&mouseMove);
	initKeymapManager();
	glutWarpPointer(1024 / 2, 768 / 2);

	// Load windmill
	vec3 position = { 0, 0, 0 };
	load_windmill(position, &windmill);

	ground = LoadModelPlus("ground.obj");
	castle = LoadModelPlus("models/various/teapot.obj");
	skybox = LoadModelPlus("skybox.obj");

	LoadTGATextureSimple("skybox512.tga", &skybox_texture);
	LoadTGATextureSimple("grass.tga", &grass_texture);
	LoadTGATextureSimple("conc.tga", &conc_texture);

	dumpInfo();

	// GL inits
	glClearColor(1,0.2,0.5,0);
	//glFrontFace(GL_CW);
	glEnable(GL_DEPTH_TEST);
	//glEnable(GL_CULL_FACE);
	
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab3-5.vert", "lab3-5.frag");
	printError("init shader");

	// Upload projection matrix
	glUniformMatrix4fv(glGetUniformLocation(program, "gProjection"), 1, GL_TRUE, projectionMatrix);

	// Upload light data to the shader
	glUniform3fv(glGetUniformLocation(program, "lightSourcesDirPosArr"), 4, &lightSourcesDirectionsPositions[0].x);
	glUniform3fv(glGetUniformLocation(program, "lightSourcesColorArr"), 4, &lightSourcesColorsArr[0].x);
	glUniform1fv(glGetUniformLocation(program, "specularExponent"), 4, specularExponent);
	glUniform1iv(glGetUniformLocation(program, "isDirectional"), 4, isDirectional);

	glUniform1i(glGetUniformLocation(program, "TexUnit"), 0);
	glUniform1i(glGetUniformLocation(program, "TexUnit2"), 1);

	// End of upload of geometry
	printError("init arrays");
}
Example #13
0
void init(void)
{
	// two vertex buffer objects, used for uploading the
	unsigned int vertexBufferObjID;
	unsigned int texcoordBufferObjID;

	dumpInfo();

	// GL inits
	glClearColor(0.2,0.2,0.5,0);
	glEnable(GL_DEPTH_TEST);
	glDisable(GL_CULL_FACE);
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("texcube.vert", "texcube.frag");
	printError("init shader");
	
	// Upload geometry to the GPU:
	
	// Allocate and activate Vertex Array Object
	glGenVertexArrays(1, &vertexArrayObjID);
	glBindVertexArray(vertexArrayObjID);
	// Allocate Vertex Buffer Objects
	glGenBuffers(1, &vertexBufferObjID);
	glGenBuffers(1, &texcoordBufferObjID);
	
	// VBO for vertex data
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID);
	glBufferData(GL_ARRAY_BUFFER, 36*3*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
	glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); 
	glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
	
	// VBO for texcoord data
	glBindBuffer(GL_ARRAY_BUFFER, texcoordBufferObjID);
	glBufferData(GL_ARRAY_BUFFER, 36*2*sizeof(GLfloat), texcoord, GL_STATIC_DRAW);
	glVertexAttribPointer(glGetAttribLocation(program, "in_Texcoord"), 2, GL_FLOAT, GL_FALSE, 0, 0);
	glEnableVertexAttribArray(glGetAttribLocation(program, "in_Texcoord"));
	
	glUniformMatrix4fv(glGetUniformLocation(program, "translationMatrix"), 1, GL_TRUE, translationMatrix);
	glUniformMatrix4fv(glGetUniformLocation(program, "rotationMatrix"), 1, GL_TRUE, rotationMatrix);
	glUniformMatrix4fv(glGetUniformLocation(program, "projMatrix"), 1, GL_TRUE, projectionMatrix);

	// End of upload of geometry

	glUniform1i(glGetUniformLocation(program, "tex"), 0); // Texture unit 0
	LoadTGATextureSimple("maskros512.tga", &tex);

	printError("init arrays");
}
Example #14
0
void init(void)
{
	// vertex buffer object, used for uploading the geometry
	unsigned int vertexBufferObjID;
	unsigned int colorBufferObjID;

	dumpInfo(); // Dump driver info to stdout

	// GL inits
	glClearColor(0.2,0.2,0.5,0); // Color in buffer upon clear buffer
	glDisable(GL_DEPTH_TEST); // Since 2D I guess?
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab1-3.vert", "lab1-3.frag"); // These are the programs that run on GPU
	printError("init shader");

	// Upload geometry to the GPU:

	// Allocate and activate Vertex Array Object
	glGenVertexArrays(1, &vertexArrayObjID); // Generate one vertex array object
	glBindVertexArray(vertexArrayObjID); 		// Bind vertex array object to use

	// Allocate Vertex Buffer Objects
	glGenBuffers(1, &vertexBufferObjID); // Generate one vertex buffer
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID); // Bind generated array buffer to GL_ARRAY_BUFFER
	glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW); // Upload geometry (vertices) to vertex array buffer

	// Upload program to and enable program (=shaders) on GPU
	glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0);
		// Choose location of our shader,  vector size 3 (3 scalars per vertice),
		// type of data (GL_FLOAT).
		// The two zeros at the end are offsets between each value and initial offset.

	glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
		// Enable program (shader) with position

	// End of upload of geometry

	// ---------------------------------------
	// Upload color
	glUniform4fv(glGetUniformLocation(program, "color"), 1, color);

	// --------------------------------------

	glUniformMatrix4fv(glGetUniformLocation(program, "translMatrix"), 1, GL_TRUE, translMatrix);

	printError("init arrays");
}
Example #15
0
void init(void)
{
	dumpInfo();

        m = LoadModel("bunny.obj");

	// GL inits
	glClearColor(0.0,0.3,0.3,0);
        glEnable(GL_DEPTH_TEST);
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab1-8.vert", "lab1-8.frag");
	printError("init shader");
	
	// Upload geometry to the GPU:
	
	// Allocate and activate Vertex Array Object
        glGenVertexArrays(1, &bunnyVertexArrayObjID);
        glGenBuffers(1, &bunnyVertexBufferObjID);
        glGenBuffers(1, &bunnyIndexBufferObjID);
        glGenBuffers(1, &bunnyNormalBufferObjID);

        glBindVertexArray(bunnyVertexArrayObjID);

        // VBO for vertex data
        glBindBuffer(GL_ARRAY_BUFFER, bunnyVertexBufferObjID);
        glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->vertexArray, GL_STATIC_DRAW);
        glVertexAttribPointer(glGetAttribLocation(program, "inPosition"), 3, GL_FLOAT, GL_FALSE, 0, 0); 
        glEnableVertexAttribArray(glGetAttribLocation(program, "inPosition"));

	printError("init vertex data");

        // VBO for normal data
        glBindBuffer(GL_ARRAY_BUFFER, bunnyNormalBufferObjID);
        glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->normalArray, GL_STATIC_DRAW);
        glVertexAttribPointer(glGetAttribLocation(program, "inNormal"), 3, GL_FLOAT, GL_FALSE, 0, 0);
        glEnableVertexAttribArray(glGetAttribLocation(program, "inNormal"));

	printError("init normal data");


        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bunnyIndexBufferObjID);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, m->numIndices*sizeof(GLuint), m->indexArray, GL_STATIC_DRAW);

        // End of upload of geometry
        
	printError("init arrays");
}
Example #16
0
void init(void)
{
    glEnable(GL_TEXTURE_2D);
    walls = LoadModelPlus("windmill/windmill-walls.obj");
    wings = LoadModelPlus("windmill/blade.obj");
    roof = LoadModelPlus("windmill/windmill-roof.obj");
    balcony = LoadModelPlus("windmill/windmill-balcony.obj");
    skybox = LoadModelPlus("skybox.obj");

    LoadTGATextureSimple("grass.tga", &ground_tex);
    LoadTGATextureSimple("SkyBox512.tga", &skybox_tex);

    glActiveTexture(GL_TEXTURE0); // Activate ground texture
    glBindTexture(GL_TEXTURE_2D, ground_tex);

    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, skybox_tex);

    if(walls == NULL || wings == NULL ) {
        fprintf(stderr, "Failed to load object\n");
    }
    cam_pos.x = 0.0;
    cam_pos.y = 0.0;
    cam_pos.z = 0.0;

    lookAt_pos.x = 0;
    lookAt_pos.y = 0;
    lookAt_pos.z = -30.0;

    dumpInfo();

    // GL inits
    glClearColor(0.7,0.2,0.5,1.0);
    glEnable(GL_DEPTH_TEST);

    printError("GL inits");

    // Load and compile shader
    program = loadShaders("lab3-3.vert", "lab3-3.frag");
    printError("init shader");

    glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), 1, GL_TRUE, projectionMatrix);




    printError("init arrays");
}
Example #17
0
void init(void)
{
	// vertex buffer object, used for uploading the geometry
	unsigned int vertexBufferObjID;
    unsigned int colorBufferObjID;
	// Reference to shader program

	dumpInfo();
    glutTimerFunc(1, &OnTimer, 0);

	// GL inits
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glClearColor(0.1,0.5,0.5,0);
	glEnable(GL_DEPTH_TEST);
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab1-5.vert", "lab1-5.frag");
	printError("init shader");
	
	// Upload geometry to the GPU:
	
	// Allocate and activate Vertex Array Object
	glGenVertexArrays(1, &vertexArrayObjID);
	glBindVertexArray(vertexArrayObjID);
	// Allocate Vertex Buffer Objects
    glGenBuffers(1, &vertexBufferObjID);
    glGenBuffers(1, &colorBufferObjID);
	
	// VBO for vertex data
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID);
	glBufferData(GL_ARRAY_BUFFER, 36*3*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
	glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); 
	glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
    
    // VBO for colour data
    glBindBuffer(GL_ARRAY_BUFFER, colorBufferObjID);
    glBufferData(GL_ARRAY_BUFFER, 36*3*sizeof(GLfloat), colors, GL_STATIC_DRAW);
    glVertexAttribPointer(glGetAttribLocation(program, "in_Color"), 3, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(glGetAttribLocation(program, "in_Color"));
 	
    glUniformMatrix4fv(glGetUniformLocation(program, "translationMatrix"), 1, GL_TRUE, translationMatrix);
    glUniformMatrix4fv(glGetUniformLocation(program, "rotationMatrix"), 1, GL_TRUE, rotationMatrix);
    glUniformMatrix4fv(glGetUniformLocation(program, "projMatrix"), 1, GL_TRUE, projectionMatrix);
	// End of upload of geometry
	
	printError("init arrays");
}
bool SndFileAudioFileReader::open(const char* input_filename)
{
    input_file_ = sf_open(input_filename, SFM_READ, &info_);

    if (input_file_ != nullptr) {
        output_stream << "Input file: " << input_filename << std::endl;

        dumpInfo(output_stream, info_);
    }
    else {
        error_stream << "Failed to read file: " << input_filename << '\n'
                     << sf_strerror(input_file_) << '\n';
    }

    return input_file_ != nullptr;
}
Example #19
0
void init(void)
{
	// vertex buffer object, used for uploading the geometry

	// Reference to shader program
    m = LoadModel("bunny.obj");

	dumpInfo();
    glutTimerFunc(1, &OnTimer, 0);

	// GL inits
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glClearColor(0.1,0.5,0.5,0);
	glEnable(GL_DEPTH_TEST);
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab1-6.vert", "lab1-6.frag");
	printError("init shader");
	
	// Upload geometry to the GPU:
    
    glGenVertexArrays(1, &bunnyVertexArrayObjID);
    glGenBuffers(1, &bunnyVertexBufferObjID);
    glGenBuffers(1, &bunnyIndexBufferObjID);
    glGenBuffers(1, &bunnyNormalBufferObjID);
    
    glBindVertexArray(bunnyVertexArrayObjID);
    
    // VBO for vertex data
    glBindBuffer(GL_ARRAY_BUFFER, bunnyVertexBufferObjID);
    glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->vertexArray, GL_STATIC_DRAW);
    glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
    
    // VBO for normal data
    glBindBuffer(GL_ARRAY_BUFFER, bunnyNormalBufferObjID);
    glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->normalArray, GL_STATIC_DRAW);
    glVertexAttribPointer(glGetAttribLocation(program, "in_Normal"), 3, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(glGetAttribLocation(program, "in_Normal"));
    
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bunnyIndexBufferObjID);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, m->numIndices*sizeof(GLuint), m->indexArray, GL_STATIC_DRAW);
	// End of upload of geometry
	
	printError("init arrays");
}
Example #20
0
int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   /* add command line argument "classic" for a pre-3.x context */
   if ((argc != 2) || (strcmp (argv[1], "classic") != 0)) {
      glutInitContextVersion (3, 1);
      glutInitContextFlags (GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG);
   }
   glutInitWindowSize (500, 500); 
   glutInitWindowPosition (100, 100);
   glutCreateWindow (argv[0]);
   dumpInfo ();
   init ();
   glutDisplayFunc(display); 
   glutReshapeFunc(reshape);
   glutKeyboardFunc (keyboard);
   glutMainLoop();
   return 0;
}
int main(int argc, char *argv[])
{
	// Initialize GLUT and GLEW, then create a window.
	////////////////////
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(100, 100);
	glutInitWindowSize(800, 600);
	glutCreateWindow("HW1 - 103062372"); // You cannot use OpenGL functions before this line; The OpenGL context must be created first by glutCreateWindow()!
	glewInit();
    dumpInfo();
	////////////////////
	
	inittexture();
	
	// Initialize OpenGL states.
	////////////////////////
	SetupRC();  //initial
	////////////////////////

	BuildMenu();  //build menu

	// Register GLUT callback functions.
	///////////////////////////////
	glutDisplayFunc(My_Display);
	glutReshapeFunc(My_Reshape);
	glutMouseFunc(My_Mouse);
	glutMotionFunc(My_MouseMove);
	glutKeyboardFunc(My_Keyboard);
	glutSpecialFunc(My_SpecialKeys);
	glutTimerFunc(timer_speed, My_Timer, 0); 
	///////////////////////////////


	
	// Enter main event loop.
	//////////////
	glutMainLoop();
	//////////////
	return 0;
}
Example #22
0
void init(void)
{
	// two vertex buffer objects, used for uploading the
	unsigned int vertexBufferObjID;
	unsigned int colorBufferObjID;
	// Reference to shader program
	GLuint program;

	dumpInfo();

	// GL inits
	glClearColor(0.0,1.0,0.0,0);
	//glEnable(GL_DEPTH_TEST);
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab1-2.vert", "lab1-2.frag");
	printError("init shader");
	
	// Upload geometry to the GPU:
	
	// Allocate and activate Vertex Array Object
	glGenVertexArrays(1, &vertexArrayObjID);
	glBindVertexArray(vertexArrayObjID);
	// Allocate Vertex Buffer Objects
	glGenBuffers(1, &vertexBufferObjID);
	
	// VBO for vertex data
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID);
	glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
	glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); 
	glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
	
	// End of upload of geometry
        
        // Upload the Matrices
        glUniformMatrix4fv(glGetUniformLocation(program, "myTransMat"), 1, GL_TRUE, myTransMat);
        glUniformMatrix4fv(glGetUniformLocation(program, "myRotMat"), 1, GL_TRUE, myRotMat);
	
	printError("init arrays");
}
Example #23
0
void init(void)
{
	dumpInfo();

        mill = LoadModelPlus( "windmill/windmill-walls.obj");
        blade = LoadModelPlus( "windmill/blade.obj");
        balcony = LoadModelPlus( "windmill/windmill-balcony.obj");
        roof = LoadModelPlus( "windmill/windmill-roof.obj");

	// GL inits
	glClearColor(0.0,0.3,0.3,0);
        glEnable(GL_DEPTH_TEST);
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab3-2.vert", "lab3-2.frag");
	printError("init shader");

        glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), 1, GL_TRUE, projectionMatrix);

        // Load texture
        //LoadTGATextureSimple("bilskissred.tga", &myBilTex);

	printError("init arrays");

        // Init up vector
        up.x = 0;
        up.y = 1;
        up.z = 0;

        cam_pos.x = 0;
        cam_pos.y = 5;
        cam_pos.z = 0;

        obj_pos.x = 0;
        obj_pos.y = 5;
        obj_pos.z = -30;

        initKeymapManager();
}
Example #24
0
void init(void)
{
	/* two vertex buffer objects, used for uploading the*/
	unsigned int vertexBufferObjID;
/*	unsigned int colorBufferObjID;*/
	/* Reference to shader program*/
	GLuint program;

	dumpInfo();

	/* GL inits*/
	glClearColor(0.5,0.5,0.1,0.3);
	glDisable(GL_DEPTH_TEST);
	printError("GL inits");

	/* Load and compile shader*/
	program = loadShaders("lab1-1.vert", "lab1-1.frag");
	printError("init shader");
	
	/* Upload geometry to the GPU:
	
	// Allocate and activate Vertex Array Object*/
	glGenVertexArrays(1, &vertexArrayObjID);
	glBindVertexArray(vertexArrayObjID);
	/* Allocate Vertex Buffer Objects*/
	glGenBuffers(1, &vertexBufferObjID);
	
	/* VBO for vertex data*/
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID);
	glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
	glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); 
	glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
    glUniformMatrix4fv(glGetUniformLocation(program, "myMatrix"), 1, GL_TRUE, myMatrix);
    set_sincos(&rotationMatrix, 0.0);
	glUniformMatrix4fv(glGetUniformLocation(program, "myRotationMatrix"), 1, GL_TRUE, rotationMatrix);
	/* End of upload of geometry*/
	
	printError("init arrays");
}
Example #25
0
void init(void)
{	
	 
  	walls = LoadModelPlus("windmill-walls.obj");
	blade =  LoadModelPlus("blade.obj");
	roof = LoadModelPlus("windmill-roof.obj");


  LoadTGATextureSimple("maskros512.tga", &myTex);
  LoadTGATextureSimple("dirt.tga", &myTex2);


	// Reference to shader program
	dumpInfo();
	// GL inits
	glClearColor(0.4,0.2,0.0,0);
	glEnable(GL_DEPTH_TEST);
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab3-2.vert", "lab3-2.frag");
	printError("init shader");
	
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, myTex);
	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, myTex2);
	glUniform1i(glGetUniformLocation(program, "texUnit"), 0); // Texture unit 0
	glUniform1i(glGetUniformLocation(program, "texUnit2"), 1); // Texture unit 1
	glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), 1, GL_TRUE, projectionMatrix);
   
       
	// End of upload of geometry

		
	printError("init arrays");

}
Example #26
0
void init(void)
{
	// vertex buffer object, used for uploading the geometry
	unsigned int vertexBufferObjID;
	unsigned int bunnyIndexBufferObjID;
	unsigned int bunnyNormalBufferObjID;
	unsigned int bunnyTexCoordBufferObjID;
	GLuint colorBufferObjID;

	// Load windmill
	vec3 position = { 0, 0, 0 };
	load_windmill(position, &windmill);

	dumpInfo();

	// GL inits
	glClearColor(1,0.2,0.5,0);
	//glFrontFace(GL_CW);
	glEnable(GL_DEPTH_TEST);
	//glEnable(GL_CULL_FACE);
	
	printError("GL inits");

	// Load and compile shader
	program = loadShaders("lab3-1.vert", "lab3-1.frag");
	printError("init shader");

	// Load texture
	glUniform1i(glGetUniformLocation(program, "texUnit"), 0); // Texture unit 0
	LoadTGATextureSimple("conc.tga", &texture);

	// Upload projection matrix
	glUniformMatrix4fv(glGetUniformLocation(program, "projMatrix"), 1, GL_TRUE, projectionMatrix);

	// End of upload of geometry
	printError("init arrays");
}
Example #27
0
int main(int argc, char** argv) {
	GLuint displayMode = GLUT_RGB | GLUT_DOUBLE,
			windowWid = 500, windowHgt = 500, topLtXpos = 100, 
			topLtYpos = 100;
    GLenum err;
    glutInit(&argc, argv); // init OpenGL w/ windowing system
	
    glutInitDisplayMode(displayMode);//(GLUT_RGB | GLUT_SINGLE);

    glutInitWindowSize(windowWid, windowHgt);
    glutInitWindowPosition(topLtXpos, topLtYpos); // set pos from top-left corner
    window1 = glutCreateWindow(argv[0]);

    if (GLEW_OK != (err = glewInit())) {
      fprintf(stderr, "glewInit() Error: %s\n", glewGetErrorString(err));
      exit(EXIT_FAILURE);
    }

    dumpInfo();
    init();
    
    glutDisplayFunc(display); // set display callback
    glutReshapeFunc(reshape); // set reshape callback
    glutKeyboardFunc(keyboard); // set keyboard callback
    glutIdleFunc(idle); // set idle callback
    
    glutMainLoop();
    
    glDisableVertexAttribArray(fgNormalIndex);
    glDisableVertexAttribArray(fgVertexIndex);
    glDeleteBuffers(1, &vertexBufferName);
    glDeleteProgram(shaderProg);
    glutDestroyWindow(window1);
    
    exit(EXIT_SUCCESS);
}
Example #28
0
void init(void)
{
  // vertex buffer object, used for uploading the geometry

  dumpInfo(); // Dump driver info to stdout

  // Load Model
  m = LoadModelPlus("bunnyplus.obj");

  // GL inits
  glClearColor(1,1,1,0);
  //glClearColor(0.2,0.2,0.5,0); // Color in buffer upon clear buffer
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  glEnable(GL_DEPTH_TEST);
  printError("GL inits");

  // Load and compile shader
  program = loadShaders("lab2-3.vert", "lab2-3.frag"); // These are the programs that run on GPU
  printError("init shader");

  // Upload geometry to the GPU:
  glGenVertexArrays(1, &bunnyVertexArrayObjID);
  glGenBuffers(1, &bunnyVertexBufferObjID);
  glGenBuffers(1, &bunnyIndexBufferObjID);
  glGenBuffers(1, &bunnyNormalBufferObjID);
  printError("glGenBuffers");

  glBindVertexArray(bunnyVertexArrayObjID);

  // Lab2
  //--------------
  glGenBuffers(1, &bunnyTexCoordBufferObjID);

  if (m->texCoordArray != NULL)
  {
    // Load model and its texture mapping coordinates
    glBindBuffer(GL_ARRAY_BUFFER, bunnyTexCoordBufferObjID);
    glBufferData(GL_ARRAY_BUFFER, m->numVertices*2*sizeof(GLfloat), m->texCoordArray, GL_STATIC_DRAW);
    glVertexAttribPointer(glGetAttribLocation(program, "inTexCoord"), 2, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(glGetAttribLocation(program, "inTexCoord"));
  }

  // Load texture into uniform in fragment shader
  glUniform1i(glGetUniformLocation(program, "tex"), 0); // Create texture unit
  LoadTGATextureSimple("grass.tga", &tex); // Load texture to texture unit
  glBindTexture(GL_TEXTURE_2D, tex); // Bind texture unit
  glActiveTexture(GL_TEXTURE0); // Activate texture unit 0 (in case we have multiple textures, this is nessecary)

  // Create a texture unit

  // -----------------

  // VBO for vertex data
  glBindBuffer(GL_ARRAY_BUFFER, bunnyVertexBufferObjID);
  glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->vertexArray, GL_STATIC_DRAW);
  glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0);
  glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));

  // VBO for normal data
  glBindBuffer(GL_ARRAY_BUFFER, bunnyNormalBufferObjID);
  glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->normalArray, GL_STATIC_DRAW);
  glVertexAttribPointer(glGetAttribLocation(program, "in_Normal"), 3, GL_FLOAT, GL_FALSE, 0, 0);
  glEnableVertexAttribArray(glGetAttribLocation(program, "in_Normal"));

  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bunnyIndexBufferObjID);
  glBufferData(GL_ELEMENT_ARRAY_BUFFER, m->numIndices*sizeof(GLuint), m->indexArray, GL_STATIC_DRAW);

  // --------------------------------------

  glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), 1, GL_TRUE, projectionMatrix);

  printError("init arrays");
}
Example #29
0
void init(void)
{
    dumpInfo();

    m = LoadModel("bunnyplus.obj");

    // GL inits
    glClearColor(0.0,0.3,0.3,0);
    glEnable(GL_DEPTH_TEST);
    printError("GL inits");

    // Load and compile shader
    program = loadShaders("lab2-4.vert", "lab2-4.frag");
    printError("init shader");

    // Load texture
    LoadTGATextureSimple("grass.tga", &myTex);

    // Upload geometry to the GPU:

    // Allocate and activate Vertex Array Object
    glGenVertexArrays(1, &bunnyVertexArrayObjID);
    glGenBuffers(1, &bunnyVertexBufferObjID);
    glGenBuffers(1, &bunnyIndexBufferObjID);
    //glGenBuffers(1, &bunnyNormalBufferObjID);
    glGenBuffers(1, &bunnyTexCoordBufferObjID);

    glBindVertexArray(bunnyVertexArrayObjID);

    // VBO for vertex data
    glBindBuffer(GL_ARRAY_BUFFER, bunnyVertexBufferObjID);
    glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->vertexArray, GL_STATIC_DRAW);
    glVertexAttribPointer(glGetAttribLocation(program, "inPosition"), 3, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(glGetAttribLocation(program, "inPosition"));

    printError("init vertex data");

    // VBO for normal data
    /*
    glBindBuffer(GL_ARRAY_BUFFER, bunnyNormalBufferObjID);
    glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->normalArray, GL_STATIC_DRAW);
    glVertexAttribPointer(glGetAttribLocation(program, "inNormal"), 3, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(glGetAttribLocation(program, "inNormal"));

    printError("init normal data");
           */

    if (m->texCoordArray != NULL)
    {
        glBindBuffer(GL_ARRAY_BUFFER, bunnyTexCoordBufferObjID);
        glBufferData(GL_ARRAY_BUFFER, m->numVertices*2*sizeof(GLfloat), m->texCoordArray, GL_STATIC_DRAW);
        glVertexAttribPointer(glGetAttribLocation(program, "inTexCoord"), 2, GL_FLOAT, GL_FALSE, 0, 0);
        glEnableVertexAttribArray(glGetAttribLocation(program, "inTexCoord"));

        printError("init texture data");
    }

    // Active texture object
    glBindTexture(GL_TEXTURE_2D, myTex);


    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bunnyIndexBufferObjID);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, m->numIndices*sizeof(GLuint), m->indexArray, GL_STATIC_DRAW);

    // End of upload of geometry

    printError("init arrays");
}
Example #30
0
//-----------------------------------------------------------------------------
void CFrame::dumpHierarchy ()
{
	dumpInfo ();
	DebugPrint ("\n");
	CViewContainer::dumpHierarchy ();
}