Exemple #1
0
void Menu(int value)
{
	switch (value)
	{
		// Wenus
	case VENUS_TEX:
		texture = VENUS;
		DisplayScene();
		break;

		// Ziemia
	case EARTH_TEX:
		texture = EARTH;
		DisplayScene();
		break;

		// Mars
	case MARS_TEX:
		texture = MARS;
		DisplayScene();
		break;

		// Jowisz
	case JUPITER_TEX:
		texture = JUPITER;
		DisplayScene();
		break;

		// filtr pomniejszający
	case GL_NEAREST_MIPMAP_NEAREST:
	case GL_NEAREST_MIPMAP_LINEAR:
	case GL_LINEAR_MIPMAP_NEAREST:
	case GL_LINEAR_MIPMAP_LINEAR:
		min_filter = value;
		DisplayScene();
		break;

		// obszar renderingu - całe okno
	case FULL_WINDOW:
		aspect = FULL_WINDOW;
		Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
		break;

		// obszar renderingu - aspekt 1:1
	case ASPECT_1_1:
		aspect = ASPECT_1_1;
		Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
		break;

		// wyjście
	case EXIT:
		exit(0);
	}
}
void Reshape(int width, int height)
{
	// obszar renderingu - całe okno
	glViewport(0, 0, width, height);

	// wybór macierzy rzutowania
	glMatrixMode(GL_PROJECTION);

	// macierz rzutowania = macierz jednostkowa
	glLoadIdentity();

	// parametry bryły obcinania
	if (aspect == ASPECT_1_1)
	{
		// wysokość okna większa od wysokości okna
		if (width < height && width > 0)
			glFrustum(left, right, bottom*height / width, top*height / width, near, far);
		else

			// szerokość okna większa lub równa wysokości okna
		if (width >= height && height > 0)
			glFrustum(left*width / height, right*width / height, bottom, top, near, far);
	}
	else
		glFrustum(left, right, bottom, top, near, far);

	// generowanie sceny 3D
	DisplayScene();
}
void Menu(int value)
{
	switch (value)
	{
		// filtr pomniejszający
	case GL_NEAREST_MIPMAP_NEAREST:
	case GL_NEAREST_MIPMAP_LINEAR:
	case GL_LINEAR_MIPMAP_NEAREST:
	case GL_LINEAR_MIPMAP_LINEAR:
		min_filter = value;
		DisplayScene();
		break;

		// obszar renderingu - całe okno
	case FULL_WINDOW:
		aspect = FULL_WINDOW;
		Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
		break;

		// obszar renderingu - aspekt 1:1
	case ASPECT_1_1:
		aspect = ASPECT_1_1;
		Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
		break;

		// wyjście
	case EXIT:
		exit(0);
	}
}
void Keyboard(unsigned char key, int x, int y)
{
	// klawisz +
	if (key == '+')
		fog_density += 0.05;
	else

		// klawisz -
	if (key == '-' && fog_density > 0.05)
		fog_density -= 0.05;

	// narysowanie sceny
	DisplayScene();
}
Exemple #5
0
void Keyboard(unsigned char key, int x, int y)
{
	// klawisz +
	if (key == '+')
		scale += 0.05;
	else

		// klawisz -
		if (key == '-' && scale > 0.05)
			scale -= 0.05;

	// narysowanie sceny
	DisplayScene();
}
void Menu(int value)
{
	switch (value)
	{
		// rodzaj mg³y
	case GL_LINEAR:
	case GL_EXP:
	case GL_EXP2:
		fog_mode = value;
		DisplayScene();
		break;

		// GL_FOG_HINT
	case GL_FASTEST:
	case GL_DONT_CARE:
	case GL_NICEST:
		fog_hint = value;
		DisplayScene();
		break;

		// obszar renderingu - ca³e okno
	case FULL_WINDOW:
		aspect = FULL_WINDOW;
		Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
		break;

		// obszar renderingu - aspekt 1:1
	case ASPECT_1_1:
		aspect = ASPECT_1_1;
		Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
		break;

		// wyjœcie
	case EXIT:
		exit(0);
	}
}
Exemple #7
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   LPSTR lpCmdLine, int nShowCmd)
{
	MSG msg;							// message
	bool done;							// flag for when app is done

	// create our window and set up OpenGL
  SetupWindow("CS447-Textures", 800, 600, 32, FALSE);

	done = false;                    // init for loop

	// main message loop.     note to use PeekMessage not GetMessage
	while (!done)
	{
		// use Peek because GetMessage halts app
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	    // check for a message
    {
		  if (msg.message == WM_QUIT)
		  {
			  done = true;             // if receive quit then quit
		  }
		  else
		  {
		    TranslateMessage(&msg);				// translate to event queue
		    DispatchMessage(&msg);				// dispatch to event queue
      }
		}
    else
    {
      DisplayScene();                       // render current scene
      SwapBuffers(g_HDC);					// bring back buffer to front
    }
	}
	KillWindow();                               // cleanup

	return msg.wParam;

} 
void Menu(int value)
{
	GLint tmp_texture;
	switch (value)
	{
		// kompresja tekstur - GL_FASTEST
	case TEXTURE_COMPRESSION_FASTEST:
	{
										texture_compression_hint = GL_FASTEST;
										tmp_texture = texture;
										GenerateTextures();
										texture = tmp_texture;
										DisplayScene();
	}
		break;

		// kompresja tekstur - GL_DONT_CARE
	case TEXTURE_COMPRESSION_DONT_CARE:
	{
										  texture_compression_hint = GL_DONT_CARE;
										  tmp_texture = texture;
										  GenerateTextures();
										  texture = tmp_texture;
										  DisplayScene();
	}
		break;

		// kompresja tekstur - GL_NICEST
	case TEXTURE_COMPRESSION_NICEST:
	{
									   texture_compression_hint = GL_NICEST;
									   tmp_texture = texture;
									   GenerateTextures();
									   texture = tmp_texture;
									   DisplayScene();
	}
		break;

		// tekstura white_skin_guy_black_hairs
	case TEXTURE_LENA:
	{
						 texture = LENA;
						 DisplayScene();
	}
		break;

		// teksura white_skin_guy_black_hairs nieskompresowana
	case TEXTURE_LENA_UNC:
	{
							 texture = LENA_UNC;
							 DisplayScene();
	}
		break;

		// tekstura white_skin_guy_black_hairs_gray
	case TEXTURE_LENA_GRAY:
	{
							  texture = LENA_GRAY;
							  DisplayScene();
	}
		break;

		// tekstura white_skin_guy_black_hairs_gray nieskompresowana
	case TEXTURE_LENA_GRAY_UNC:
	{
								  texture = LENA_GRAY_UNC;
								  DisplayScene();
	}
		break;

		// obszar renderingu - całe okno
	case FULL_WINDOW:
	{
						aspect = FULL_WINDOW;
						Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
	}
		break;

		// obszar renderingu - aspekt 1:1
	case ASPECT_1_1:
	{
					   aspect = ASPECT_1_1;
					   Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
	}
		break;

		// wyjście
	case EXIT:
		exit(0);
	}
}