Пример #1
0
void OpenGLRenderer::deinitialize() {
    checkForErrors();
    glDisable(GL_DEPTH_TEST);
    //glDisable(GL_CULL_FACE);
    //glDisable(GL_TEXTURE_2D);
    //glDisable(GL_BLEND);

    glDeleteVertexArrays(1, &VAO_mesh);
    glDeleteBuffers(4, &VBO_mesh[0]);
    glDeleteVertexArrays(1, &VAO_fbo);
    glDeleteBuffers(4, &VBO_fbo[0]);
    glDeleteTextures(1, &texture_ID);
    checkForErrors();

    glDeleteTextures(1, &colorTexture1);
    glDeleteTextures(1, &depthTexture1);
    glDeleteFramebuffers(1, &fbo1);
    glDeleteTextures(1, &colorTexture2);
    glDeleteTextures(1, &depthTexture2);
    glDeleteFramebuffers(1, &fbo2);
    glDeleteTextures(1, &colorTexture3);
    glDeleteTextures(1, &depthTexture3);
    glDeleteFramebuffers(1, &fbo3);
    checkForErrors();

    for (int i = 0; i < program_IDs.size(); i++) {
        glDeleteShader(vShader_IDs[i]);
        glDeleteShader(pShader_IDs[i]);
        glDeleteProgram(program_IDs[i]);
    }
    checkForErrors();
}
Пример #2
0
// Based on libarchive's public example code.
// https://github.com/libarchive/libarchive/wiki/Examples#wiki-A_Basic_Write_Example
void GuiZipper::packageFiles(const char *outputFile, const char *baseDir,
    char **filenames, int numFiles, bool binary, const char *absMetaFilename,
    const char *metaFilename) throw (ZipperException*) {
  int r;
  struct archive *a = archive_write_new();
  r = archive_write_add_filter_gzip(a);
  checkForErrors("Error adding filter gzip", a, r);
  r = archive_write_set_format_pax_restricted(a);
  checkForErrors("Error setting format pax restricted", a, r);
  r = archive_write_open_filename(a, outputFile);
  checkForErrors("Error opening file", a, r);
  packageSingleFile(absMetaFilename, metaFilename, a, false);
  for (int x = 0; x < numFiles; x++) {
    char *filename = filenames[x];
    char *filePath = fileManager_->getFilePath(baseDir, filename);
    try {
      packageSingleFile(filePath, filename, a, binary);
    } catch (ZipperException *ze) {
      delete filePath;
      throw ze;
    }
    delete filePath;
  }
  r = archive_write_close(a);
  checkForErrors("Error writing close", a, r);
  r = archive_write_free(a);
  checkForErrors("Error writing free", a, r);
}
Пример #3
0
	//-----------------------------------------------------------------//
	void audio_io::alc_info() const
	{
		if(alcIsExtensionPresent(NULL, (const ALCchar*)"ALC_ENUMERATION_EXT") == AL_TRUE) {
			if(alcIsExtensionPresent(NULL, (const ALCchar*)"ALC_ENUMERATE_ALL_EXT") == AL_TRUE) {
				printDevices(ALC_ALL_DEVICES_SPECIFIER, "playback ");
			} else {
				printDevices(ALC_DEVICE_SPECIFIER, "playback ");
				printDevices(ALC_CAPTURE_DEVICE_SPECIFIER, "capture ");
			}
		} else {
			std::cout << boost::format("No device enumeration available\n");
		}

		ALCdevice* device = alcGetContextsDevice(alcGetCurrentContext());
		checkForErrors();

		std::cout << boost::format("Default device: %s\n")
			% alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER);

		std::cout << boost::format("Default capture device: %s\n")
			% alcGetString(device, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);

		ALCint major, minor;
		alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major);
		alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor);
		checkForErrors();
		std::cout << boost::format("ALC version: %d.%d\n") % static_cast<int>(major) % static_cast<int>(minor);

		printExtensions("ALC extensions", ' ',
			alcGetString(device, ALC_EXTENSIONS));
		checkForErrors();
	}
Пример #4
0
static void
printALCInfo (void)
{
  ALCint major, minor;
  ALCdevice *device;

  if (alcIsExtensionPresent (NULL, (const ALCchar *) "ALC_ENUMERATION_EXT") ==
      AL_TRUE)
    {
      printDevices (ALC_DEVICE_SPECIFIER, "");
      printDevices (ALC_CAPTURE_DEVICE_SPECIFIER, "capture ");
    }
  else
    {
      printf ("no device enumeration available\n");
    }

  device = alcGetContextsDevice (alcGetCurrentContext ());
  checkForErrors ();

  printf ("default device: %s\n",
          getStringALC (device, ALC_DEFAULT_DEVICE_SPECIFIER));

  printf ("default capture device: %s\n",
          getStringALC (device, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

  alcGetIntegerv (device, ALC_MAJOR_VERSION, 1, &major);
  alcGetIntegerv (device, ALC_MAJOR_VERSION, 1, &minor);
  checkForErrors ();
  printf ("ALC version: %d.%d\n", (int) major, (int) minor);

  printExtensions ("ALC extensions", ' ',
                   getStringALC (device, ALC_EXTENSIONS));
}
bool AudioProcessor::shutdown()
{
  ROS_INFO("Shutting down audio processing...");
  result_ = sound_->release();
  checkForErrors(result_);
  result_ = system_->release();
  checkForErrors(result_);
  return true;
}
Пример #6
0
void regenerateMainFBORenderDepthBuffer() {
    renderScaleChanged = false;
    
    const int numBuffers = 1;
    if(fbos[0] != 0) {
        glDeleteBuffers(numBuffers, fbos);
    }
    if(depthBuffer != 0) {
        glDeleteRenderbuffers(1, &depthBuffer);
    }
    if(textures[0] != 0) {
        glDeleteTextures(numBuffers, textures);
    }
    
    glGenFramebuffers(numBuffers, fbos);
    glGenRenderbuffers(1, &depthBuffer);
    glGenTextures(numBuffers, textures);
    
    for (int i = 0; i < numBuffers; ++i) {
        glBindFramebuffer(GL_FRAMEBUFFER, fbos[i]);
        glBindTexture(GL_TEXTURE_2D, textures[i]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
        //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
        glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textures[i], 0);
		// Set the list of draw buffers.
		GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
		glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers
        
        glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
        if (i == 0) {
            glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32,//24,
                                  textureWidth, textureHeight);
        }
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
                                  GL_RENDERBUFFER, depthBuffer);
        if (!checkForErrors()) {
            std::cerr << "Stage 1 - Problem generating FBO " << i << std::endl;
            exit(EXIT_FAILURE);
        }
        
        std::cout << "Generating FBO #" << i << std::endl;
        std::cout << "FBO: " << textureWidth << "x" << textureHeight << std::endl;
        
        if (!checkForErrors() ||
            glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
            std::cerr << "Stage 2 - Problem generating FBO " << i << std::endl;
            exit(EXIT_FAILURE);
        }
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
    }
}
Пример #7
0
// ---------------------------------------------------------------------------
// Function: renderGL
// Design:   Belongs (mostly) to OpenGL component
// Purpose:  Main rendering of the 3D desktop
// Updated:  Sep 10, 2012
// TODO:     Split into separate functions
// ---------------------------------------------------------------------------
void renderGL(Desktop3DLocation& loc, double timeDiff_, RendererPlugin *renderer)
{
    static double time = 0;
    time += timeDiff_;
    
  if (!initedOpenGL) {
    initedOpenGL = true;

    if(renderer->getWindowID()) window = renderer->getWindowID();
//    if (OGRE3D || IRRLICHT) {
      
#ifdef USE_GLEW
      glewExperimental = GL_TRUE;
      GLenum err = glewInit();
      std::cerr << "Inited GLEW: " << err << std::endl;
      checkForErrors();
      std::cerr << "Inited GLEW, may have invalid enum above, that's alright" << std::endl;
      if (GLEW_OK != err) {
        // GLEW failed!
        exit(1);
      }
#endif

#ifdef WIN32
	  //bool r = wglSwapIntervalEXT(5);
	  //std::cerr << "wglSwapIntervalEXT: " << r << std::endl;
#endif
//    }
      
      if(!OGRE3D) {
          checkForErrors();
          std::cerr << "checked errors 2" << std::endl;
          
          std::cerr << "init_distortion_shader" << std::endl;
          bool success = init_distortion_shader();
          checkForErrors();
          std::cerr << "checked errors 3" << std::endl;
          if (!success) {
              std::cerr << "Failed to init distortion shader!" << std::endl;
              exit(1);
          }
          success = init_distortion_shader_cache();
          if (!success) {
              std::cerr << "Failed to init distortion shader cache!" << std::endl;
              exit(1);
          }

          if (USE_FBO) prep_framebuffers();
      }
  }

  renderer->step(loc, timeDiff_, time);
}
Пример #8
0
int
main (int argc, char *argv[])
{
  alutInit (&argc, argv);
  checkForErrors ();

  printALUTInfo ();
  printALCInfo ();
  printALInfo ();
  checkForErrors ();

  alutExit ();

  return EXIT_SUCCESS;
}
Пример #9
0
void Ibex::VLCVideoPlayer::createVideoTextures(bool isStereo, int width, int height) {
  // load OpenGL textures for video/stereo-video if necessary
  if(videoTexture[0]) {
    if(videoTexture[1] == videoTexture[0]) {
      glDeleteTextures(1, videoTexture);
    } else {
      glDeleteTextures(2, videoTexture);
    }
    videoTexture[0] = videoTexture[1] = 0;
  }
  glGenTextures((isStereo) ? 2 : 1, videoTexture);
    if (!checkForErrors()) {
        fprintf(stderr,"Stage 00 - Problem generating videoTexture FBO");
        exit(EXIT_FAILURE);
    }
  for(int i = 0; i < 2; ++i) {
    if(i == 1 && !isStereo) {
      videoTexture[i] = videoTexture[0];
      break;
    }
        
    glBindTexture(GL_TEXTURE_2D, videoTexture[i]);
    if (!checkForErrors()) {
      fprintf(stderr,"Stage 0a - Problem generating videoTexture FBO");
      exit(EXIT_FAILURE);
    }
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    if (!checkForErrors()) {
      fprintf(stderr,"Stage 0b - Problem generating videoTexture FBO");
      exit(EXIT_FAILURE);
    }
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    if (!checkForErrors()) {
      fprintf(stderr,"Stage 0c - Problem generating videoTexture FBO");
      exit(EXIT_FAILURE);
    }
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, (isStereo)?height/2:height, 0,
		 GL_BGRA, IBEX_VIDEO_GL_PIX_FORMAT, 0);
    if (!checkForErrors()) {
      fprintf(stderr,"Stage 0d - Problem generating videoTexture FBO");
      exit(EXIT_FAILURE);
    }
  }
  glBindTexture(GL_TEXTURE_2D, 0);
  glFlush();
}
Пример #10
0
/*
 * Initialisiert den AddShader (Programm erstellen, Uniform IDs laden, VBOs initialisieren)
 *
 * Der AddShader ist für das Addieren einzelner FBOs beim Transparenz-Effekt zuständig
 */
void OpenGLRenderer::initializeAddShader() {
    // Lade Shader und erstelle das Programm
    useAddShader = createProgram("../shader/FBO/vertexShader.c", "../shader/FBO/addShader.c");

    // Ermittle Speicheradressen der Uniforms
    pingPongStep_ID = glGetUniformLocation(program_IDs[useAddShader], "pingPongStep");
    newFBO_ID = glGetUniformLocation(program_IDs[useAddShader], "newFBO");
    oldFBO_ID = glGetUniformLocation(program_IDs[useAddShader], "oldFBO");

    // in-Variablen der Vertexshader (an diese IDs werden die entsprechenden VBOs gebunden)
    GLuint addInPosition_ID = glGetAttribLocation(program_IDs[useAddShader], "in_position");
    GLuint addInTexCoord_ID = glGetAttribLocation(program_IDs[useAddShader], "in_texcoord");

    glBindVertexArray(VAO_fbo);
    //Position
    glBindBuffer(GL_ARRAY_BUFFER, VBO_fbo[0]);
    glVertexAttribPointer(addInPosition_ID, 4, GL_FLOAT, 0, 0, 0);
    glEnableVertexAttribArray(addInPosition_ID);

    //Texture-Coordinates
    glBindBuffer(GL_ARRAY_BUFFER, VBO_fbo[1]);
    glVertexAttribPointer(addInTexCoord_ID, 2, GL_FLOAT, 0, 0, 0);
    glEnableVertexAttribArray(addInTexCoord_ID);

    glBindVertexArray(0);
    checkForErrors();
}
Пример #11
0
/*
 * Initialisiert den FinalShader (Programm erstellen, Uniform IDs laden, VBOs initialisieren)
 *
 * Der FinalShader ist für das Anwenden der PostScreen-Effekte zuständig
 */
void OpenGLRenderer::initializeFinalShader() {
    // Lade Shader und erstelle das Programm
    useFinalShader = createProgram("../shader/FBO/vertexShader.c", "../shader/FBO/pixelShader.c");

    // Ermittle Speicheradressen der Uniforms
    sobel_ID = glGetUniformLocation(program_IDs[useFinalShader], "sobel");
    blue_ID = glGetUniformLocation(program_IDs[useFinalShader], "blue");
    black_ID = glGetUniformLocation(program_IDs[useFinalShader], "black");
    width_ID = glGetUniformLocation(program_IDs[useFinalShader], "fWidth");
    height_ID = glGetUniformLocation(program_IDs[useFinalShader], "fHeight");

    // in-Variablen der Vertexshader (an diese IDs werden die entsprechenden VBOs gebunden)
    GLuint fboInPosition_ID = glGetAttribLocation(program_IDs[useFinalShader], "in_position");
    GLuint fboInTexCoord_ID = glGetAttribLocation(program_IDs[useFinalShader], "in_texcoord");

    glBindVertexArray(VAO_fbo);
    //Position
    glBindBuffer(GL_ARRAY_BUFFER, VBO_fbo[0]);
    glVertexAttribPointer(fboInPosition_ID, 4, GL_FLOAT, 0, 0, 0);
    glEnableVertexAttribArray(fboInPosition_ID);

    //Texture-Coordinates
    glBindBuffer(GL_ARRAY_BUFFER, VBO_fbo[1]);
    glVertexAttribPointer(fboInTexCoord_ID, 2, GL_FLOAT, 0, 0, 0);
    glEnableVertexAttribArray(fboInTexCoord_ID);

    glBindVertexArray(0);
    checkForErrors();
}
Пример #12
0
/*
 * Initialisiert den StarWarsShader (Programm erstellen, Uniform IDs laden, VBOs initialisieren)
 *
 * Der StarWarsShader ist für die StarWars-Effekte zuständig
 */
void OpenGLRenderer::initializeStarWarsShader() {
    // Lade Shader und erstelle das Programm
    useStarWarsShader = createProgram("../shader/StarWars/vertexShader.c", "../shader/StarWars/pixelShader.c");

    // Ermittle Speicheradressen der Uniforms
    swIntensity_ID = glGetUniformLocation(program_IDs[useStarWarsShader], "intensity");
    swThickness_ID = glGetUniformLocation(program_IDs[useStarWarsShader], "thickness");
    swFrequency_ID = glGetUniformLocation(program_IDs[useStarWarsShader], "frequency");
    swTime_ID = glGetUniformLocation(program_IDs[useStarWarsShader], "time");
    swViewWidth_ID = glGetUniformLocation(program_IDs[useStarWarsShader], "viewWidth");
    swViewHeight_ID = glGetUniformLocation(program_IDs[useStarWarsShader], "viewHeight");
    swRandom_ID = glGetUniformLocation(program_IDs[useStarWarsShader], "random");

    // in-Variablen der Vertexshader (an diese IDs werden die entsprechenden VBOs gebunden)
    GLuint starWarsInPosition_ID = glGetAttribLocation(program_IDs[useStarWarsShader], "in_position");
    GLuint starWarsInTexCoord_ID = glGetAttribLocation(program_IDs[useStarWarsShader], "in_texcoord");

    glBindVertexArray(VAO_fbo);
    //Position
    glBindBuffer(GL_ARRAY_BUFFER, VBO_fbo[0]);
    glVertexAttribPointer(starWarsInPosition_ID, 4, GL_FLOAT, 0, 0, 0);
    glEnableVertexAttribArray(starWarsInPosition_ID);

    //Texture-Coordinates
    glBindBuffer(GL_ARRAY_BUFFER, VBO_fbo[1]);
    glVertexAttribPointer(starWarsInTexCoord_ID, 2, GL_FLOAT, 0, 0, 0);
    glEnableVertexAttribArray(starWarsInTexCoord_ID);

    glBindVertexArray(0);
    checkForErrors();
}
Пример #13
0
/*
 * Erstellt ein Shaderprogramm aus den angegebenen Shaderdateien.
 * Liefert den Index, an dessen Postion das Progemm und die einzelnen Shader in den Vektoren gespeichert werden.
 */
int OpenGLRenderer::createProgram(QString vertexPath, QString pixelPath) {
    // Shader laden
    GLuint vertex_ID = glCreateShader(GL_VERTEX_SHADER);
    GLuint pixel_ID = glCreateShader(GL_FRAGMENT_SHADER);
    //const char* vs = readFile(vertexPath).c_str();    // geht nicht in einem Schritt... stürzt ab?!
    //const char* fs = readFile(pixelPath).c_str();
    std::string vsString = readFile(vertexPath);
    std::string fsString = readFile(pixelPath);
    const char* vs = vsString.c_str();
    const char* fs = fsString.c_str();
    glShaderSource(vertex_ID, 1, &vs, 0);
    glShaderSource(pixel_ID, 1, &fs, 0);

    // Shader kompilieren
    glCompileShader(vertex_ID);
    printShaderInfoLog(vertex_ID);
    glCompileShader(pixel_ID);
    printShaderInfoLog(pixel_ID);

    // Programm aus Shadern erstellen
    GLuint program_ID = glCreateProgram();
    glAttachShader(program_ID, vertex_ID);  // erst Vertexshader
    glAttachShader(program_ID, pixel_ID);   // danach Pixelshader
    glBindFragDataLocation(program_ID, 0, "fragColor"); // fragColor enthält am Ende die Farbe des Pixels ist (Ausgabe des Pixelshaders)
    glLinkProgram(program_ID);
    printProgramInfoLog(program_ID);

    checkForErrors();

    vShader_IDs.append(vertex_ID);
    pShader_IDs.append(pixel_ID);
    program_IDs.append(program_ID);
    return vShader_IDs.size() - 1;
}
Пример #14
0
int main()
{
	setlocale(LC_ALL, "Russian");
	
	//Сжимаем файл
	int c = compress("source.txt", "compressedSource.dat");
	if (checkForErrors(c))
		printf("File has been succefully compressed.\n");

	//Разархивация
	int d = decompress("compressedSource.dat", "decompressedSource.txt");
	if (checkForErrors(d))
		printf("File has been succefully decompressed.\n");

	getch();
}
Пример #15
0
static const char *
getStringALC (ALCdevice *device, ALCenum param)
{
  const char *s = (const char *) alcGetString (device, param);
  checkForErrors ();
  return s;
}
Пример #16
0
void GuiZipper::packageSingleFile(const char *absFilename, const char *filename,
    struct archive *a, bool binary) throw (ZipperException*) {
  struct stat st;
  char buff[8192];
  int fd;
  stat(absFilename, &st);
  struct archive_entry *entry = archive_entry_new();
  archive_entry_copy_stat(entry, &st);
  archive_entry_set_filetype(entry, AE_IFREG);
  archive_entry_set_pathname(entry, filename);
  archive_entry_set_perm(entry, 0644);
  int r = archive_write_header(a, entry);
  checkForErrors("Error writing header", a, r);
  int flags = O_RDONLY;
#ifdef __WIN32__
  if (binary) {
    flags |= O_BINARY;
  }
#endif
  fd = open(absFilename, flags);
  ssize_t len = read(fd, buff, sizeof(buff));
  while (len > 0) {
    archive_write_data(a, buff, len);
    len = read(fd, buff, sizeof(buff));
  }
  close(fd);
  archive_entry_free(entry);
}
Пример #17
0
static const char *
getStringAL (ALenum param)
{
  const char *s = (const char *) alGetString (param);
  checkForErrors ();
  return s;
}
Пример #18
0
void TCPClient::drawPins(unsigned char * _theColors)
{
    ofPushMatrix();
	//ofTranslate(50, 200);
    
    int xOffset = 13;
    int islandSpacer = 30; //350;
    
    int islandSize = size / 3;
    int islands = 3;
    int rows = 24;
    int columns = 16;

    outImage.begin();
    
    ofSetColor(0);
    ofRect(0, 0, RELIEF_PHYSICAL_SIZE_X, RELIEF_PHYSICAL_SIZE_Y);
    
    checkForErrors();
    cout << bErrorDetected << endl;
    if(!bErrorDetected)
    {
        //sort incoming data
        for(int k = 0; k < islands; k++) // islands
        {
            for(int i = 0; i < columns; i++) // columns
            {
                for(int j = 0; j < rows; j++) // rows
                {
                    //sort linear array to the 3 islands
                    int idx = (j * columns) + (k * islandSize) + i;
               
                    int sortIdx = (k + i) * (rows) + j;
                
                    rects.at(idx).setWidth(1);
                    rects.at(idx).setHeight(1);
                
                    rects.at(idx).x = ( xOffset + (i + k * islandSpacer));
                    rects.at(idx).y = (j);
                
                    ofSetColor(_theColors[idx]);
                    //draw values in sorted order
                    ofRect(rects.at(idx));
                }
            }
        }
    }
    else
    {
        ofSetColor(0, 0, 0);
        ofRect(0, 0, RELIEF_SIZE_X, RELIEF_SIZE_Y);
    }
    
    outImage.end();
    outImage.draw(0, 0);
    
    outImage.draw(0, 400, 102 * 5, 24 * 5);
  	ofPopMatrix();
}
Пример #19
0
bool Model::Import3DFromFile( const std::string& pFile)
{
    static bool first = true;
    if(first) {
        first = false;
        
        setupShaders();
    }
    
    std::ifstream fin(pFile.c_str());
    if(!fin.fail()) {
        fin.close();
    }
    else{
        printf("Couldn't open file: %s\n", pFile.c_str());
        printf("%s\n", importer.GetErrorString());
        return false;
    }
    
    scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality);
    
    if( !scene)
    {
        printf("%s\n", importer.GetErrorString());
        return false;
    }
    
    // Now we can access the file's contents.
    printf("Import of scene %s succeeded.\n",pFile.c_str());
    
#ifdef __APPLE__
    boost::filesystem::path p(pFile);
    std::string basePath = p.parent_path().string()+"/";
#else
	char path[2000];
	wchar_t wpath[2000];
	strcpy(path, pFile.c_str());
	mbstowcs(wpath, path, strlen(path)+1);//Plus null
	LPWSTR ptr = wpath;
	PathRemoveFileSpec(ptr);
	std::wstring backToString(ptr);
	std::string basePath(std::string(backToString.begin(),backToString.end())+"\\");
#endif

    printf("Import textures of scene %s...\n",pFile.c_str());
    LoadGLTextures(scene, basePath);
    printf("Import textures of scene %s done.\n",pFile.c_str());
    
    printf("Import generating VAOs for scene %s...\n",pFile.c_str());
    genVAOsAndUniformBuffer(scene);
    printf("Import generating VAOs for scene %s done.\n",pFile.c_str());

    if(!checkForErrors()) {
        std::cerr << "Problem loading model..." << std::endl;
        exit(1);
    }
    
    return true;
}
Пример #20
0
static void
printALUTInfo (void)
{
  ALint major, minor;
  const char *s;

  major = alutGetMajorVersion ();
  minor = alutGetMinorVersion ();
  checkForErrors ();
  printf ("ALUT version: %d.%d\n", (int) major, (int) minor);

  s = alutGetMIMETypes (ALUT_LOADER_BUFFER);
  checkForErrors ();
  printExtensions ("ALUT buffer loaders", ',', s);

  s = alutGetMIMETypes (ALUT_LOADER_MEMORY);
  checkForErrors ();
  printExtensions ("ALUT memory loaders", ',', s);
}
Пример #21
0
// Based on libarchive's public example code.
// https://github.com/libarchive/libarchive/wiki/Examples#wiki-Constructing_Objects_On_Disk
void GuiZipper::unpackFile(const char *zipFile, const char *outputDir)
    throw (ZipperException*) {
  // TODO: use archive_write_disk_open instead (if/when it exists)
  char cwd[4096];
  getcwd(cwd, 4096);
  char *absZipFile = fileManager_->getAbsFilePath(zipFile);
  platformstl::filesystem_traits<char> traits;
  traits.set_current_directory(outputDir);
  
  struct archive *a;
  struct archive *ext;
  struct archive_entry *entry;
  int flags;
  int r;
  
  flags = ARCHIVE_EXTRACT_TIME;
  flags |= ARCHIVE_EXTRACT_PERM;
  flags |= ARCHIVE_EXTRACT_ACL;
  flags |= ARCHIVE_EXTRACT_FFLAGS;
  
  a = archive_read_new();
  archive_read_support_format_tar(a);
  archive_read_support_filter_gzip(a);
  ext = archive_write_disk_new();
  archive_write_disk_set_options(ext, flags);
  archive_write_disk_set_standard_lookup(ext);
  r = archive_read_open_filename(a, absZipFile, 10240);
  checkForErrors("Error opening archive for reading", a, r);
  for (;;) {
    r = archive_read_next_header(a, &entry);
    if (r == ARCHIVE_EOF) {
      break;
    }
    checkForErrors("Error reading next archive header", a, r);
    r = archive_write_header(ext, entry);
    checkForErrors("Error writing next archive header", a, r);
    copyData(a, ext, outputDir);
    r = archive_write_finish_entry(ext);
    checkForErrors("Error writing archive finish entry", a, r);
  }
  r = archive_read_close(a);
  checkForErrors("Error closing read archive", a, r);
  r = archive_read_free(a);
  checkForErrors("Error freeing read archive", a, r);
  r = archive_write_close(ext);
  checkForErrors("Error closing write archive", a, r);
  r = archive_write_free(ext);
  checkForErrors("Error freeing write archive", a, r);

  traits.set_current_directory(cwd);
  delete absZipFile;
}
Пример #22
0
	static void printDevices(ALCenum which, const char* kind)
	{
		const char *s = alcGetString(NULL, which);
		checkForErrors();

		std::cout << boost::format("Available %sdevices:\n") % kind;
		while(*s != '\0') {
			std::cout << boost::format("    %s\n") % s;
			while(*s++ != '\0') ;
		}
	}
Пример #23
0
void Shader::compile(const std::string& vertexSource, const std::string& fragmentSource, const std::string& geometrySource) {
    GLuint vertex, fragment;
    GLuint geometry = 0;

    vertex = glCreateShader(GL_VERTEX_SHADER);
    auto sourceString = vertexSource.c_str();
    glShaderSource(vertex, 1, &sourceString, nullptr);
    glCompileShader(vertex);
    checkForErrors(vertex, ShaderType::SHADER);

    fragment = glCreateShader(GL_FRAGMENT_SHADER);
    sourceString = fragmentSource.c_str();
    glShaderSource(fragment, 1, &sourceString, nullptr);
    glCompileShader(fragment);
    checkForErrors(fragment, ShaderType::SHADER);

    if(geometrySource != "") {
        geometry = glCreateShader(GL_GEOMETRY_SHADER);
        sourceString = geometrySource.c_str();
        glShaderSource(geometry, 1, &sourceString, nullptr);
        glCompileShader(geometry);
        checkForErrors(geometry, ShaderType::SHADER);
    }

    ID = glCreateProgram();
    glAttachShader(ID, vertex);
    glAttachShader(ID, fragment);

    if(geometry){
        glAttachShader(ID, geometry);
    }

    glLinkProgram(ID);
    checkForErrors(ID, ShaderType::PROGRAM);

    glDeleteShader(vertex);
    glDeleteShader(fragment);
    if(geometry) {
        glDeleteShader(geometry);
    }
}
Пример #24
0
HRESULT CeeFileGenWriter::link()
{
    HRESULT hr = checkForErrors();
    if (! SUCCEEDED(hr))
        return hr;


    m_corHeader->Resources.VirtualAddress = VAL32(m_dwManifestRVA);
    m_corHeader->Resources.Size = VAL32(m_dwManifestSize);

    m_corHeader->StrongNameSignature.VirtualAddress = VAL32(m_dwStrongNameRVA);
    m_corHeader->StrongNameSignature.Size = VAL32(m_dwStrongNameSize);

    m_corHeader->VTableFixups.VirtualAddress = VAL32(m_dwVTableRVA);
    m_corHeader->VTableFixups.Size = VAL32(m_dwVTableSize);

    getPEWriter().setCharacteristics(
//#ifndef _WIN64
        IMAGE_FILE_32BIT_MACHINE |
//#endif
        IMAGE_FILE_EXECUTABLE_IMAGE | 
        IMAGE_FILE_LINE_NUMS_STRIPPED | 
        IMAGE_FILE_LOCAL_SYMS_STRIPPED
    );

    m_corHeader->cb = VAL32(sizeof(IMAGE_COR20_HEADER));
    m_corHeader->MajorRuntimeVersion = VAL16(COR_VERSION_MAJOR);
    m_corHeader->MinorRuntimeVersion = VAL16(COR_VERSION_MINOR);
    if (m_dllSwitch)
        getPEWriter().setCharacteristics(IMAGE_FILE_DLL);
    if (m_objSwitch)
        getPEWriter().clearCharacteristics(IMAGE_FILE_DLL | IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LOCAL_SYMS_STRIPPED);
    m_corHeader->Flags = VAL32(m_comImageFlags);
    m_corHeader->EntryPointToken = VAL32(m_entryPoint);
    _ASSERTE(TypeFromToken(m_entryPoint) == mdtMethodDef || m_entryPoint == mdTokenNil || 
             TypeFromToken(m_entryPoint) == mdtFile);
    setDirectoryEntry(getCorHeaderSection(), IMAGE_DIRECTORY_ENTRY_COMHEADER, sizeof(IMAGE_COR20_HEADER), m_corHeaderOffset);

    if ((m_comImageFlags & COMIMAGE_FLAGS_IL_LIBRARY) == 0
        && !m_linked && !m_objSwitch)
    {
        hr = emitExeMain();
        if (FAILED(hr))
            return hr;

    }

    m_linked = true;

    IfFailRet(getPEWriter().link());

    return S_OK;
} // HRESULT CeeFileGenWriter::link()
Пример #25
0
int smsa_vunmount( void )  {
	
	uint32_t command;     		 //holds the generated "unmount" command.	
	ERROR_SOURCE err = 0;		 //holds return values of function calls to checkForErrors	


	if ( DEBUG )
		printCache( cache_hits, disk_reads);		

	
	//save the contents of the memory to a file, so that
	//it can be restored when mount is called again, rather
	//than setting it to all zeros. If an error occurs in this 
	//function we will not return a 1 since it is not a catastrophic
	//error, and the virtual memory will still function properly 
	//once mount is called
//	err = saveDiskToFile();

	//generate the op command so that we can use it to call
	//the smsa_operation function to unmount the disk. Once 
	//again, DONT_CARE is defined as 0. After function call
	//command will contain the value neccessary to call
	//smsa_operation in order to unmount the disk
	err = generateOPCommand ( &command, SMSA_UNMOUNT, DONT_CARE, DONT_CARE, DONT_CARE );

	if ( DEBUG )
		logMessage ( LOG_INFO_LEVEL, "Sending UNMOUNT Command Across the Network");

	//call function with the "mount" op command,
	//and NULL set as the parameter for the char*,
	//since we will not use this char* in the mount
	//function
	if ( smsa_client_operation ( command, NULL ) ) {
		logMessage ( LOG_INFO_LEVEL, "_smsa_vunmount:Failed to send UNMOUNT command on the network");
		return 1;
	

	logMessage ( LOG_INFO_LEVEL, "Successfully Unmounted the Disk" );


	//free cache
	if ( smsa_close_cache() )
		logMessage ( LOG_INFO_LEVEL, "_smsa_vunmount:Failed to properly close cache in smsa_close_cache()" );
		return 1;
	}

	
	//if checkForErrors finds that err is non-zero, it will return 1. 
	//see smsa_driver.h for error enum definition
	return ( checkForErrors ( err, "_vumount", DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE, 
						DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE ) );
}
Пример #26
0
static JSBool
flush(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
    DOC_BEGIN("");
    DOC_END;
    cairo_surface_t *mySurface = NULL;
    convertFrom(cx, OBJECT_TO_JSVAL(obj), mySurface);

    ensureParamCount(argc, 0);

    cairo_surface_flush(mySurface);

    return checkForErrors(cx, mySurface);
}
Пример #27
0
/*
 * Initialisiert ein FBO
 */
void OpenGLRenderer::initializeFBO(GLuint fbo, GLuint colorTexture, GLuint depthTexture) {
    // Texturhandles erstellen
    glGenTextures(1, &colorTexture);
    glGenTextures(1, &depthTexture);
    checkForErrors();

    // Konfiguriert leere Color- und Depth-Texturen in Bildschirmgröße, in die am Ende die leeren Dreiecke aus dem VBO_fbo gerendert werden können
    configureFBOTextures(colorTexture, depthTexture);

    // Erzeuge neue FBOs
    glGenFramebuffers(1, &fbo);
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, colorTexture, 0);   // Verknüpfe Color-Textur mit dem FBO
    glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthTexture, 0);    // Verknüpfe Depth-Textur mit dem FBO

    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
        qDebug ( ) << "Error, FBO not complete!";
    }
    // gebundenen Framebuffer wieder loslösen
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    checkForErrors();
}
Пример #28
0
static JSBool
getHeight(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
    DOC_BEGIN("");
    DOC_END;
    cairo_surface_t *mySurface = NULL;
    convertFrom(cx, OBJECT_TO_JSVAL(obj), mySurface);

    ensureParamCount(argc, 0);

    int myHeight = cairo_image_surface_get_height(mySurface);

    *rval = as_jsval(cx, myHeight);

    return checkForErrors(cx, mySurface);
}
Пример #29
0
/*
 * Initialisiert die VAOs
 * Muss vor dem Initialisieren der VBOs geschehen (initializeShader()-Funktionen)!
 */
void OpenGLRenderer::initializeVAOs() {
    // Die 4 VBOs des MeshShaders als VAO zusammenfassen
    glGenVertexArrays(1, &VAO_mesh);
    glBindVertexArray(VAO_mesh);
    glGenBuffers(4, &VBO_mesh[0]);

    // Erstelle Fake VAO, um FBO Texturen auf den Bildschirm rendern zu können
    // Hier brauchen wir nur Positionen und Textur-Koordinaten -> 2 VBOs
    glGenVertexArrays(1, &VAO_fbo);
    glBindVertexArray(VAO_fbo);
    glGenBuffers(2, &VBO_fbo[0]);
    fill_fboVBOs();

    glBindVertexArray(0);
    checkForErrors();
}
Пример #30
0
static JSBool
writeToPNG(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
    DOC_BEGIN("");
    DOC_END;
    cairo_surface_t *mySurface = NULL;
    convertFrom(cx, OBJECT_TO_JSVAL(obj), mySurface);

    ensureParamCount(argc, 1);

    std::string myPath;
    convertFrom(cx, argv[0], myPath);

    cairo_surface_write_to_png(mySurface, myPath.c_str());

    return checkForErrors(cx, mySurface);
}