Esempio n. 1
0
  bool Mesh::setTexture(const char *texName)
  {
    Block& b = *(m_blocks.end()-1);
    bool status = false;
    SDL_Surface* tex_image;

    if(tex_image = IMG_Load( const_cast<char*> (texName) )  )
      {
	status = true;
#if 0	
	status = true;
	/* Create The Texture */
	glGenTextures( 1, &b.texture );

	/* Typical Texture Generation Using Data From The Bitmap */
	glBindTexture( GL_TEXTURE_2D, b.texture );

	/* Generate The Texture */
	glTexImage2D( GL_TEXTURE_2D, 0, 3, tex_image->w,
		      tex_image->h, 0, GL_BGR,
		      GL_UNSIGNED_BYTE, tex_image->pixels );

	/* Linear Filtering */
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
#endif

	makeTexture (tex_image, &b.texture, GL_LINEAR);
	SDL_FreeSurface(tex_image);
      }
        
    return status;
  }
Esempio n. 2
0
	void MyTexturedBox::init() {
		_physics.setPosition(3,1.01,3);
		_physics.setAngularVelocity(10.0);
		makeMaterial();
		makeTexture();
		makeModel();
	}
void StereogramWidget::setTextureMode(TextureMode textureMode)
{
    mTextureMode = textureMode;
    invalidateTexture();
    makeTexture();
    update();
}
Esempio n. 4
0
void VideoPlayer::display()
{
    GLuint tex = makeTexture();
    glClearColor( 0.0, 0.4, 0.0, 0.0 );
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glEnable( GL_TEXTURE_2D );
    glDisable(GL_LIGHTING);

    glMatrixMode (GL_MODELVIEW);
    glPushMatrix ();
    glLoadIdentity ();
    glMatrixMode (GL_PROJECTION);
    glPushMatrix ();
    glLoadIdentity ();

    glBindTexture( GL_TEXTURE_2D, tex );
    glBegin (GL_QUADS);
    glColor3f(1, 1, 1);
    glTexCoord2f(0, 1);
    glVertex3i(-1, -1, 1);
    glTexCoord2f(1, 1);
    glVertex3i(1, -1, 1);
    glTexCoord2f(1, 0);
    glVertex3i(1, 1, 1);
    glTexCoord2f(0, 0);
    glVertex3i(-1, 1, 1);
    glEnd();

    glPopMatrix ();
    glMatrixMode (GL_MODELVIEW);
    glPopMatrix ();
    glDeleteTextures(1, &tex);
    glEnable(GL_LIGHTING);
}
Esempio n. 5
0
static void loadTexture(void){
    g_resources.textures[0] = makeTexture("images/01-qwiki-reference.jpg");
    g_resources.uniforms.textures[0] = glGetUniformLocation(program, "textures[0]");

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, g_resources.textures[0]);
    glUniform1f(g_resources.uniforms.textures[0], 0);
}
/// Constructs a new region at the given position
/// @param x The x coordinate of the origin
/// @param y The y coordinate of the origin
/// @param parent The game that this region is in.
Terrain::Terrain(glm::vec3 pos,Game* parent) : Object(pos,parent)
{
  initialiseTriangles();
  freeze();
  shaderID = game->shaderManager->newShader("terrain",VERTEX_SHADER|GEOMETRY_SHADER|FRAGMENT_SHADER|TESSELATION_SHADER);
  makeTexture();
  texture = textureFromTGA("assets/grass.tga",true);
  forest = new Forest(parent,heightmapTexture);
}
Esempio n. 7
0
// コンストラクタ
KinectV2::KinectV2()
{
  // センサを取得する
  if (sensor == NULL && GetDefaultKinectSensor(&sensor) == S_OK)
  {
    HRESULT hr;

    // センサの使用を開始する
    hr = sensor->Open();
    assert(hr == S_OK);

    // デプスデータの読み込み設定
    IDepthFrameSource *depthSource;
    hr = sensor->get_DepthFrameSource(&depthSource);
    assert(hr == S_OK);
    hr = depthSource->OpenReader(&depthReader);
    assert(hr == S_OK);
    IFrameDescription *depthDescription;
    hr = depthSource->get_FrameDescription(&depthDescription);
    assert(hr == S_OK);
    depthSource->Release();

    // デプスデータのサイズを得る
    depthDescription->get_Width(&depthWidth);
    depthDescription->get_Height(&depthHeight);
    depthDescription->Release();

    // カラーデータの読み込み設定
    IColorFrameSource *colorSource;
    hr = sensor->get_ColorFrameSource(&colorSource);
    assert(hr == S_OK);
    hr = colorSource->OpenReader(&colorReader);
    assert(hr == S_OK);
    IFrameDescription *colorDescription;
    hr = colorSource->get_FrameDescription(&colorDescription);
    assert(hr == S_OK);
    colorSource->Release();

    // カラーデータのサイズを得る
    colorDescription->get_Width(&colorWidth);
    colorDescription->get_Height(&colorHeight);
    colorDescription->Release();

    // 座標のマッピング
    hr = sensor->get_CoordinateMapper(&coordinateMapper);
    assert(hr == S_OK);

    // depthCount と colorCount を計算してテクスチャとバッファオブジェクトを作成する
    makeTexture();

    // デプスデータからカメラ座標を求めるときに用いる一時メモリを確保する
    position = new GLfloat[depthCount][3];

    // カラーデータを変換する用いる一時メモリを確保する
    color = new GLubyte[colorCount * 4];
  }
}
Esempio n. 8
0
GLuint workshopScene::textureFromFile(std::string name, std::string reldir)
{
    std::stringstream ss;
    ss << path << reldir << name;
    GLFWimage img;
    if (!glfwReadImage(ss.str().c_str(), &img, 0))
        std::cout << "Could not load texture: " << ss.str() << "\n";
    GLuint texhandle = makeTexture(img);
    glfwFreeImage(&img);
    return texhandle;
}
Esempio n. 9
0
Equalizer::Equalizer( QGLShaderProgram *program, int width, int height)
 	: columns(1), bands_count(22), texture(0) {

  this->program = program;
	this->width   = width;
	this->height  = height;
  bands = new float[bands_count];

  glGenTextures(1, &texture);

	makeTexture();
}
Esempio n. 10
0
void ResourceManager::loadResources() {
  Json::Value models = ParamReader::get()->getParam("resources.models");
  Json::Value textures = ParamReader::get()->getParam("resources.textures");
  Json::Value shaders = ParamReader::get()->getParam("resources.shaders");
  Json::Value dfdescs = ParamReader::get()->getParam("resources.depthFields");

  for (Json::ValueIterator texture = textures.begin();
          texture != textures.end(); texture++) {
    textures_[texture.key().asString()] = makeTexture((*texture).asString());
  }

  LOG(DEBUG) << "Loading models\n";
  for (Json::ValueIterator it = models.begin(); it != models.end(); it++) {
    std::string model_name = it.key().asString();
    Json::Value model_desc = *it;
    std::string model_file = must_have_idx(model_desc, "file").asString();
    LOG(DEBUG) << "loading " << model_file << '\n';
    auto *model = loadModel(model_file);
    setModelTransform(model, getModelTransform(model_desc));
    models_[model_name] = model;
  }

  for (Json::ValueIterator shader = shaders.begin();
          shader != shaders.end(); shader++) {
    GLuint program =
      loadProgram((*shader)["vert"].asString(), (*shader)["frag"].asString());
    shaders_[shader.key().asString()] = new Shader(program);
  }

  for (Json::ValueIterator dfdesc = dfdescs.begin();
          dfdesc != dfdescs.end(); dfdesc++) {
    DepthField *df = new DepthField;
    df->texture = makeTexture((*dfdesc)["file"].asString());
    df->minDist = (*dfdesc)["minDist"].asFloat();
    df->maxDist = (*dfdesc)["maxDist"].asFloat();
    depthFields_[dfdesc.key().asString()] = df;
  }
}
OrbitEditor::OrbitEditor( int& id, int WIDTH_, int HEIGHT_ ) : AppSDL2OGL_3D( id, WIDTH_, HEIGHT_ ) {

    double dt_ = 1.0;
    bool derivs = true;
    splines.allocate( 3, 10, derivs );
    for(int i=0; i<splines.n; i++){
        splines.ts [i]     = i*dt_;
        splines.CPs[0][i]  = randf( -1.0f, 1.0f );
        splines.CPs[1][i]  = randf( -1.0f, 1.0f );
        splines.CPs[2][i]  = randf( -1.0f, 1.0f );
        if(derivs){
            splines.dCPs[0][i]  = randf( -1.0f, 1.0f )/dt_;
            splines.dCPs[1][i]  = randf( -1.0f, 1.0f )/dt_;
            splines.dCPs[2][i]  = randf( -1.0f, 1.0f )/dt_;

            //splines.dCPs[0][i]  = 0;
            //splines.dCPs[1][i]  = 0;
            //splines.dCPs[2][i]  = 0;
            printf("%i %3.3f (%3.3f,%3.3f,%3.3f) (%3.3f,%3.3f,%3.3f) \n", i, splines.ts[i], splines.CPs[0][i], splines.CPs[1][i], splines.CPs[2][i],  splines.dCPs[0][i], splines.dCPs[1][i], splines.dCPs[2][i]    );
        }else{
            printf("%i %3.3f (%3.3f,%3.3f,%3.3f)\n", i, splines.ts[i], splines.CPs[0][i], splines.CPs[1][i], splines.CPs[2][i]    );
        }

    }
    splines.ts[2]     -= 0.3;

    int nsamp_max = 1000;
    positions      = new Vec3d[nsamp_max ];
    velocities     = new Vec3d[nsamp_max ];
    accelerations  = new Vec3d[nsamp_max ];

    tstart = 1.15;
    tend   = 8.9;
    dt     = 0.01;
    nsamp = splines.evalUniform( tstart, tend, dt, 3, which, (double*)positions, (double*)velocities, (double*)accelerations );

    //DEGUB
    //dpos   = new Vec3d[nsamp_max ];
    //ddpos  = new Vec3d[nsamp_max ];
    //double invdt = 1/dt;
    //for(int i=0;i<nsamp-1;i++){ dpos [i]=( positions[i+1]-positions[i] )*invdt;  };
    //for(int i=0;i<nsamp-2;i++){ ddpos[i]=( dpos[i+1]-dpos[i] )*invdt;             };

    fontTex = makeTexture( "common_resources/dejvu_sans_mono_RGBA_inv.bmp" );
    //txtPop   .inputText = "txtPop";
    txtStatic.inputText = "txtStatic";

    zoom = 2;

}
Esempio n. 12
0
void init(void)
{
 //背景色
  glClearColor(0.2, 0.2, 0.3, 1.0);

  setCamera();//視点を求める
  setLight(); //光源設定 
	glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);
	setShadowMap();
  printf("マウス/キー操作の説明には'h'キーをプッシュ \n");
  //テクスチャー作成
	makeTexture();

}
Esempio n. 13
0
void GFX::loadTexture(const char *filename, GLenum filter)
{
	const char *extension = strrchr(filename, '.'); // determine the filetype
	iV_Image image;
	if (!extension || strcmp(extension, ".png") != 0)
	{
		debug(LOG_ERROR, "Bad image filename: %s", filename);
		return;
	}
	if (iV_loadImage_PNG(filename, &image))
	{
		makeTexture(image.width, image.height, filter, iV_getPixelFormat(&image), image.bmp);
		iV_unloadImage(&image);
	}
}
//AeroCraftGUI:: AeroCraftGUI( int& id, int WIDTH_, int HEIGHT_ ) : ScreenSDL2OGL_3D( id, WIDTH_, HEIGHT_ ) {
AeroCraftGUI:: AeroCraftGUI( int& id, int WIDTH_, int HEIGHT_ ) : AppSDL2OGL_3D( id, WIDTH_, HEIGHT_ ) {
    //fontTex = makeTexture( "common_resources/dejvu_sans_mono.bmp" );
    //fontTex = makeTexture( "common_resources/dejvu_sans_mono_RGBA.bmp" );
    fontTex = makeTexture( "common_resources/dejvu_sans_mono_RGBA_inv.bmp" );
    //fontTex = makeTexture( "common_resources/dejvu_sans_mono_Alpha.bmp" );

    panel.init( 5,5,105,35,  fontTex );
    panel.caption   = "rotation [Rad]"; panel.vmin = -3.14159265359; panel.vmax = 3.14159265359;


    mpanel.initMulti( 120,5,200,120, fontTex , 4 );
    mpanel.caption="MultiPanel_1";

    txt.inputText = "insert number using =+-*/";

    SDL_StartTextInput ();
    //panel.nChars = 6;
};
Esempio n. 15
0
ImTextureID PiGui::RenderSVG(std::string svgFilename, int width, int height) {
	Output("nanosvg: %s %dx%d\n", svgFilename.c_str(), width, height);
	NSVGimage *image = NULL;
	NSVGrasterizer *rast = NULL;
	unsigned char* img = NULL;
	int w, h;
	// size of each icon
	//	int size = 64;
	// 16 columns
	//	int W = 16*size;
	int W = width;
	// 16 rows
	//	int H = 16*size;
	int H = height;
	img = static_cast<unsigned char*>(malloc(W*H*4));
	memset(img, 0, W * H * 4);
	std::string filename = svgFilename; // FileSystem::JoinPath(FileSystem::JoinPath(FileSystem::GetDataDir(), "icons"), "icons.svg");
	image = nsvgParseFromFile(filename.c_str(), "px", 96.0f);
	if (image == NULL) {
		Error("Could not open SVG image.\n");
	}
	w = static_cast<int>(image->width);
	h = static_cast<int>(image->height);

	rast = nsvgCreateRasterizer();
	if (rast == NULL) {
		Error("Could not init rasterizer.\n");
	}

	if (img == NULL) {
		Error("Could not alloc image buffer.\n");
	}
	{
		float scale = double(W)/w;
		float tx = 0;
		float ty = 0;
		nsvgRasterize(rast, image, tx, ty, scale, img, W, H, W*4);
	}
	nsvgDeleteRasterizer(rast);
	nsvgDelete(image);
	return makeTexture(img, W, H);
}
Esempio n. 16
0
void init() {
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel(GL_FLAT);
	glEnable(GL_DEPTH_TEST);

	makeTexture();

	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	glGenTextures(1, &texName);
	glBindTexture(GL_TEXTURE_2D, texName);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
	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_RGBA, imageWidth, imageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureImage);

}
Esempio n. 17
0
GLFont *glFontLoad(char *fontfile) {
	GLFont *font = NULL;
	BMPFile *bmp = NULL;

	bmp = BMP_Load(fontfile);
	if (!bmp) return NULL;

	font = calloc(1, sizeof(GLFont));
	if (!font) {
		BMP_Destroy(&bmp);
		return NULL;
	}

	font->textureID = makeTexture(BMP_GetWidth(bmp), BMP_GetHeight(bmp), BMP_GetPixelArray(bmp));
	BMP_Destroy(&bmp);

	font->base = makeFontList(font->textureID);

	return font;
}
void StereogramWidget::calcStereogram(void)
{
    makeTexture();
    mScaledDepthData = mOriginalDepthData.scaled(mRequestedStereogramSize);
    mStereogram = QImage(mRequestedStereogramSize, QImage::Format_RGB32);
    if (mTexture.isNull())
        return;
    for (int y = 0; y < mScaledDepthData.size().height(); ++y) {
        DepthData::DepthDataType sameArr(mStereogram.width());
        DepthData::DepthDataType::const_iterator data = y * mScaledDepthData.size().width() + mScaledDepthData.data().begin();
        makeSameArray(sameArr, data, mScaledDepthData.size().width() / mStereogram.width());
        QRgb* const dst = reinterpret_cast<QRgb*>(mStereogram.scanLine(y));
        const QRgb* const src = reinterpret_cast<QRgb*>(mTexture.scanLine(y));
        int x = mStereogram.width();
        while (x--) {
            const int same = sameArr[x];
            dst[x] = (same == x)
                    ? src[same % mTexture.width()]
                    : dst[same];
					
					// if (same=x) then dst[x] := src[same mod Texture.width) else dst[x] := dst[same]
        }
    }
}
Esempio n. 19
0
workshopScene::workshopScene(std::string path_)
:mouseRayCallback(btVector3(0, 0, 0), btVector3(0, 0, 0)),
 axisResult(btVector3(0, 0, 0), btVector3(0, 0, 0))
{
    path = path_;
    DIR *dir;
    dirent *ent;
    gWorld = new world();
    gWorld->btWorld->setGravity(btVector3(0, 0, 0));
    mouseConstraint = 0;
    std::stringstream ss;
    ss << path << "data/plane_10x10.bsm";
    gWorld->addObject(new physObj(0, btVector3(0, -1, 0), new btStaticPlaneShape(btVector3(0, 1, 0), 1), new model(ss.str())));
    ss.str("");
    ss << path << "assemblies";
    dir = opendir(ss.str().c_str());
    if (dir == NULL)
    {
        std::cout << "Could not open assemblies directory.\n";
        return;
    }
    int i = 0;
    while ((ent = readdir(dir)) != NULL)
    {
        if (ent->d_type == DT_DIR && ++i > 2)     //discard "." and ".."
        {
            partnames.push_back(ent->d_name);
        }
    }
    closedir(dir);

    for (unsigned int i = 0; i < partnames.size(); i++)
    {
        std::cout << "Part: " << partnames[i] << "\n";
        std::stringstream ss;
        ss << path << "assemblies/" << partnames[i] << "/thumb.tga";
        std::cout << ss.str() << "\n";
        GLFWimage img;
        if (glfwReadImage(ss.str().c_str(), &img, 0))
        {
            thumbnails.push_back(makeTexture(img));
            glfwFreeImage(&img);
        }
        else
        {
            thumbnails.push_back(0);
            std::cout << "Could not load thumbnail for " << partnames[i] << "\n";
        }
    }
    cursor = textureFromFile("cursor.tga");
    panel = ninePatch(textureFromFile("9patch.tga"));
    button = ninePatch(textureFromFile("button.tga"));
    bubble = ninePatch(textureFromFile("bubble.tga"), 8, 16, 12, 8, 0.25, 0.5, 0.375, 0.75);
    tooltextures.push_back(textureFromFile("drag.tga"));
    tooltextures.push_back(textureFromFile("axis.tga"));
    tooltextures.push_back(textureFromFile("delete.tga"));
    font = textureFromFile("font.tga");
    cursorx = 0;
    cursory = 0;
    mousevelx = 0;
    mousevely = 0;
    mouseWasCaptured = false;
    camera.position = btVector3(0, 0, 10);
    camera.pitch = 0;
    camera.yaw = 0;
    camera.orientationFromAngles();
    selectedItem = -1;
    selectedTool = -1;
    static unsigned char fontpixels[STB_SOMEFONT_BITMAP_HEIGHT][STB_SOMEFONT_BITMAP_WIDTH];
    STB_SOMEFONT_CREATE(fontdata, fontpixels, STB_SOMEFONT_BITMAP_HEIGHT);
    glGenTextures(1, &stbfont);
    glBindTexture(GL_TEXTURE_2D, stbfont);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_WRAP_BORDER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_WRAP_BORDER);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, STB_SOMEFONT_BITMAP_HEIGHT, STB_SOMEFONT_BITMAP_WIDTH, 0, GL_ALPHA, GL_UNSIGNED_BYTE, fontpixels);
}
Esempio n. 20
0
/*
 =======================================================================================================================
    void init() This function is called once at the beginning of program execution allowing initialisation of variables
    etc.
 =======================================================================================================================
 */
void init()
{

	/* set the finishes */
	finPot = (Finish)
	{
		{
			0.2, 0.2, 0.2, 1.0
		},
		{
			0.8, 0.8, 0.8, 1.0
		},
		{
			1.0, 1.0, 1.0, 1.0
		},
		{
			0.7, 0.7, 0.7, 1.0
		},
		1.0
	};
	finDefault = (Finish)
	{
		{
			0.2, 0.2, 0.2, 1.0
		},
		{
			0.8, 0.8, 0.8, 1.0
		},
		{
			0.0, 0.0, 0.0, 1.0
		},
		{
			0.0, 0.0, 0.0, 1.0
		},
		0.0
	};
	finTable = (Finish)
	{
		{
			0.2, 0.2, 0.2, 1.0
		},
		{
			0.8, 0.8, 0.8, 1.0
		},
		{
			0.0, 0.0, 0.0, 1.0
		},
		{
			0.0, 0.0, 0.0, 1.0
		},
		1.0
	};
	finFork = (Finish)
	{
		{
			0.2, 0.2, 0.2, 1.0
		},
		{
			0.8, 0.8, 0.8, 1.0
		},
		{
			0.5, 0.5, 0.5, 1.0
		},
		{
			0.0, 0.0, 0.0, 1.0
		},
		1.5
	};
	finCup = (Finish)
	{
		{
			0.2, 0.2, 0.2, 1.0
		},
		{
			0.6, 0.6, 0.6, 1.0
		},
		{
			0.2, 0.2, 0.2, 1.0
		},
		{
			0.2, 0.2, 0.2, 1.0
		},
		1.5
	};

	/* enable some standard things */
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_NORMALIZE);
	quadratic = gluNewQuadric();
	gluQuadricNormals(quadratic, GLU_SMOOTH);

	/* set initial rotation and scale values */
	alpha = -(float) 20.0;
	beta = (float) 20.0;
	scale = (float) 1.0;
	zoom = 1.0;
	inc = 0;
	inc2 = 0;

	/*
	 * read in some textures using libbmpread (much better than the one on blackboard)
	 * source: https://github.com/chazomaticus/libbmpread
	 */
	if(bmpread("b.bmp", 4, &(teapottex[0])) == 0)
	{
		printf("failed loading texture");
		perror("error");
	}

	makeTexture(teapottex[0], 0);
	if(bmpread("g.bmp", 4, &(teapottex[1])) == 0)
	{
		printf("failed loading texture");
		perror("error");
	}

	makeTexture(teapottex[1], 1);
	if(bmpread("n.bmp", 4, &(teapottex[2])) == 0)
	{
		printf("failed loading texture");
		perror("error");
	}

	makeTexture(teapottex[2], 2);
}
OpenGLFramebufferObject::OpenGLFramebufferObject(const QSize &size,
                                                 OGL::TextureFormat internal)
    : OpenGLFramebufferObject(makeTexture(size, internal), true) { }
Esempio n. 22
0
void room::initRoom(float dimensions_p[3], float origin_p[3], struct roomTextures *Proom_p, int doors_p) { 
  int debug = 1;
  // This int holds how many textures will be used for a room
  int totalDoorTexes = 4;
  srand(time(NULL));
  door1.innerDoor = makeTexture("textures/door0.png"); 
  door1.floorPad  = makeTexture("textures/floorPad.png");  
  dimensions[0]    = dimensions_p[0];
  dimensions[1]    = dimensions_p[1];
  dimensions[2]    = dimensions_p[2];
  origin[0]        = origin_p[0];
  origin[1]        = origin_p[1];
  origin[2]        = origin_p[2];
  Proom         = Proom_p;
  numDoors = doors_p;  
  // This is all for the doors:
  int i, j, l, k=0;
  int side = 0;
  int one=0, two=0;
  while(k<doors_p) {
    //side = (int)rand() % 6; //Pick which side we want the door to be on
    side = 1 + ((int)rand() % 4); 
    switch (side) {
      //NOTE:
      // I guess the variable 'one' is always equal to zero?
      //Edit: I forgot, I moved all the doors to the bottom level
      /*case (0): //Bottom of the cube
        one = (int)rand() %  ((int)dimensions_p[2]);
        two = (int)rand() % ((int)dimensions_p[0]-1);        
        PtextMem.bottom_door[one][two] = 1;
        if (debug == 1)
          printf("Side: Bottom one = %d, two = %d,\n", one, two);    
        break;*/
      case (1): //Front of the cube
        doorStructs[k] = (doorInformation *) malloc(sizeof(doorInformation)); //All important malloc for dynamic doors
        doorStructs[k]->side = 1; //Set side to 1, meaning front
	      doorStructs[k]->doorNumber = k;
	      //one = (int)rand() % ((int)dimensions_p[1]+1);
        two = (int)rand() % ((int)dimensions_p[0]);
        // The reason this is so batshit f*****g long is because we need to make sure doors
        // don't have pressure pads that overlap on corners. And stuff.
        if (floorPads1.floorPadsPlaces[0][two] != 1) {
          doorStructs[k]->x=one;
          doorStructs[k]->y=two;
          PtextMem.front_door[one][two] = 1; //Tells the room drawing func to not draw a wall
          floorPads1.floorPadsPlaces[0][two] = 1; //Tells the same func to draw a floorpad.
          doorStructs[k]->floorLoc[0][two]=1;
          if (debug == 1)
            printf("Side: Front one = %d, two = %d,\n", one, two);
          k++;
        }
        break;    
      case (2): //Right of the cube
        doorStructs[k] = (doorInformation *) malloc(sizeof(doorInformation));
        doorStructs[k]->side = 2;
	      doorStructs[k]->doorNumber = k;
        //one = (int)rand() %  ((int)dimensions_p[2]);
        two = (int)rand() % ((int)dimensions_p[1]);
        if (floorPads1.floorPadsPlaces[two][(int)dimensions_p[1]-1] != 1) {
        doorStructs[k]->x=one;
          doorStructs[k]->y=two;
          PtextMem.right_door[one][two] = 1;
          floorPads1.floorPadsPlaces[two][(int)dimensions_p[1]-1] = 1;
          doorStructs[k]->floorLoc[two][(int)dimensions_p[1]-1]=1;
          if (debug == 1)
            printf("Side: Right one = %d, two = %d,\n", one, two);
          k++;
        }
        break;
      case (3): //Back wall of the cube
        doorStructs[k] = (doorInformation *) malloc(sizeof(doorInformation));
        doorStructs[k]->side = 3;
	      doorStructs[k]->doorNumber = k;
        //one = (int)rand() %  ((int)dimensions_p[1]+1);
        two = (int)rand() % ((int)dimensions_p[0]); 
        if (floorPads1.floorPadsPlaces[(int)dimensions_p[0]-1][two] != 1) {
          doorStructs[k]->x=one;
          doorStructs[k]->y=two;
          PtextMem.back_door[one][two] = 1;
          floorPads1.floorPadsPlaces[(int)dimensions_p[0]-1][two] = 1;
          doorStructs[k]->floorLoc[(int)dimensions_p[0]-1][two]=1;
          if (debug == 1)
            printf("Side: Back one = %d, two = %d,\n", one, two); 
          k++;
        }
        break;
      case (4): //Left side of the cube
        doorStructs[k] = (doorInformation *) malloc(sizeof(doorInformation));
        doorStructs[k]->side = 4;
	      doorStructs[k]->doorNumber = k;
        //one = (int)rand() %  ((int)dimensions_p[2]);
        two = (int)rand() % ((int)dimensions_p[1]); 
        if (floorPads1.floorPadsPlaces[two][0] != 1) {
          doorStructs[k]->x=one;
          doorStructs[k]->y=two;
          PtextMem.left_door[one][two] = 1;
          floorPads1.floorPadsPlaces[two][0] = 1;
          doorStructs[k]->floorLoc[two][0]=1;
          if (debug == 1)
            printf("Side: Left one = %d, two = %d,\n", one, two);
          k++;
        }
        break;
      /*case (5): //Top of the cube
        one = (int)rand() %  ((int)dimensions_p[2]);
        two = (int)rand() % ((int)dimensions_p[0]-1); 
        PtextMem.top_door[one][two] = 1;
        if (debug == 1)
          printf("Side: Top one = %d, two = %d,\n", one, two);
        break;*/
        printf("%d\n", k);
    }    
    //k++;
    one = 0;
    two = 0;       
  }
  //This little POS picks textures for the walls.
  for (l=0;l<dimensions[2];l++) {
    for (i=0;i<dimensions[1];i++) {
      for (j=0;j<dimensions[0];j++) {
        PtextMem.top_tex[i][j] = Proom->ceiling;
        PtextMem.bottom_tex[i][j] = Proom->floor;
        PtextMem.front_tex[i+l][j] = Proom->wall[(int)rand() % totalDoorTexes];
        PtextMem.back_tex[i+l][j] = Proom->wall[(int)rand() % totalDoorTexes];
        PtextMem.left_tex[i+l][j] = Proom->wall[(int)rand() % totalDoorTexes];
        PtextMem.right_tex[i+l][j] = Proom->wall[(int)rand() % totalDoorTexes];
      }
    }
  }
}
TestAppMesh::TestAppMesh( int& id, int WIDTH_, int HEIGHT_ ) : AppSDL2OGL_3D( id, WIDTH_, HEIGHT_ ) {

    fontTex = makeTexture( "common_resources/dejvu_sans_mono_RGBA_inv.bmp" );

    mesh.fromFileOBJ( "common_resources/turret.obj" );
    //mesh.fromFileOBJ( "common_resources/tank_hull.obj" );

    mesh.findEdges(); //exit(0);

    mesh.polygons[2]->printPoints();
    mesh.polygons[8]->printPoints();
    mesh.insertEdgeVertex( 14 );
    mesh.points[mesh.points.size()-1].add(0.5,0.5,0.0);
    mesh.polygons[2]->printPoints();
    mesh.polygons[8]->printPoints();

    int ip = mesh.colapseEdge(12);
    mesh.cleanRemovedPoints();


    mesh.polygonsToTriangles();
    mesh.tris2normals(true);
    printf("initialization DONE !");

    mesh.rendered_shape = glGenLists(1);
    glNewList( mesh.rendered_shape , GL_COMPILE );
        glEnable( GL_LIGHTING );
        glColor3f( 0.8f, 0.8f, 0.8f );

        Draw3D::drawMesh( mesh );
        glColor3f(0.0f,0.0f,0.9f);
        for(int i=0; i<mesh.points.size(); i++){
            Draw3D::drawVecInPos( mesh.normals[i], mesh.points[i] );
        }
        /*
        glBegin(GL_TRIANGLES);
        for( Vec3i tri : mesh.triangles ){
            Vec3f p,n;
            convert( mesh.points[tri.a], p ); convert( mesh.normals[tri.a], n ); glNormal3f( n.x, n.y, n.z ); glVertex3f( p.x, p.y, p.z );
            convert( mesh.points[tri.b], p ); convert( mesh.normals[tri.b], n ); glNormal3f( n.x, n.y, n.z ); glVertex3f( p.x, p.y, p.z );
            convert( mesh.points[tri.c], p ); convert( mesh.normals[tri.c], n ); glNormal3f( n.x, n.y, n.z ); glVertex3f( p.x, p.y, p.z );
        };
        */
        for(int i=0; i<mesh.points.size(); i++){
            Draw3D::drawVecInPos( mesh.normals[i], mesh.points[i] );
        }
        glEnd();
    glEndList();

    // TO DO : convex hull
    /*
    int npoints = 20;
    Vec3d * points = new Vec3d[npoints];
    for(int i=0; i<npoints; i++){
        points[i].set( randf(-1.0,1.0), randf(-1.0,1.0), randf(-1.0,1.0) );
    }

    mesh.rendered_shape = glGenLists(1);
    glNewList( mesh.rendered_shape , GL_COMPILE );
    glDisable(GL_LIGHTING);
    glColor3f(1.0,1.0,1.0);
    glBegin( GL_POINTS );
        for(int i=0; i<npoints; i++){ glVertex3f( points[i].x, points[i].y, points[i].z ); }
    glEnd();
    glEndList();
    */

    //exit(0);

}
Esempio n. 24
0
void POVRayExport::exportParticle(std::ofstream& os, const shared_ptr<Particle>& p){
	const auto sphere=dynamic_cast<Sphere*>(p->shape.get());
	const auto capsule=dynamic_cast<Capsule*>(p->shape.get());
	const auto ellipsoid=dynamic_cast<Ellipsoid*>(p->shape.get());
	const auto wall=dynamic_cast<Wall*>(p->shape.get());
	const auto infCyl=dynamic_cast<InfCylinder*>(p->shape.get());
	const auto facet=dynamic_cast<Facet*>(p->shape.get());
	// convenience
	const auto& n0(p->shape->nodes[0]);


	if(sphere) os<<"sphere{ o, "<<sphere->radius<<" "<<makeTexture(p)<<" "<<node2pov(n0)<<" }";
	else if(capsule) os<<"sphere_sweep{ linear_spline, 2, <"<<-.5*capsule->shaft<<",0,0> ,"<<capsule->radius<<", <"<<.5*capsule->shaft<<",0,0> ,"<<capsule->radius<<" "<<makeTexture(p)<<" "<<node2pov(n0)<<" }";
	else if(ellipsoid) os<<"sphere{ o, 1 scale "<<vec2pov(ellipsoid->semiAxes)<<" "<<makeTexture(p)<<" "<<node2pov(n0)<<" }";
	else if(wall){
		if((wall->glAB.isEmpty())){ os<<"plane{ "<<Vector3r::Unit(wall->axis)<<", "<<wall->nodes[0]->pos[wall->axis]; }
		else{ // quad, as mesh2
			Vector3r a; a[wall->axis]=wall->nodes[0]->pos[wall->axis]; Vector3r b(a), c(a), d(a);
			short ax1((wall->axis+1)%3), ax2((wall->axis+2)%3);
			a[ax1]=wall->glAB.min()[0]; a[ax2]=wall->glAB.min()[1];
			b[ax1]=wall->glAB.min()[0]; b[ax2]=wall->glAB.max()[1];
			c[ax1]=wall->glAB.max()[0]; c[ax2]=wall->glAB.min()[1];
			d[ax1]=wall->glAB.max()[0]; d[ax2]=wall->glAB.max()[1];
			os<<"mesh2{ vertex_vectors { 4 "<<vec2pov(a)<<", "<<vec2pov(b)<<", "<<vec2pov(c)<<", "<<vec2pov(d)<<" } face_indices { 2, <0,2,1>, <1,2,3> }";
		}
		os<<makeTexture(p,wallTexture)<<" }"; // will use the default if wallTexture is empty
	}
	else if(infCyl){
		if(isnan(infCyl->glAB.maxCoeff())){ // infinite cylinder, use quadric for this
			Vector3r abc=Vector3r::Ones(); abc[infCyl->axis]=0;
			os<<"quadric{ "<<vec2pov(abc)<<", <0,0,0>, <0,0,0>, -1 "<<makeTexture(p)<<" "<<node2pov(n0)<<" }";
		} else {
			#if 0
			#endif
			// base point (global coords), first center
			Vector3r pBase(n0->pos); pBase[infCyl->axis]+=infCyl->glAB[0];
			// axis vector (global coords), pBase+pAxis is the second center
			Vector3r pAxis(Vector3r::Zero()); pAxis[infCyl->axis]=infCyl->glAB[1]-infCyl->glAB[0];
			// axial rotation; warn if not around the axis
			AngleAxisr aa(n0->ori); Vector3r axRotVecDeg(aa.axis()*aa.angle()*180./M_PI);
			if(aa.angle()>1e-6 && abs(aa.axis()[infCyl->axis])<.999999) LOG_WARN("#"<<p->id<<": InfCylinder rotation not aligned with its axis (cylinder axis "<<infCyl->axis<<"; rotation axis "<<aa.axis()<<", angle "<<aa.angle()<<")");
			bool open=!cylCapTexture.empty();
			if(open){
				os<<"/*capped cylinder*/";
				Vector3r normal=Vector3r::Unit(infCyl->axis);
				for(int i:{-1,1}){
					os<<"disc{ o, "<<vec2pov(i*normal)<<", "<<infCyl->radius<<" "<<makeTexture(p,cylCapTexture)<<" rotate "<<vec2pov(axRotVecDeg)<<" translate "<<vec2pov(i<0?pBase:(pBase+pAxis).eval());
					os<<" }";
				}
			}
			// length of the cylinder
			Real cylLen=(infCyl->glAB[1]-infCyl->glAB[0]);
			// non-axial rotation, from +x cyl to infCyl->axis (case-by-case)
			Vector3r nonAxRotVec=(infCyl->axis==0?Vector3r::Zero():(infCyl->axis==1?Vector3r(0,0,90):Vector3r(0,-90,0)));
			// cylinder spans +x*cylLen from origin, then rotated, so that the texture is rotated as well
			os<<"cylinder{ o, <"<<cylLen<<",0,0>, "<<infCyl->radius<<(open?" open ":" ")<<" "<<makeTexture(p)<<" rotate "<<vec2pov(nonAxRotVec)<<" rotate "<<vec2pov(axRotVecDeg)<<" translate "<<vec2pov(pBase)<<" }";
		}
	}
	else if(facet){
		// halfThick ignored for now, as well as connectivity
		if(facet->halfThick>0){
			Vector3r dp=facet->getNormal()*facet->halfThick;
			const Vector3r& a(facet->nodes[0]->pos); const Vector3r& b(facet->nodes[1]->pos); const Vector3r& c(facet->nodes[2]->pos);
			os<<"merge{ sphere_sweep{ linear_spline, 4 "<<vec2pov(a)<<", "<<facet->halfThick<<", "<<vec2pov(b)<<", "<<facet->halfThick<<", "<<vec2pov(c)<<", "<<facet->halfThick<<", "<<vec2pov(a)<<", "<<facet->halfThick<<" } triangle{"<<vec2pov(a+dp)<<", "<<vec2pov(b+dp)<<", "<<vec2pov(c+dp)<<" } triangle {"<<vec2pov(a-dp)<<", "<<vec2pov(b-dp)<<", "<<vec2pov(c-dp)<<" } "<<makeTexture(p)<<" }";
		} else {
			os<<"triangle{ "<<vec2pov(facet->nodes[0]->pos)<<", "<<vec2pov(facet->nodes[1]->pos)<<", "<<vec2pov(facet->nodes[2]->pos)<<" "<<makeTexture(p)<<" }";
		}
	}
	os<<" // id="<<p->id<<endl;
}
Esempio n. 25
0
int
main (int argc, char **argv)
{
	int i;
	double now;

	feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);

	init_sdl_gl_flags (WIDTH, HEIGHT, 0);

	srandom (time (NULL));

	init_gl (&argc, argv);

	glEnable (GL_LIGHTING);
	glEnable (GL_DEPTH_TEST);
	glEnable (GL_AUTO_NORMAL);
	glEnable (GL_NORMALIZE);

	glClearDepth (1);
	
	glViewport (0, 0, WIDTH, HEIGHT);
	glMatrixMode (GL_PROJECTION);
	glLoadIdentity ();
	gluPerspective (60, (GLfloat) WIDTH/(GLfloat) HEIGHT, .1, 1000);
	glClearColor (0, 0, 0, 0);
	glMatrixMode (GL_MODELVIEW);

	SDL_ShowCursor (1);

	makeImages ();

	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
	glGenTextures (1, texName);
	
	makeTexture (texName[0], groundtexture.texturesize,
		     (GLubyte ***) groundtexture.tex);

	glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
	glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);

	glBlendFunc (GL_SRC_ALPHA, GL_ONE);

	gndcounter = 1;
	read_terrain ();

	player.p.x = 0;
	player.p.y = 0;
	player.p.z = ground_height (&player.p);

	player.loc = detect_plane (&player.p);

	player.movtype = GROUNDED;

	player.speed = 100;
	player.mass = 1;

	vset (&player.vel, 0, 0, 0);

	player.turnspeed = DTOR (180);
	player.theta = DTOR (0);
	player.camdist = 15;

	player.lasttime = get_secs ();
	player.moving = NO;

	playercamera.phi = DTOR (0);
	playercamera.theta_difference = 0;
	
	while (1) {
		process_input ();
		
		if (mousebutton[1] == 0
		    && mousebutton[2] == 0
		    && mousebutton[3] == 0) {
			SDL_ShowCursor (1);
		} else {
			SDL_ShowCursor (0);
		}

		movement ();
		if (paused == NO) {
			for (i = 0; i < 1; i++) {
				moving ();
				now = get_secs ();
				player.lasttime = now;
			}
		}

		process_mouse ();

		draw ();
		
		now = get_secs ();
		
		player.lasttime = now;

		SDL_Delay (10);
	}

	return (0);
}
Esempio n. 26
0
void special(int key, int x, int y)
{
  if(sKey == TRANSLATE)
  {
	  switch( key )
	  {
	  case GLUT_KEY_RIGHT://x方向
		  pos[objNo][0] += 0.1;
		  break;
	  case GLUT_KEY_LEFT://-x方向
		  pos[objNo][0] -= 0.1;
		  break;
	  case GLUT_KEY_UP:
		  if(glutGetModifiers() == 0) pos[objNo][1] += 0.1;//y方向
		  else if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) pos[objNo][2] -= 0.1; //z方向
		  break;
	  case GLUT_KEY_DOWN:
		  if(glutGetModifiers() == 0) pos[objNo][1] -= 0.1;//-y方向
		  else if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) pos[objNo][2] += 0.1; //-z方向
		  break;
	  default:
		  break;
	  }
  }
  else if(sKey == ROTATE)
  {
	  switch( key )
	  {
	  case GLUT_KEY_RIGHT://x軸回転
		  angle[objNo][0] += 10.0;
		  break;
	  case GLUT_KEY_LEFT://-x軸回転
		  angle[objNo][0] -= 10.0;
		  break;
	  case GLUT_KEY_UP:
		  if(glutGetModifiers() == 0) angle[objNo][1] += 10;//y方向
		  else if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) angle[objNo][2] += 10; //z方向
		  break;
	  case GLUT_KEY_DOWN:
		  if(glutGetModifiers() == 0) angle[objNo][1] -= 10;//-y方向
		  else if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) angle[objNo][2] -= 10; //-z方向
		  break;
	  default:
		  break;
	  }
  }
  else if(sKey == SCALE)
  {
	  switch( key )
	  {
	  case GLUT_KEY_RIGHT://x方向拡大
		  scale[objNo][0] += 0.1;
		  break;
	  case GLUT_KEY_LEFT://x方向縮小
		  scale[objNo][0] -= 0.1;
		  break;
	  case GLUT_KEY_UP:
		  if(glutGetModifiers() == 0) scale[objNo][1] += 0.1;//y方向拡大
		  else if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) scale[objNo][2] += 0.1; //z方向
		  break;
	  case GLUT_KEY_DOWN:
		  if(glutGetModifiers() == 0) scale[objNo][1] -= 0.1;//y方向縮小
		  else if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) scale[objNo][2] -= 0.1; //z方向
		  break;
	  default:
		  break;
	  }
  }
  else if(sKey == LIGHT)
  {
		float d = 0.2;
	  switch( key )
	  {
	  case GLUT_KEY_RIGHT://x方向
		  lightPos[0] += d;
		  break;
	  case GLUT_KEY_LEFT:
		  lightPos[0] -= d;//-x方向
		  break;
	  case GLUT_KEY_UP:
		  if(glutGetModifiers() == 0) lightPos[1] += d;//y方向
		  if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) lightPos[2] -= d;//z方向
		  break;
	  case GLUT_KEY_DOWN:
		  if(glutGetModifiers() == 0) lightPos[1] -= d;//-y方向
		  if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) lightPos[2] += d;//-z方向
		  break;
	  default:
		  break;
	  }
  }
  if(key == GLUT_KEY_F1) 
  {
		inv *= -1.0;
		makeTexture();
  }	
  if(key == GLUT_KEY_F2) 
  {
		if(glutGetModifiers() == 0) fGrad += 1.0;
		if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) fGrad -= 1.0;
		if(fGrad < 0.0) fGrad = 0.0;
		printf("fGrad = %f \n", fGrad);
		makeTexture();
  }

  if(key == GLUT_KEY_F3) 
  {
		if(glutGetModifiers() == 0) fov += 1.0;
		if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) fov -= 1.0;
	  printf("fov=%f \n",fov);
  }
  if(key == GLUT_KEY_F4) 
  {
		if(glutGetModifiers() == 0) farZ += 1.0;
		if(glutGetModifiers() == GLUT_ACTIVE_SHIFT) farZ -= 1.0;
	  printf("farZ=%f \n",farZ);
  }
	if(key == GLUT_KEY_PAGE_UP) 
	{
		dang += 0.1;
  }	
	if(key == GLUT_KEY_PAGE_DOWN) 
	{
		dang -= 0.1;
  }	
}
void init_opengl(void)
{
    //OpenGL initialization
    glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
    //Initialize matrices
    glMatrixMode(GL_PROJECTION); glLoadIdentity();
    glMatrixMode(GL_MODELVIEW); glLoadIdentity();
    //Set 2D mode (no perspective)
    glOrtho(0, WINDOW_WIDTH, 0, WINDOW_HEIGHT, -1, 1);

    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_FOG);
    glDisable(GL_CULL_FACE);
    //Set the screen background color
    glClearColor(0.0, 0.0, 0.0, 1.0);
    //Initialize Fonts
    glEnable(GL_TEXTURE_2D);
    initialize_fonts();
    //system convert
    system("convert ./images/city.png ./images/city.ppm");
    system("convert ./images/street.jpg ./images/street.ppm");
    system("convert ./images/stars.png ./images/stars.ppm");
    system("convert ./images/civilian.jpg ./images/civilian.ppm");
    system("convert ./images/gameover.png ./images/gameover.ppm");
    system("convert ./images/mainmenu.png ./images/mainmenu.ppm");
    system("convert ./images/dcity.png ./images/dcity.ppm");
    system("convert ./images/emissile.png ./images/emissile.ppm");
    system("convert ./images/dmissile.png ./images/dmissile.ppm");
    system("convert ./images/ufo.png ./images/ufo.ppm");
    system("convert ./images/c_city.png ./images/c_city.ppm");
    system("convert ./images/c_emissile.png ./images/c_emissile.ppm");
    system("convert ./images/c_dmissile.png ./images/c_dmissile.ppm");
    system("convert ./images/c_floor.png ./images/c_floor.ppm");
    system("convert ./images/howtoplay.png ./images/howtoplay.ppm");
    //system("convert ./images/c_bomber.png ./images/c_bomber.ppm");
    //system("convert ./images/c_satellite.png ./images/c_satellite.ppm");
    //system("convert ./images/c_silo.png ./images/c_silo.ppm");
    //system("convert ./images/c_sbomb.png ./images/c_sbomb.ppm");

    //load images into a ppm structure
    cityImage = ppm6GetImage("./images/city.ppm");
    starsImage = ppm6GetImage("./images/stars.ppm");
    streetImage = ppm6GetImage("./images/street.ppm");
    civilianImage = ppm6GetImage("./images/civilian.ppm");
    gameoverImage =ppm6GetImage("./images/gameover.ppm");
    mainmenuImage = ppm6GetImage("./images/mainmenu.ppm");
    dcityImage = ppm6GetImage("./images/dcity.ppm");
    emissileImage = ppm6GetImage("./images/emissile.ppm");
    dmissileImage = ppm6GetImage("./images/dmissile.ppm");
    ufoImage = ppm6GetImage("./images/ufo.ppm");
    howtoImage = ppm6GetImage("./images/howtoplay.ppm");
    //classic images
    c_cityImage = ppm6GetImage("./images/c_city.ppm");
    c_emissileImage = ppm6GetImage("./images/c_emissile.ppm");
    c_dmissileImage = ppm6GetImage("./images/c_dmissile.ppm");
    c_floorImage = ppm6GetImage("./images/c_floor.ppm");

    //create opengl texture elements
    //stars
    starsTexture = makeTexture(starsTexture, starsImage);
    //street
    streetTexture = makeTexture(streetTexture, streetImage);
    //city
    cityTexture = makeTransparentTexture(cityTexture, cityImage);
    //civilian
    civilianTexture = makeTransparentTexture(civilianTexture, civilianImage);
    //dcity
    dcityTexture = makeTransparentTexture(cityTexture, dcityImage);
    //emissile
    emissileTexture = makeTransparentTexture(cityTexture, emissileImage);
    //dmissile
    dmissileTexture = makeTransparentTexture(cityTexture, dmissileImage);
    //ufo
    ufoTexture = makeTransparentTexture(cityTexture, ufoImage);
    //Others
    gameoverTexture = makeTransparentTexture(gameoverTexture, gameoverImage);
    mainmenuTexture = makeTexture(mainmenuTexture, mainmenuImage);
    howtoplayTexture = makeTexture(howtoplayTexture, howtoImage);
    //Classic
    c_floorTexture = makeTexture(c_floorTexture, c_floorImage);
    c_cityTexture = makeTransparentTexture(c_cityTexture, c_cityImage);
    c_emissileTexture = makeTransparentTexture(c_emissileTexture, c_emissileImage);
    c_dmissileTexture = makeTransparentTexture(c_dmissileTexture, c_dmissileImage);
    
    //remove ppm's
    remove("./images/city.ppm");
    remove("./images/stars.ppm");
    remove("./images/street.ppm");
    remove("./images/civilian.ppm");
    remove("./images/gameover.ppm");
    remove("./images/mainmenu.ppm");
    remove("./images/dcity.ppm");
    remove("./images/emissile.ppm");
    remove("./images/dmissile.ppm");
    remove("./images/ufo.ppm");
    remove("./images/howtoplay.ppm");
    //remove classic stuff  
    remove("./images/c_city.ppm");
    remove("./images/c_emissile.ppm");
    remove("./images/c_dmissile.ppm");
    remove("./images/c_floor.ppm");
}