Example #1
0
PyShape *PyLink::addCube(double x, double y, double z)
{
    PyShape *shape = new PyShape();
    loadCube(shape, x,y,z);
    addShape(shape);
    return shape;
}
bool TextureManager::reloadCube(const std::string &fn) {
  auto it = textureCubes.find(fn);

  if(it != textureCubes.end()) {
    loadCube(it->second,fn);
    return true;
  }

  return false;
}
GLuint TextureManager::getCube(const std::string &fn) {
  if(fn.empty()) {
    return 0;
  }

  std::map<std::string,GLuint>::iterator it=textureCubes.find(fn);

  if(it != textureCubes.end()) {
    return it->second;
  }

  //
  GLuint tex;
  glGenTextures(1,&tex);

  loadCube(tex,fn);

  textureCubes.insert(std::make_pair(fn,tex));
  return tex;
}
Example #4
0
void Reader::read() {
    int quality = 50;
    int width = 256;
    int height = 256;
    quality = atoi(document->FirstChildElement("scene")->FirstChildElement("properties")->FirstChildElement("quality")->FirstChild()->Value());
    width = atoi(document->FirstChildElement("scene")->FirstChildElement("properties")->FirstChildElement("width")->FirstChild()->Value());
    height = atoi(document->FirstChildElement("scene")->FirstChildElement("properties")->FirstChildElement("height")->FirstChild()->Value());

    this->scene->setHeight(height);
    this->scene->setWidth(width);
    this->scene->setQuality(quality);

    printf("Width = %d, Height = %d, Quality = %d\n", width, height, quality);

    float ex, ey, ez;
    float lx, ly, lz;
    ex = atof(document->FirstChildElement("scene")->FirstChildElement("camera")->FirstChildElement("eye")->FirstChildElement("x")->FirstChild()->Value());
    ey = atof(document->FirstChildElement("scene")->FirstChildElement("camera")->FirstChildElement("eye")->FirstChildElement("y")->FirstChild()->Value());
    ez = atof(document->FirstChildElement("scene")->FirstChildElement("camera")->FirstChildElement("eye")->FirstChildElement("z")->FirstChild()->Value());
    lx = atof(document->FirstChildElement("scene")->FirstChildElement("camera")->FirstChildElement("lookAt")->FirstChildElement("x")->FirstChild()->Value());
    ly = atof(document->FirstChildElement("scene")->FirstChildElement("camera")->FirstChildElement("lookAt")->FirstChildElement("y")->FirstChild()->Value());
    lz = atof(document->FirstChildElement("scene")->FirstChildElement("camera")->FirstChildElement("lookAt")->FirstChildElement("z")->FirstChild()->Value());
    this->scene->setEyeX(ex);
    this->scene->setEyeY(ey);
    this->scene->setEyeZ(ez);
    this->scene->setLookAtX(lx);
    this->scene->setLookAtY(ly);
    this->scene->setLookAtZ(lz);
    printf("Setting camera: %f %f %f, %f %f %f\n", ex, ey, ez, lx, ly, lz);

    TiXmlElement *o;
    o = document->FirstChildElement("scene")->FirstChildElement("objects")->FirstChildElement();
    while (o != NULL) {
        if (strcmp(o->Value(), "cube") == 0) {
            loadCube(o);
        } else if (strcmp(o->Value(), "sphere") == 0) {
            loadSphere(o);
        }
        o = o->NextSiblingElement();
    }
}
Example #5
0
/**
 * Intialise SDL and create openGL context.
 * load, compile and linking of shaders. 
 * Image loading also done.
 */
void Game::init()
{
    SDL_Init(SDL_INIT_EVERYTHING);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION , 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    window = SDL_CreateWindow("Voxel Game" , SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 768, SDL_WINDOW_OPENGL);

    glContext = SDL_GL_CreateContext(window);

    glewExperimental = GL_TRUE;
    glewInit();

    glViewport(0, 0, 1024, 768);

    glEnable(GL_DEPTH_TEST);
    std::cout << "init\n";
    std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
    std::cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
    std::cout << "Vendor: " << glGetString(GL_VENDOR) << std::endl;
    std::cout << "Renderer: " << glGetString(GL_RENDERER) << std::endl;

    shader.loadShader("shaders/Vertex.vert", "shaders/Fragment.frag");
    loadCube();
    texture = iLoader.loadTexture("images/wall.jpg");
    width = iLoader.getwidth();
    height = iLoader.getheight();
     std::cout << texture << "\n";
    
    texture2 = iLoader.loadTexture("images/container.jpg");
    width2 = iLoader.getwidth();
    height2 = iLoader.getheight();
     std::cout << texture2 << "\n";
}
Example #6
0
Cube::Cube(int level) {
	loadCube(level);
}
Example #7
0
bool Cube::loadNextCube() {
	return loadCube(level+1);
}
Example #8
0
bool Cube::reloadCube() {
	return loadCube(level);
}