コード例 #1
0
GLvoid NEHE17::InitGL(){
	if(!LoadGLTextures("NeheGL/img/Font.bmp", 0)){
        cout<<"Fail to load font texture"<<endl;
    }
	
	if(!LoadGLTextures("NeheGL/img/Bumps.bmp", 1)){
        cout<<"Fail to load bumps texture"<<endl;
    }
	
	buildFont();
	
	// Enable Texture Mapping
	glEnable(GL_TEXTURE_2D);
	
	// Enables Smooth Shading
	glShadeModel(GL_SMOOTH);
	
	// clear background as black
	glClearColor(0.0f,0.0f,0.0f,0.0f);
	
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	
	// want the best perspective correction to be done
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);	// Select The Type Of Blending
	
}
コード例 #2
0
/* A general OpenGL initialization function.  Sets all of the initial parameters. */
GLvoid InitGL(GLsizei Width, GLsizei Height)	// We call this right after our OpenGL window is created.
{
	LoadGLTextures();                           // load the textures.
	glEnable(GL_TEXTURE_2D);                    // Enable texture mapping.

	glBlendFunc(GL_SRC_ALPHA, GL_ONE);          // Set the blending function for translucency (note off at init time)
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);	// This Will Clear The Background Color To Black
	glClearDepth(1.0);				// Enables Clearing Of The Depth Buffer
	glDepthFunc(GL_LESS);                       // type of depth test to do.
	glEnable(GL_DEPTH_TEST);                    // enables depth testing.
	glShadeModel(GL_SMOOTH);			// Enables Smooth Color Shading

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();				// Reset The Projection Matrix

	gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);	// Calculate The Aspect Ratio Of The Window

	glMatrixMode(GL_MODELVIEW);

	// set up lights.
	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
	glEnable(GL_LIGHT1);
}
コード例 #3
0
ファイル: nehe-ogl16.cpp プロジェクト: stden/comp_graph
int InitGL(GLvoid) {                                    // Все настройки OpenGL начинаются здесь
    if (!LoadGLTextures()) {                            // Переход к процедуре загрузки текстуры
        return FALSE;                                   // Если текстура не загружена возращает FALSE
    }

    glEnable(GL_TEXTURE_2D);                            // Включение нанесения текстур
    glShadeModel(GL_SMOOTH);                            // Включение гладкой закраски (smooth shading)
    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);               // Очиска экрана, с заполнием его цветом тумана. ( Изменено )
    glClearDepth(1.0f);                                 // Установка буфера глубины
    glEnable(GL_DEPTH_TEST);                            // Включение проверки глубины
    glDepthFunc(GL_LEQUAL);                             // Тип выполняемой проверки глубины
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);  // Изящная коррекция перспективы

    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);     // Установить цвет среды
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);     // Установить диффузный (рассеиваемый) цвет
    glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);   // Разместить источник
    glEnable(GL_LIGHT1);                                // Включить Источник света #1

    glFogi(GL_FOG_MODE, fogMode[fogfilter]);            // Режим тумана
    glFogfv(GL_FOG_COLOR, fogColor);                    // Цвет тумана
    glFogf(GL_FOG_DENSITY, 0.35f);                      // Насколько густым будет туман
    glHint(GL_FOG_HINT, GL_DONT_CARE);                  // Вспомогательная установка тумана
    glFogf(GL_FOG_START, 1.0f);                         // Глубина, с которой начинается туман
    glFogf(GL_FOG_END, 5.0f);                           // Глубина, где туман заканчивается.
    glEnable(GL_FOG);                                   // Включает туман (GL_FOG)
    return TRUE;                                        // Инициализация прошла OK
}
コード例 #4
0
GLvoid InitGL(GLsizei Width, GLsizei Height)	// This Will Be Called Right After The GL Window Is Created
{
	LoadGLTextures();							// Load The Texture(s)
	glEnable(GL_TEXTURE_2D);					// Enable Texture Mapping

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);		// This Will Clear The Background Color To Black
	glClearDepth(1.0);							// Enables Clearing Of The Depth Buffer
	glShadeModel(GL_SMOOTH);					// Enables Smooth Color Shading

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();							// Reset The Projection Matrix

	gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);	// Calculate The Aspect Ratio Of The Window

	glMatrixMode(GL_MODELVIEW);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);			// Set The Blending Function For Translucency
	glEnable(GL_BLEND);

	for (loop=0; loop<num; loop++)
	{
		star[loop].angle=0.0f;
		star[loop].dist=(float(loop)/num)*5.0f;
		star[loop].r=rand()%256;
		star[loop].g=rand()%256;
		star[loop].b=rand()%256;
	}
}
コード例 #5
0
ファイル: lesson11.c プロジェクト: sunzhiyuan/NEHE
/* A general OpenGL initialization function.  Sets all of the initial parameters. */
void InitGL(int Width, int Height)	        // We call this right after our OpenGL window is created.
{
    float float_x, float_y;                     // loop counters.
    LoadGLTextures();				// Load The Texture(s) 
    glEnable(GL_TEXTURE_2D);			// Enable Texture Mapping
    glClearColor(0.0f, 0.0f, 1.0f, 0.0f);	// Clear The Background Color To Blue 
    glClearDepth(1.0);				// Enables Clearing Of The Depth Buffer
    glDepthFunc(GL_LESS);			// The Type Of Depth Test To Do
    glEnable(GL_DEPTH_TEST);			// Enables Depth Testing
    glShadeModel(GL_SMOOTH);			// Enables Smooth Color Shading
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();				// Reset The Projection Matrix
    
    gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);	// Calculate The Aspect Ratio Of The Window
    
    glMatrixMode(GL_MODELVIEW);

    for(float_x = 0.0f; float_x < 9.0f; float_x +=  0.2f )	{
	for(float_y = 0.0f; float_y < 9.0f; float_y += 0.2f)		{
	    points[ (int) (float_x*5) ][ (int) (float_y*5) ][0] = float_x - 4.4f;
	    points[ (int) (float_x*5) ][ (int) (float_y*5) ][1] = float_y - 4.4f;
	    points[ (int) (float_x*5) ][ (int) (float_y*5) ][2] = (float) (sin( ( (float_x*5*8)/360 ) * 3.14159 * 2 ));
	}
    }
}
コード例 #6
0
ファイル: main.cpp プロジェクト: aryaro/gpu
void InitGL(int width, int height )
{

    LoadGLTextures();
    glEnable(GL_TEXTURE_2D);


	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	glClearDepth( 1.0 );
	glDepthFunc( GL_LESS );
	glEnable( GL_DEPTH_TEST );
	glShadeModel( GL_SMOOTH );

	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	gluPerspective( 45.0f, ( (GLfloat)width / (GLfloat)height ), 0.1f, 100.0f);

	glMatrixMode( GL_MODELVIEW );

    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);  // add lighting. (ambient)
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);  // add lighting. (diffuse).
    glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // set light position.
    glEnable(GL_LIGHT1);                             // turn light 1 on.


}
コード例 #7
0
GLvoid NEHE22::InitGL(){
	
	multitextureSupported=initMultitexture();
	
	if(!LoadGLTextures()){
        cout<<"Fail to load textures"<<endl;
    }
	
	// Enable Texture Mapping
	glEnable(GL_TEXTURE_2D);
	
	// Enables Smooth Shading
	glShadeModel(GL_SMOOTH);
	
	// clear background as black
	glClearColor(0.0f,0.0f,0.0f,0.5f);
	
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	
	// want the best perspective correction to be done
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	
	initLights();
}
コード例 #8
0
ファイル: main.cpp プロジェクト: caitouda/BNUCourses
int InitGL(GLvoid)
{
    if (!LoadGLTextures())
    {
        return FALSE;
    }

    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    glClearDepth(1.0f);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    glEnable(GL_BLEND);

    for (loop=0; loop<num; loop++)
    {
        star[loop].angle=0.0f;
        star[loop].dist=(float(loop)/num)*5.0f;
        star[loop].r=rand()%256;
        star[loop].g=rand()%256;
        star[loop].b=rand()%256;
    }
    return TRUE;
}
コード例 #9
0
ファイル: lesson9.cpp プロジェクト: jacksunsea/OpenGLTest
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	if(!LoadGLTextures())
	{
		return FALSE;
	}
	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	//glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	//glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);				//设置混色函数设置半透明效果
	glEnable(GL_BLEND);							//启用混色
	for(loop = 0; loop < num; loop ++)
	{
		star[loop].angle = 0.0f;
		star[loop].dist = (float(loop)/num) * 5.0f;
		star[loop].r = rand()%256;
		star[loop].g = rand()%256;
		star[loop].b = rand()%256;
	}
	
	return TRUE;										// Initialization Went OK
}
コード例 #10
0
ファイル: nehe_lesson11.cpp プロジェクト: xerpi/NeHe-SFML2.0
int InitGL()										    // All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())								// Jump To Texture Loading Routine ( NEW )
	{
		return false;									// If Texture Didn't Load Return false
	}

	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping ( NEW )
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
	glPolygonMode( GL_BACK, GL_FILL );					// Back Face Is Solid
	glPolygonMode( GL_FRONT, GL_LINE );					// Front Face Is Made Of Lines

	for(int x=0; x<45; x++)
	{
		for(int y=0; y<45; y++)
		{
			points[x][y][0]=float((x/5.0f)-4.5f);
			points[x][y][1]=float((y/5.0f)-4.5f);
			points[x][y][2]=float(sin((((x/5.0f)*40.0f)/360.0f)*3.141592654*2.0f));
		}
	}

	return true;										// Initialization Went OK
}
コード例 #11
0
ファイル: main.cpp プロジェクト: nusus/VS2012Workspace
int InitGL(GLvoid)										// 此处开始对OpenGL进行所有设置
{
	glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);

	if (!LoadGLTextures())
	{
		return FALSE;
	}
	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);							// 启用阴影平滑
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// 黑色背景
	glClearDepth(1.0f);									// 设置深度缓存
	glEnable(GL_DEPTH_TEST);							// 启用深度测试
	glDepthFunc(GL_LEQUAL);								// 所作深度测试的类型
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// 告诉系统对透视进行修正

	glLightfv(GL_LIGHT1, GL_AMBIENT, g_lightAmbient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, g_lightDiffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, g_lightPosition);
	glEnable(GL_LIGHT1);

	
	return TRUE;										// 初始化 OK
}
コード例 #12
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
    if (!LoadGLTextures())								// Jump To Texture Loading Routine
    {
        return FALSE;									// If Texture Didn't Load Return FALSE
    }

    glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
    glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
    glClearDepth(1.0f);									// Depth Buffer Setup
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);					// Set The Blending Function For Translucency
    glEnable(GL_BLEND);

    for (loop=0; loop<num; loop++)
    {
        star[loop].angle=0.0f;
        star[loop].dist=(float(loop)/num)*5.0f;
        star[loop].r=rand()%256;
        star[loop].g=rand()%256;
        star[loop].b=rand()%256;
    }
    return TRUE;										// Initialization Went OK
}
コード例 #13
0
ファイル: Lesson23.cpp プロジェクト: asion0/AsionGitCodes
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())								// Jump To Texture Loading Routine
	{
		return FALSE;									// If Texture Didn't Load Return FALSE
	}

	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);		// Setup The Ambient Light
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);		// Setup The Diffuse Light
	glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);	// Position The Light
	glEnable(GL_LIGHT1);								// Enable Light One

	quadratic=gluNewQuadric();							// Create A Pointer To The Quadric Object (Return 0 If No Memory)
	gluQuadricNormals(quadratic, GLU_SMOOTH);			// Create Smooth Normals 
	gluQuadricTexture(quadratic, GL_TRUE);				// Create Texture Coords 

	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // Set The Texture Generation Mode For S To Sphere Mapping (NEW)
	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // Set The Texture Generation Mode For T To Sphere Mapping (NEW)

	return TRUE;										// Initialization Went OK
}
コード例 #14
0
/* A general OpenGL initialization function.  Sets all of the initial parameters. */
GLvoid InitGL(GLsizei Width, GLsizei Height)  // We call this right after our OpenGL window is created.
{
    LoadGLTextures();                        // Load the textures
    
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);    // This Will Clear The Background Color To Black
    glClearDepth(1.0);                       // Enables Clearing Of The Depth Buffer
    glDepthFunc(GL_LESS);                    // The Type Of Depth Test To Do
    glEnable(GL_DEPTH_TEST);                 // Enables Depth Testing
    glShadeModel(GL_SMOOTH);                 // Enables Smooth Color Shading
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();                        // Reset The Projection Matrix
    
    gluPerspective(45.0, GLfloat(Width)/GLfloat(Height),0.1f,100.0f);    // Calculate The Aspect Ratio Of The Window  
    quadric=gluNewQuadric();                  // Create A Pointer To The Quadric Object ( NEW )
    
    // Can also use GLU_NONE, GLU_FLAT
    gluQuadricNormals(quadric, GLU_SMOOTH);   // Create Smooth Normals
    gluQuadricTexture(quadric, GL_TRUE);      // Create Texture Coords ( NEW )
    
    m_bFullscreen = false;
    m_mouseX = 0;
    m_mouseY = 0;
    m_tiltAngle = -70.0f;
    m_twistAngle = -45.0f;
    m_distance = 270.0f;
    m_bLeftMouseButtonDown = false;
    m_bRightMouseButtonDown = false;
    m_lastTick = 0;
    m_lastRenderTick = 0;
    m_bPaused = false;
}
コード例 #15
0
ファイル: Lesson26.cpp プロジェクト: ventureheart/opengl
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
    if (!LoadGLTextures())								// If Loading The Textures Failed
    {
        return false;									// Return false
    }
    glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
    glClearColor(0.2f, 0.5f, 1.0f, 1.0f);				// Background
    glClearDepth(1.0f);									// Depth Buffer Setup
    glClearStencil(0);									// Clear The Stencil Buffer To 0
    glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
    glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
    glEnable(GL_TEXTURE_2D);							// Enable 2D Texture Mapping

    glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmb);			// Set The Ambient Lighting For Light0
    glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDif);			// Set The Diffuse Lighting For Light0
    glLightfv(GL_LIGHT0, GL_POSITION, LightPos);		// Set The Position For Light0

    glEnable(GL_LIGHT0);								// Enable Light 0
    glEnable(GL_LIGHTING);								// Enable Lighting

    q = gluNewQuadric();								// Create A New Quadratic
    gluQuadricNormals(q, GL_SMOOTH);					// Generate Smooth Normals For The Quad
    gluQuadricTexture(q, GL_TRUE);						// Enable Texture Coords For The Quad

    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);	// Set Up Sphere Mapping
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);	// Set Up Sphere Mapping

    return true;										// Initialization Went OK
}
コード例 #16
0
GLvoid NEHE09::InitGL(){
	
	//give the relative directory of image under current project folder
	if(!LoadGLTextures("NeheGL/img/star.bmp")){
        cout<<"Fail to load textures"<<endl;
    }
	
	glEnable(GL_TEXTURE_2D);	// Enable Texture Mapping
    glShadeModel(GL_SMOOTH);	// Enable Smooth Shading
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);	// Black Background
    glClearDepth(1.0f);	// Depth Buffer Setup
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);	// Set The Blending Function For Translucency
    glEnable(GL_BLEND);	// Enable Blending
	
	//initial stars
	for(loop=0; loop<num; loop++){
		star[loop].angle=0.0f;
		star[loop].dist=(float(loop)/num)*5.0f;
		star[loop].r=rand()%256;
		star[loop].g=rand()%256;
		star[loop].b=rand()%256;
	}
	
}
コード例 #17
0
ファイル: row.c プロジェクト: GMusliaj/clustergl
/* general OpenGL initialization function */
int initGL( GLvoid )
{

    /* Load in the texture */
    if ( !LoadGLTextures( ) )
	return FALSE;

    /* Enable Texture Mapping ( NEW ) */
    glEnable( GL_TEXTURE_2D );

    /* Enable smooth shading */
    glShadeModel( GL_SMOOTH );

    /* Set the background black */
    glClearColor( 0.0f, 0.0f, 0.0f, 0.5f );

    /* Depth buffer setup */
    glClearDepth( 1.0f );

    /* Enables Depth Testing */
    glEnable( GL_DEPTH_TEST );

    /* The Type Of Depth Test To Do */
    glDepthFunc( GL_LEQUAL );

    /* Really Nice Perspective Calculations */
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

    return( TRUE );
}
コード例 #18
0
ファイル: lab1.cpp プロジェクト: AZAZARKA/KGProje-t
GLvoid InitGL(GLsizei Width, GLsizei Height)	// Вызвать после создания окна GL
{
	LoadGLTextures();			// Загрузка текстур
	glEnable(GL_TEXTURE_2D);		// Разрешение наложение текстуры

	glClearColor(0.5f,0.5f,0.5f,1.0f);      // Будем очищать экран, заполняя его цветом тумана.

	glClearDepth(1.0);		// Разрешить очистку буфера глубины
	glDepthFunc(GL_LESS);	// Тип теста глубины
	glEnable(GL_DEPTH_TEST);// разрешить тест глубины
	glShadeModel(GL_SMOOTH);// разрешить плавное цветовое сглаживание
	glMatrixMode(GL_PROJECTION);// Выбор матрицы проекции
	glLoadIdentity();		// Сброс матрицы проекции
	gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);
							// Вычислить соотношение геометрических размеров для окна
	glMatrixMode(GL_MODELVIEW);// Выбор матрицы просмотра модели

	GLfloat fogColor[4]= {0.5f, 0.5f, 0.5f, 1.0f}; // Цвет тумана

	glEnable(GL_FOG);                       // Включает туман (GL_FOG)
	glFogi(GL_FOG_MODE, GL_LINEAR);// Выбираем тип тумана
	glFogfv(GL_FOG_COLOR, fogColor);        // Устанавливаем цвет тумана
	glFogf(GL_FOG_DENSITY, 1.0f);          // Насколько густым будет туман
	glHint(GL_FOG_HINT, GL_DONT_CARE);      // Вспомогательная установка тумана
	glFogf(GL_FOG_START, 0.5f);             // Глубина, с которой начинается туман
	glFogf(GL_FOG_END, 2.0f);               // Глубина, где туман заканчивается.
}
コード例 #19
0
ファイル: questionare.c プロジェクト: alesko/libhello
/* general OpenGL initialization function */
int initGLFont( GLvoid )
{

  /* Load in the textures */
  if ( !LoadGLTextures( ) )
    return (int)false;

    /* Build our font list */
    BuildFont( );

    /* Enable smooth shading */
    glShadeModel( GL_SMOOTH );

    /* Set the background black */
    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );

    /* Depth buffer setup */
    glClearDepth( 1.0f );

    /* The Type Of Depth Test To Do */
    glDepthFunc( GL_LEQUAL );

    /* Select The Type Of Blending */
    glBlendFunc( GL_SRC_ALPHA, GL_ONE );

    /* Enable 2D Texture Mapping */
    glEnable( GL_TEXTURE_2D );
    
    return (int)true;
}
コード例 #20
0
int InitGL(GLvoid)								// 此处开始对OpenGL进行所有设置
{
	if (!LoadGLTextures())							// 调用纹理载入子例程
	{
		return FALSE;							// 如果未能载入,返回FALSE
	}

	glEnable(GL_TEXTURE_2D);						// 启用纹理映射
	glShadeModel(GL_SMOOTH);						// 启用阴影平滑
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);					// 黑色背景
	glClearDepth(1.0f);							// 设置深度缓存
	glEnable(GL_DEPTH_TEST);						// 启用深度测试
	glDepthFunc(GL_LEQUAL);							// 所作深度测试的类型
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			// 真正精细的透视修正

	glPolygonMode( GL_BACK, GL_FILL );			// 后表面完全填充
	glPolygonMode( GL_FRONT, GL_LINE );			// 前表面使用线条绘制

	// 沿X平面循环
	for(int x=0; x<45; x++)
	{
		// 沿Y平面循环
		for(int y=0; y<45; y++)
		{
			// 向表面添加波浪效果
			points[x][y][0]=float((x/5.0f)-4.5f);
			points[x][y][1]=float((y/5.0f)-4.5f);
			points[x][y][2]=float(sin((((x/5.0f)*40.0f)/360.0f)*3.141592654*2.0f));
		}
	}
	return TRUE;								// 初始化 OK
}
コード例 #21
0
int InitGL()					 // All Setup For OpenGL goes here
{
	if (!LoadGLTextures(scene))
	{
		return FALSE;
	}


	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);		 // Enables Smooth Shading
	glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
	glClearDepth(1.0f);				// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);		// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);			// The Type Of Depth Test To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculation


	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);    // Uses default lighting parameters
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
	glEnable(GL_NORMALIZE);

	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
	glEnable(GL_LIGHT1);

	//glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);


	return TRUE;					// Initialization Went OK
}
コード例 #22
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())								// Jump To Texture Loading Routine
	{
		return FALSE;									// If Texture Didn't Load Return FALSE
	}

	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.5f,0.5f,0.5f,1.0f);					// We'll Clear To The Color Of The Fog
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);		// Setup The Ambient Light
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);		// Setup The Diffuse Light
	glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);	// Position The Light
	glEnable(GL_LIGHT1);								// Enable Light One

	glFogi(GL_FOG_MODE, fogMode[fogfilter]);			// Fog Mode
	glFogfv(GL_FOG_COLOR, fogColor);					// Set Fog Color
	glFogf(GL_FOG_DENSITY, 0.35f);						// How Dense Will The Fog Be
	glHint(GL_FOG_HINT, GL_DONT_CARE);					// Fog Hint Value
	glFogf(GL_FOG_START, 1.0f);							// Fog Start Depth
	glFogf(GL_FOG_END, 5.0f);							// Fog End Depth
	glEnable(GL_FOG);									// Enables GL_FOG
	return TRUE;										// Initialization Went OK
}
コード例 #23
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{

	if (!LoadGLTextures())                          // Jump To Texture Loading Routine
    {
        return FALSE;                           // If Texture Didn't Load Return FALSE
    }
	glEnable(GL_TEXTURE_2D);                        // Enable Texture Mapping
    glShadeModel(GL_SMOOTH);                        // Enable Smooth Shading
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);                   // Black Background
    glClearDepth(1.0f);                         // Depth Buffer Setup
    glEnable(GL_DEPTH_TEST);                        // Enables Depth Testing
    glDepthFunc(GL_LEQUAL);                         // The Type Of Depth Testing To Do
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);          // Really Nice Perspective Calculations

	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);             // Setup The Ambient Light
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);             // Setup The Diffuse Light
	glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);            // Position The Light
	glEnable(GL_LIGHT1);                            // Enable Light One
	glLightfv(GL_LIGHT2, GL_AMBIENT, LightAmbient2);             // Setup The Ambient Light
	glLightfv(GL_LIGHT2, GL_DIFFUSE, LightDiffuse2);             // Setup The Diffuse Light
	glLightfv(GL_LIGHT2, GL_POSITION,LightPosition2);            // Position The Light
	glEnable(GL_LIGHT2);                            // Enable Light One

	return TRUE;										// Initialization Went OK
}
コード例 #24
0
ファイル: opengl_system.cpp プロジェクト: bonczek/VertexBerek
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())								// Jump To Texture Loading Routine
		return FALSE;									// If Texture Didn't Load Return FALSE

	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);				// This Will Clear The Background Color To Black
	glClearDepth(1.0);									// Enables Clearing Of The Depth Buffer
	glDepthFunc(GL_LESS);								// The Type Of Depth Test To Do
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glShadeModel(GL_SMOOTH);							// Enables Smooth Color Shading
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	glEnable( GL_ALPHA_TEST );							// dodany test alpha !
	glEnable (GL_BLEND );
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	GLfloat LightAmbientGlobal[] = { 0.9f, 0.9f, 0.9f, 1.0f };
	GLfloat LightAmbientGlobalPosition[] = { 5.0f, 5.0f, 10.0f, 1.0f };
	glLightfv( GL_LIGHT0, GL_DIFFUSE, LightAmbientGlobal );

	glEnable(GL_LIGHT1);							// Enable Light One */
	
	LoadGLMap( &map1, "data/map_zewnatrz.txt");
	current = &map1;

	return TRUE;										// Initialization Went OK
}
コード例 #25
0
ファイル: ob_particle.cpp プロジェクト: RD3BAX/BrainBay
int create_AnimationWindow(void)
{
	HDC hDC;
	PIXELFORMATDESCRIPTOR pfd;
	int nPixelFormat;	
	BOOL	fullscreen=FALSE;			// Fullscreen Flag Set To Fullscreen Mode By Default
	RECT rc;


    if (!(ghWndAnimation= CreateWindow( "AnimationClass", "Animation", 
		WS_CLIPSIBLINGS| WS_CHILD | WS_CAPTION | WS_THICKFRAME |WS_VISIBLE, GLOBAL.anim_left, GLOBAL.anim_top,GLOBAL.anim_right-GLOBAL.anim_left,GLOBAL.anim_bottom-GLOBAL.anim_top, ghWndMain, NULL, hInst, NULL)))
	{ 
		//SDL_Quit();
		report_error("Could not create Animation Window");
	    return FALSE;
	}
	ShowWindow(ghWndAnimation,1);
	UpdateWindow(ghWndAnimation);	
	//InvalidateRect(ghWndAnimation,NULL,TRUE);
	
	memset(&pfd, 0, sizeof(pfd));    
	pfd.nSize      = sizeof(pfd);
	pfd.nVersion   = 1;
	pfd.dwFlags    = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 24;
	pfd.cDepthBits = 16;
	pfd.iLayerType = PFD_MAIN_PLANE;
	
	// Set pixel format
	
	hDC = GetDC(ghWndAnimation);
	nPixelFormat = ChoosePixelFormat(hDC, &pfd);
	SetPixelFormat(hDC, nPixelFormat, &pfd);
	
	GLRC_Animation = wglCreateContext(hDC);
	wglMakeCurrent(hDC, GLRC_Animation);
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f,0.0f,0.0f,0.0f);					// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glDisable(GL_DEPTH_TEST);							// Disable Depth Testing
	glEnable(GL_BLEND);									// Enable Blending
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);					// Type Of Blending To Perform
	glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);	// Really Nice Perspective Calculations
	glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);				// Really Nice Point Smoothing
	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	if (!LoadGLTextures())								// Jump To Texture Loading Routine
	{
		report_error("Couldn't load Particle-Bitmap");
		return FALSE;									// If Texture Didn't Load Return FALSE
	}
	glBindTexture(GL_TEXTURE_2D,texture[0]);			// Select Our Texture
	GetClientRect(ghWndAnimation, &rc);
	Size_GL(ghWndAnimation, GLRC_Animation,0);					// Set Up Our Perspective GL Screen
	ReleaseDC(ghWndAnimation, hDC);
	DRAW.particles=1;
	return (TRUE);

}
コード例 #26
0
ファイル: Model.cpp プロジェクト: heropunch/cyberdeck
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;
}
コード例 #27
0
ファイル: pic.c プロジェクト: pobingwanghai/opengl
void init(void)
{
	glClearColor(0.0, 0.0, 0.0, 0.0);            //清理颜色,为黑色,(也可认为是背景颜色)

	glCullFace(GL_BACK);                        //背面裁剪(背面不可见)
	glEnable(GL_CULL_FACE);                        //启用裁剪
	glEnable(GL_TEXTURE_2D);
	LoadGLTextures();            //载入纹理贴图
}
コード例 #28
0
ファイル: floor.cpp プロジェクト: xausee/BookBar
bool Floor::Initial()
{
	texture = new GLuint [1];
	if (texture != NULL)
	{	
		LoadGLTextures();
		return true;
	}
	else
		return false;
}
コード例 #29
0
inline void LoadGLWrapper(const char* filename, int TextureID) //Bugchecks
{

	if (!LoadGLTextures(filename,TextureID)) // Jump To Texture Loading Routine
	{
#ifdef _DEBUG
		std::cout << "\nTEXTURE FAILED: " << TextureID << "\n"; // If Texture Didn't Load Shout at the debug console
#endif
	}

}
コード例 #30
0
ファイル: TextWritter.cpp プロジェクト: leloulight/lbanet
/***********************************************************
reload font texture
***********************************************************/
void TextWritter::ReloadTexture()
{
	KillFont();
	LoadGLTextures("Data/Font.png", _textTextureIdx);
	BuildFont(_textTextureIdx);
	_initialized = true;

	ConfigurationManager::GetInstance()->GetInt("Options.General.TextR", m_textR);
	ConfigurationManager::GetInstance()->GetInt("Options.General.TextG", m_textG);
	ConfigurationManager::GetInstance()->GetInt("Options.General.TextB", m_textB);
}