BOOL Initialize(GL_Window* window, Keys* keys)						// 初始化场景
{
	//设置全局变量
	OGL_window	= window;
	OGL_keys	= keys;

	// 在此处初始化绘制场景
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);							// 清屏为黑色
	glClearDepth(1.0f);												// 设置深度缓存
	glDepthFunc(GL_LEQUAL);											// 选择深度测试方式
	glEnable(GL_DEPTH_TEST);										// 开启深度测试
	glShadeModel(GL_SMOOTH);										// 阴暗处理采用平滑方式
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);				// 最精细的透视计算


	//tower3DS.Load("tower.3ds");										// 载入3ds文件
	//gundam3DS.Load("gundam.3ds");									// 载入3ds文件
	//background3DS.Load("model/GardonBackground.3DS");
	noteEighth3DS.Load("model/musicalNoteEighth.3DS");
	/*noteEighth3DS.Load("model/musicalNoteEighth.3DS");
	noteEighth23DS.Load("model/musicalNoteEighth_Two.3DS");
	noteFourth3DS.Load("model/musicalNoteFourth.3DS");*/
	note_Whole3DS.Load("model/WholeNote.3DS");
	note_Half3DS.Load("model/HalfNote.3DS");
	noteFourth3DS.Load("model/FourthNote.3DS");
	note_Eighth3DS.Load("model/EighthNote.3DS");
	note_Sixteenth3DS.Load("model/SixteenthNote.3DS");
	note_ThirtySecond3DS.Load("model/ThirtySecondNote.3DS");

	
	noteEighth23DS.Load("model/EighthNoteDouble.3DS");

	BuildFont();		//建立字体

	//BuildTexture("ground.jpg",groundTex);

	// 设置光照和材质
	glMaterialfv(GL_FRONT, GL_SPECULAR, spec);
	glMaterialfv(GL_FRONT, GL_SHININESS, &df);

	glEnable(GL_LIGHTING);
	glLightfv(GL_LIGHT0, GL_POSITION, posl);
	glLightfv(GL_LIGHT0, GL_AMBIENT, amb);
	glEnable(GL_LIGHT0);

	GLfloat LightAmbient[]= { 0.6f, 0.6f, 0.6f, 1.0f }; 
	GLfloat LightDiffuse[]= { 0.8f, 0.8f, 0.8f, 0.8f };
	GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f };
	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
	glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
	glEnable(GL_LIGHT1);
 
	glEnable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

	skybox.Load("model/galaxy.3DS");

	return TRUE;													// 初始化成功返回TRUE
}
Пример #2
0
BOOL GameClass::InitGame(void)
{
	glEnable(GL_TEXTURE_2D);

	int tempID=LoadTexture("images\\font.png");
	if(tempID==-1)
		MessageBox(0,L"Error loading font.",L"Error",MB_OK);

	FontText=tempID;
	BuildFont();


//	if(!LoadStandardFont(FONT_NAME,FONT_HEIGHT))
//		MessageBox(0,"Error loading font.","Error",MB_OK);

//	if(!LoadStandard3DFont("Gyparody",0.4f))
//		MessageBox(0,"Error loading font.","Error",MB_OK);

	for(int a=0;a<NUMTEXTURES;a++)
	{
		PrintAndSwap("Loading %s", textureNames[a]);

		int tempID=LoadTexture((char *)textureNames[a]);
		Textures[a]=-1;
		if(tempID==-1)	MessageBoxW(0,(LPCWSTR)textureNames[a],L"Error loading image",MB_OK);
		else			Textures[a]=tempID;
		SetTexture1(Textures[a]);
	}

	return 1;
}
Пример #3
0
/* 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;
}
Пример #4
0
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CONSTR/DESTR
CVisText::CVisText()
{
	// Default Color/Draw Values
	Color[0]=Color[1]=Color[2]=1;
#if INDEX_MODE
	ColorIndex=VisWindow->ColorRGB2I(Color);
#endif
	Alpha=1;

	// Clipped
	Clipped = VISWIN_IS_CLIPPED(X,Y);

	// Transform
	ScaleX=ScaleY= 1;
	Angle = 0;


	// FONT & STRING SETUP
	
	Fill=TRUE;
	fontUnderline=FALSE;
	fontItalic=FALSE;
	fontWeight=500;
	strcpy(fontName,VISTEXT_DEFAULT_FONT);
	listBase=-1;
	BuildFont();

	textString[0]=NULL;
	calcTextBox();
}
Пример #5
0
void CGraphCanvas::InitGL()
{
	SetCurrent();
	GLenum err = glewInit();
	if (GLEW_OK != err)
		wxLogError( "%s\n", glewGetErrorString(err) );

	if ( GLEW_ARB_vertex_buffer_object )
		wxLogMessage( "VBO extersion is supported!\n");
	if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GL_EXT_geometry_shader4)
		wxLogMessage("Ready for GLSL - vertex, fragment, and geometry units.\n");
	else {
		wxLogError("Not totally ready :( \n");
	}

	glClearColor( WHITE[0], WHITE[1], WHITE[2], WHITE[3] );
	glClearDepth(1.0);

    glEnable(GL_LINE_SMOOTH);
    glEnable(GL_BLEND);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);
 	glEnable(GL_NORMALIZE);


	HWND hWnd = (HWND) GetHandle();
	m_hDC = GetDC(hWnd);

	BuildFont();
}
Пример #6
0
bool cTextureFont::Load( const Uint32& TexId, const eeUint& StartChar, const eeUint& Spacing, const eeUint& TexColumns, const eeUint& TexRows, const Uint16& NumChars ) {
	cTexture * Tex = cTextureFactory::instance()->GetTexture( TexId );

	mTexId = TexId;

	if ( NULL != Tex ) {
		mTexColumns		= TexColumns;
		mTexRows		= TexRows;
		mStartChar		= StartChar;
		mNumChars		= NumChars;

		mtX				= ( 1 / static_cast<eeFloat>( mTexColumns ) );
		mtY				= ( 1 / static_cast<eeFloat>( mTexRows ) );

		mFWidth			= (eeFloat)( Tex->Width() / mTexColumns );
		mFHeight		= (eeFloat)( Tex->Height() / mTexRows );
		mHeight			= mSize = mLineSkip = (eeUint)mFHeight;

		if ( Spacing == 0 )
			mSpacing = static_cast<eeUint>( mFWidth );
		else
			mSpacing = Spacing;

		BuildFont();

		eePRINTL( "Texture Font %s loaded.", Tex->Filepath().c_str() );

		return true;
	}

	eePRINTL( "Failed to Load Texture Font: Unknown Texture." );

	return false;
}
Пример #7
0
MOboolean
moFont::Init( moFontType p_Type, moText p_fontname, MOint p_size, MOuint glid ) {

  glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );

	switch( (int)p_Type ) {
		case MO_FONT_OUTLINE://3d
			m_pFace = (FTFont*)new FTGLOutlineFont( p_fontname );
			break;
		case MO_FONT_TRANSLUCENT://2d
            m_pFace = (FTFont*)new FTGLBitmapFont( p_fontname );
			break;
		case MO_FONT_TRANSLUCENTTEXTURE://3d
            m_pFace = (FTFont*)new FTGLTextureFont( p_fontname );
			break;
		case MO_FONT_GRAYSCALE://2d
            m_pFace = (FTFont*)new FTGLPixmapFont( p_fontname );
			break;
		case MO_FONT_MONOCHROME://2d
            m_pFace = (FTFont*)new FTGLPixmapFont( p_fontname );
			break;
		case MO_FONT_SOLID://3d extruded (depth)
            m_pFace = (FTFont*)new FTGLExtrdFont( p_fontname );
			break;
		case MO_FONT_FILLED://3d
            m_pFace = (FTFont*)new FTGLPolygonFont( p_fontname );
			break;
    case MO_FONT_GLBUILD:
            m_FontGLId = glid;
            BuildFont();
			break;
    case MO_FONT_UNDEFINED:
            MODebug2->Error(moText(" FontManager:: UNDEFINED font type"));
            m_pFace = NULL;
            break;

	}


  FTFont* FF = (FTFont*) m_pFace;
  FT_Error FontError;
  if (FF)
    FontError = FF->Error();

	if ( ( p_Type!=MO_FONT_GLBUILD && ( FF == NULL || FontError!=0 ) ) ||
         ( p_Type==MO_FONT_UNDEFINED )  || (p_Type==MO_FONT_GLBUILD && (int)m_FontGLId==-1)) {
        MODebug2->Error(moText("FontManager: Could not construct face from ")+(moText)p_fontname);
        return false;
	} else {
		m_Name = p_fontname;
    if (FF) {
      SetSize(p_size);
      FF->Depth(20);
      //FF->CharMap(ft_encoding_unicode);
    }
		return true;
	}

	return false;
}
Пример #8
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	FILE *allBMP;
	allBMP = fopen("allBMP.txt", "rt"); 
	int numBMP = 0;	
	char oneline[255];
	readstr(allBMP,oneline);
	sscanf(oneline, "NUMOFBMP %d\n", &numBMP); //Get the number of filenames in the txt file

	//Dynamically assigning a 2D array of how ever many strings there are needed with 50 characters per string
	// Texture 1D array is also created
	char **BMPnames = (char **)malloc(numBMP*sizeof(*BMPnames));	
	texture = (GLuint *)malloc(numBMP*sizeof(GLuint));
	for (int i = 0; i < numBMP; i++)
	{
		BMPnames[i] = (char *)malloc(50*sizeof(*BMPnames[0]));		
	}
	
	// Put the image file names into the created 2D array
	for (int counter = 0; counter < numBMP; counter++)
	{
		readstr(allBMP,oneline);
		sscanf(oneline, "%s\n", BMPnames[counter]);
	}

	for (int counter = 0; counter < numBMP; counter++)
	{
		if (!NeHeLoadBitmap(BMPnames[counter], texture[counter]))					// Load The Bitmap
		return FALSE;
	}
	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);					// Set The Blending Function For Translucency
	glClearColor(1.0f, 1.0f, 1.0f, 1.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

	SetupWorld();
	BuildFont();
	//CoInitialize(0);
	//IPlatformCommand *m_platform;
	//HRESULT hResult = CoCreateInstance(CLSID_CPlatformCommand, NULL, CLSCTX_LOCAL_SERVER, IID_IPlatformCommand, (LPVOID*)&m_platform);
	::CoInitialize(NULL);
	//// Create an instance of the Word application and obtain the
	//// pointer to the application's IDispatch interface.
	//CLSID clsid;
	//HRESULT hr;
	//IUnknown* pUnk;

	//CLSIDFromProgID(L"Word.Application",&clsid);
	//hr = ::CoCreateInstance( clsid, NULL, CLSCTX_SERVER,IID_IUnknown, (void**) &pUnk);

	return TRUE;										// Initialization Went OK
}
Пример #9
0
/***********************************************************
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);
}
Пример #10
0
    void InitGL ()
    {
        glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

        glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
        glClearDepth (1.0f);

        glEnable (GL_DEPTH_TEST);
        glDepthFunc (GL_LEQUAL);

        glShadeModel (GL_SMOOTH);
        glEnable (GL_LINE_SMOOTH);

        glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

        memset (Vertices, 0, sizeof (Vertices));

        CurrentHeight     = initialize2dArr (Vector <int> (SIZE_X, SIZE_Y));
        PreviousHeight    = initialize2dArr (Vector <int> (SIZE_X, SIZE_Y));
        PrePreviousHeight = initialize2dArr (Vector <int> (SIZE_X, SIZE_Y));

        BuildFont ();

        for (int x = 0; x < SIZE_X; x ++)
        {
            for (int y = 0; y < SIZE_Y; y ++)
            {
                assert (x < SIZE_X && x >= 0);
                assert (y < SIZE_Y && y >= 0);

                Vertices [x][y].coords [0] = 1.0f - 2.0f * (float) x / SIZE_X;
                Vertices [x][y].coords [1] = 1.0f - 2.0f * (float) y / SIZE_Y;

                Vertices [x][y].normal [2] = - 4.0f / SIZE_X;
            }
        }


        Texture [0] = loadjpgGL ("X:\\Map\\Tile.jpg");
        Texture [1] = loadjpgGL ("X:\\Map\\Water6.jpg");

        glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
        glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
        glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

        glEnable (GL_TEXTURE_2D);

        glEnable (GL_NORMALIZE);

        glEnable (GL_LIGHTING);
        glEnable (GL_LIGHT0);
    }
Пример #11
0
int grf_start(char *p_file)
{
  nahraj_texture_config(p_file, &txconf);

  /* Nahozeni stavu OpenGL
   */
  nastav_konfig(&hwconf, &txconf);
  anisotropic_filtr_init(&txconf);

  BuildFont();
  return (TRUE);
}
Пример #12
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	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

	BuildFont();										// Build The Font

	return TRUE;										// Initialization Went OK
}
Пример #13
0
STDMETHODIMP CVisText::put_fontName(BSTR newVal)
{
	// fontName is ASCII, but COM sends BSTR (i.e. WCS or unicode string)
	wcstombs( fontName, newVal, wcslen(newVal)+1 );
	KillFont();	BuildFont();
	calcTextBox();

	// Ask VisWindow to Update
	if(VisWindow && Show){ 
		VisWindow->requestUpdate();
		if(VisWindow->logmode) VisWindow->logAction(tag,ACTION_FONT,(double *)NULL,0);
	}
	return S_OK;
}
Пример #14
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
	}
	BuildFont();										// Build The Font
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);				// Clear The Background Color To Black
	glClearDepth(1.0);									// Enables Clearing Of The Depth Buffer
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Test To Do
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);					// Select The Type Of Blending
	glShadeModel(GL_SMOOTH);							// Enables Smooth Color Shading
	glEnable(GL_TEXTURE_2D);							// Enable 2D Texture Mapping
	return TRUE;										// Initialization Went OK
}
Пример #15
0
STDMETHODIMP CVisText::put_fill(double newVal)
{
	int redo=0;
	if( fabs(newVal)<.01 && Fill ){ Fill=FALSE; redo=1; }
	else if( fabs(newVal)>.01 && !Fill ){ Fill=TRUE; redo=1;}
	if(redo){
		KillFont();	BuildFont();
	}

	if(VisWindow && Show){ 
		VisWindow->requestUpdate();
		if(VisWindow->logmode) VisWindow->logAction(tag,ACTION_FILL,&newVal,1);
	}
	return S_OK;
}
Пример #16
0
void InitGL ( GLvoid )     // Create Some Everyday Functions
{

	glewInit();
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.5f, 0.5f, 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
	glEnable ( GL_COLOR_MATERIAL );
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA   );

	TestLightInit();
	//InitGLSL();
	/*glMatrixMode (GL_PROJECTION);										// Select The Projection Matrix
	glLoadIdentity ();													// Reset The Projection Matrix
	gluPerspective (45.0, (GLfloat)(winW)/(GLfloat)(winH),			// Calculate The Aspect Ratio Of The Window
					10.0f, 100000.0f);		
	glMatrixMode (GL_MODELVIEW);	
	*/
	Test3DsTex = new Textures;
	Test3DsTex->loadfile("Data/Model/Test3dsModel");
	Test3DsTexID=Test3DsTex->LoadToVRAM(GL_LINEAR_MIPMAP_LINEAR);
	
	ASCFontTex=new Textures;
	ASCFontTex->loadfile("Data/Font");
	ASCFontTex->LoadToVRAM(GL_LINEAR_MIPMAP_LINEAR);
	BuildFont(ASCFontTex->TexID);

	QueryPerformanceCounter(&t1);
	QueryPerformanceFrequency(&feq);
	QueryPerformanceFrequency(&feqf);
	//LLfeq=feq.QuadPart;
	sprintf(showfps,"FPS:- -");
	//Fonts.LoadFont("SimSun");

	char szPath[MAX_PATH];
	GetWindowsDirectory(szPath,sizeof(szPath));
	char FontPath[MAX_PATH];

	sprintf(FontPath,"%s/Fonts/simsun.ttc",szPath);
	//FontsTest.LoadFont(FontPath,16,16,128,128);
	//FontsTest.inputTxt("qwerttyyuioop[]");
	init3DTexTest();
	for(int i=0;i<10;i++)
		testkey[i]=false;
}
Пример #17
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
    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
    glEnable(GL_LIGHT0);								// Enable Default Light (Quick And Dirty)
    glEnable(GL_LIGHTING);								// Enable Lighting
    glEnable(GL_COLOR_MATERIAL);						// Enable Coloring Of Material

    BuildFont();										// Build The Font

    return TRUE;										// Initialization Went OK
}
Пример #18
0
int InitGL(GLvoid)											// All Setup For OpenGL Goes Here
{
	if (!LoadTGA(&textures[0],"Data/Font.TGA"))				// Load The Font Texture
	{
		return false;										// If Loading Failed, Return False
	}

	BuildFont();											// Build The Font

	glShadeModel(GL_SMOOTH);								// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);					// Black Background
	glClearDepth(1.0f);										// Depth Buffer Setup
	glBindTexture(GL_TEXTURE_2D, textures[0].texID);		// Select Our Font Texture

	return TRUE;											// Initialization Went OK
}
Пример #19
0
STDMETHODIMP CVisText::put_fontWeight(double newVal)
{
	if((int)newVal!=fontWeight){
		fontWeight=(int)(floor(newVal/100)*100.);  // Weight is in set 100:100:900
		if( fontWeight<100 && fontWeight!=0)	fontWeight=100;
		if( fontWeight>900)						fontWeight=900;
	
		KillFont();	BuildFont();
		calcTextBox();
		if(VisWindow && Show){ 
			VisWindow->requestUpdate();
			if(VisWindow->logmode) VisWindow->logAction(tag,ACTION_WEIGHT,&newVal,1);
		}
	}
	return S_OK;
}
Пример #20
0
STDMETHODIMP CVisText::put_fontItalic(double newVal)
{
	int redo=0;
	if( fabs(newVal)<.01 && fontItalic ){ fontItalic=FALSE; redo=1; }
	else if( fabs(newVal)>.01 && !fontItalic ){ fontItalic=TRUE; redo=1; }
	if(redo){
		KillFont();	BuildFont();
		calcTextBox();
	}

	if(VisWindow && Show){ 
		VisWindow->requestUpdate();
		if(VisWindow->logmode) VisWindow->logAction(tag,ACTION_ITALIC,&newVal,1);
	}
	return S_OK;
}
Пример #21
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
	}

	BuildFont();											// Build The Font

	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_LINE_SMOOTH_HINT, GL_NICEST);					// Set Line Antialiasing
	glEnable(GL_BLEND);										// Enable Blending
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);		// Type Of Blending To Use
	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
	}
	BuildFont();										// Build The Font

	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
	glEnable(GL_LIGHT0);								// Quick And Dirty Lighting (Assumes Light0 Is Set Up)
	glEnable(GL_LIGHTING);								// Enable Lighting
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	glBindTexture(GL_TEXTURE_2D, texture[0]);			// Select The Texture
	return TRUE;										// Initialization Went OK
}
Пример #23
0
// Will Be Called Right After The GL Window Is Created
GLvoid InitGL(GLsizei Width, GLsizei Height)
{
    // Clear The Background Color To Black
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    // Enables Clearing Of The Depth Buffer
    glClearDepth(1.0);

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

    // Enables Depth Testing
    glEnable(GL_DEPTH_TEST);

    // Enables Smooth Color Shading
    glShadeModel(GL_SMOOTH);

    // Select The Projection Matrix
    glMatrixMode(GL_PROJECTION);

    // Reset The Projection Matrix
    glLoadIdentity();

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

    // Select The Modelview Matrix
    glMatrixMode(GL_MODELVIEW);

    // Build The Font
    BuildFont();

    // Enable Default Light (Quick And Dirty)
    glEnable(GL_LIGHT0);

    // Enable Lighting
    glEnable(GL_LIGHTING);

    // Enable Coloring Of Material
    glEnable(GL_COLOR_MATERIAL);
}
Пример #24
0
int InitGL(GLvoid)										// 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
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);					// Set The Blending Function For Translucency Based On Source Alpha Value
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);				// Black background
	glClearDepth(1.0f);									// Depth buffer setup
	glDepthFunc(GL_LESS);								// The Type Of Depth Test To Do
	glEnable(GL_DEPTH_TEST);							// Enables depth testing
	glShadeModel(GL_SMOOTH);							// Enable smooth shading

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really nice perspective calcutations

	SetupWorld();
	BuildFont();										// Build font

	return TRUE;										// Initialization went OK
}
Пример #25
0
//----- initializeGL -----------------------------------------
void QGLWidgetTest::initializeGL() {

	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.6f, 0.6f, 0.6f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glDisable(GL_DEPTH_TEST);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);					// Set Line Antialiasing
	glDisable(GL_LIGHTING);
	glDisable(GL_CULL_FACE);

	// bind the texture
	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, gTexture->Width(), gTexture->Height(),
				 0, GL_BGRA, GL_UNSIGNED_BYTE, gTexture->Pixels());
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	setDefaultGlobalStates();
	startTimer(timer_interval);
	BuildFont();
}
Пример #26
0
BOOL Initialize (GL_Window* window, Keys* keys)					// Any OpenGL Initialization Goes Here
{
	g_window	= window;
	g_keys		= keys;

	srand( (unsigned)time( NULL ) );							// Randomize Things

	if ((!LoadTGA(&textures[0],"Data/BlueFace.tga")) ||			// Load The BlueFace Texture
		(!LoadTGA(&textures[1],"Data/Bucket.tga")) ||			// Load The Bucket Texture
		(!LoadTGA(&textures[2],"Data/Target.tga")) ||			// Load The Target Texture
		(!LoadTGA(&textures[3],"Data/Coke.tga")) ||				// Load The Coke Texture
		(!LoadTGA(&textures[4],"Data/Vase.tga")) ||				// Load The Vase Texture
		(!LoadTGA(&textures[5],"Data/Explode.tga")) ||			// Load The Explosion Texture
		(!LoadTGA(&textures[6],"Data/Ground.tga")) ||			// Load The Ground Texture
		(!LoadTGA(&textures[7],"Data/Sky.tga")) ||				// Load The Sky Texture
		(!LoadTGA(&textures[8],"Data/Crosshair.tga")) ||		// Load The Crosshair Texture
		(!LoadTGA(&textures[9],"Data/Font.tga")))				// Load The Crosshair Texture
	{
		return FALSE;											// If Loading Failed, Return False
	}

	BuildFont();												// Build Our Font Display List

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);						// Black Background
	glClearDepth(1.0f);											// Depth Buffer Setup
	glDepthFunc(GL_LEQUAL);										// Type Of Depth Testing
	glEnable(GL_DEPTH_TEST);									// Enable Depth Testing
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);			// Enable Alpha Blending (disable alpha testing)
	glEnable(GL_BLEND);											// Enable Blending       (disable alpha testing)
//	glAlphaFunc(GL_GREATER,0.1f);								// Set Alpha Testing     (disable blending)
//	glEnable(GL_ALPHA_TEST);									// Enable Alpha Testing  (disable blending)
	glEnable(GL_TEXTURE_2D);									// Enable Texture Mapping
	glEnable(GL_CULL_FACE);										// Remove Back Face

	for (int loop=0; loop<30; loop++)							// Loop Through 30 Objects
		InitObject(loop);										// Initialize Each Object
	
	return TRUE;												// Return TRUE (Initialization Successful)
}
Пример #27
0
bool SceneTutorial24::Init()
{
    imageFont = MyImage::LoadImage("Textures/Font.tga");
    if( imageFont == NULL ) {
        return false;
    }
    
    BuildFont();

    glShadeModel(GL_SMOOTH);                                // Enable Smooth Shading
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);                   // Black Background
    glClearDepth(1.0f);                                     // Depth Buffer Setup
    glBindTexture(GL_TEXTURE_2D, imageFont->GetTexture());        // Select Our Font Texture

    _cameraPosition.Set(0, 0, 10);
    _cameraScale.Set(1.0f, 1.0f, 1.0f);

    swidth = 640;
    sheight = 480;
    scroll = 0;

    return true;
}
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	//加载纹理
	char path[] = "Data/y0.bmp";
	for(int i = 0; i < CTexture; i++)
	{
		path[6] = i + 48;								// 设定纹理路径
		if (!LoadGLTextures(path, i))					// Jump To Texture Loading Routine ( NEW )
		{
			return FALSE;								// If Texture Didn't Load Return FALSE
		}
	}
	 
	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping ( NEW )|启用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|精细的透视修正
	BuildFont();										// Build The Font
	return TRUE;										// Initialization Went OK
}
Пример #29
0
//---------------------------------------------------------------------------------------
int z_ed3View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
    _hdc = ::GetDC(m_hWnd);   
    if(!DOC()->InitGL(3,_hdc, m_hRC))
    {
        PostQuitMessage(0);
        return -1;
    }
	
    glPolygonMode(GL_BACK,GL_FILL);
	glFrontFace(GL_CW);
	glEnable(GL_CULL_FACE);
	glCullFace(GL_FRONT);

    BuildFont(_hdc);
	MakeCurrent(0, 0); 
    ++DOC()->_viewCount;
/*
    MEM_START(a,"a");
    do{
        V3      v(1.0,1.0,1.0);
        Brush   b;
        Brush   b1;
        b.MakeSheet(v,1,1);

        Brush   b2 = b;
        b1 = b;

    }while(0);
    MEM_END(a);
*/

	return 0;
}
Пример #30
0
 cWindowTextShower::cWindowTextShower(HDC& aHDC)
 {
     mHDC = aHDC;
     BuildFont();
 }