当前位置: 首页>>代码示例>>C++>>正文


C++ InitGL函数代码示例

本文整理汇总了C++中InitGL函数的典型用法代码示例。如果您正苦于以下问题:C++ InitGL函数的具体用法?C++ InitGL怎么用?C++ InitGL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了InitGL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SDL_GL_SetAttribute

int Engine::Init(std::string title)
{
	// Start SDL 
	if(SDL_Init( SDL_INIT_VIDEO ) == -1)
		return -1;

	// Setup double Buffering
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	//kill sdl on exiting
	atexit(SDL_Quit);

	// setup screen (with OpenGL)
	screen = SDL_SetVideoMode(ScreenWidth, ScreenHeight, BitsPerPixel, SDL_OPENGL);

	if(screen == NULL)
		return -1;

	// set the window title
	SDL_WM_SetCaption(title.c_str(), NULL);

	//Initialise OpenGL
	InitGL();

	//Intialise Audio
	soundManager = new SoundManager();

	// seed random
	srand(time(NULL));

	return 0;
}
开发者ID:EvanCGriffin,项目名称:soccergame,代码行数:32,代码来源:Engine.cpp

示例2: SetCurrent

void Pcb3D_GLCanvas::Redraw( void )
/**********************************/
{
    SetCurrent();

	InitGL();

    glMatrixMode(GL_MODELVIEW);    /* position viewer */
    /* transformations */
    GLfloat mat[4][4];
	glTranslatef(Draw3d_dx, Draw3d_dy, 0.0F);

    build_rotmatrix( mat, g_Parm_3D_Visu.m_Quat );
    glMultMatrixf( &mat[0][0] );

    glRotatef(g_Parm_3D_Visu.m_Rot[0], 1.0, 0.0, 0.0);
	glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0);
    glRotatef(g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0);

	if( m_gllist ) glCallList( m_gllist );
	else
	{
		m_gllist = CreateDrawGL_List();
//		m_gllist = DisplayCubeforTest();
	}

	glFlush();
	SwapBuffers();
 }
开发者ID:BackupTheBerlios,项目名称:kicad-svn,代码行数:29,代码来源:3d_draw.cpp

示例3: main

int main(int argc, char* argv[]){	

	cout << PROGRAM_NAME << " - " << VERSION << endl
		<< "BYU CS 455 - Fall 2012" << endl << endl
		<< "Created by:" << endl
		<< "\tJosh Davis" << endl
		<< "\tTyler Gill" << endl
		<< "\tMorgan Strong" << endl
		<< "\tJames Williams" << endl << endl;
	
	glutInit(&argc, argv);
	/* setting up double buffering rbg and depth for this */
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(windowWidth, windowHeight);
	glutInitWindowPosition(100, 100);
	/* this name needs to match the name of the window in DrawGLScene */
	glutCreateWindow(windowName);

	InitGL();

	/* the draw function will draw once and no more */
	glutDisplayFunc(DrawGLScene);
	/* this is the idle function it gets called as much as possible */
	glutIdleFunc(IdleGLScene);
	/* This is called everytime the window is altered */
	glutReshapeFunc(ReSizeGLScene);
	/* this gets called on a keyboard event */
	//glutKeyboardFunc(GLKeyDown);

	//glutSpecialFunc(SpecialKeys);

	//glutSpecialUpFunc(SpecialKeysUp);

	// Game initialization
	ObjectMan* man = ObjectMan::GetInstance();
	InputMan* inman = InputMan::GetInstance();

	cout << "Running Game..." << endl << endl;

	/* Gets the loop rolling */
	try{
		/* 
		 * This loop wont return ever so we are going to play some tricks
		 * to make it look like it exits when it is actually done. That is why
		 * we use the try catch.
		 */
		// TODO: Override the x button on the window.
		glutMainLoop();
	}
	catch(const char* msg){
		printf(msg);

		HWND hwnd = FindWindow("glut", windowName);
		ShowWindow(hwnd, SW_HIDE);
		Sleep(500);
	}

	return 0;
}
开发者ID:tygill,项目名称:Racer,代码行数:59,代码来源:main.cpp

示例4: InitManagers

	void CoreMac::Init(const ax::Size& frame_size)
	{
//		std::cout << "Init axCoreMac." << std::endl;
		InitManagers();
		InitGL();
		ResizeFrame(frame_size);
		//    _size = frame_size;
	}
开发者ID:axlib,项目名称:OpenAX,代码行数:8,代码来源:axCoreMac.cpp

示例5: Entity

Player::Player(World& world, glm::vec3 position, glm::vec2 rotation, float speed)
    : Entity(world,
        AABB(position, glm::vec3(-0.4, 0, -0.4), glm::vec3(0.4, 1.8, 0.4)),
        rotation, speed),
    m_blockSelected(glm::vec3(), glm::vec3(), glm::vec3())
{
    InitGL();
}
开发者ID:lolzballs,项目名称:Blocket,代码行数:8,代码来源:player.cpp

示例6: InitGL

BOOL CIdleOpenGLWnd::OnCreate(LPCREATESTRUCT lpcs)
{
	if (!MSG_FORWARD_WM_CREATE(COpenGLWnd, lpcs))
		return FALSE;

	m_hrc = InitGL();
	return TRUE;
}
开发者ID:dlarudgus20,项目名称:IkhWinLib2,代码行数:8,代码来源:CIdleOpenGLWnd.cpp

示例7: InitEverything

bool InitEverything(SDL_GLContext& g_Context, SDL_Window*& g_Window, std::unique_ptr<Scene>& pScene) {
	if (InitSDL())
		if (InitGL(g_Context, g_Window))
			if (InitSound())
				if (InitPython())
					if (InitScene(pScene))
						return true;
	return false;
}
开发者ID:mynameisjohn,项目名称:PyRenderer,代码行数:9,代码来源:Init.cpp

示例8: InitGL

void View2::OnInitialUpdate()
{
	CView::OnInitialUpdate();

	LEFT_DOWN=false;
	RIGHT_DOWN=false;

	InitGL();
}
开发者ID:pigoblock,项目名称:TFYP,代码行数:9,代码来源:View2.cpp

示例9: main

int main(int argc, char **argv) {

	if (argc < 6) {
		printf("usage: leitura arqin.raw width height slices dslices colormap\n");
		exit(1);
	}

	glutInit(&argc, argv);
	//glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(100, 100);
	glutInitWindowSize(640, 640);
	glutCreateWindow("Teste de Vizualizacao com textura 3D");

	glutDisplayFunc(&DrawGLScene);
	glutIdleFunc(&DrawGLScene);
	glutReshapeFunc(&ReSizeGLScene);
	glutKeyboardFunc(&keyPressed);

	glutMotionFunc(MoveMouseBotaoPressionado);
	glutPassiveMotionFunc(MoveMouse);
	glutMouseFunc(GerenciaMouse);

	raw = readRAW(argc, argv);

	GLenum err = glewInit();
	if (GLEW_OK != err) {
		fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
	}
	if (glewIsSupported("GL_VERSION_2_1"))
		printf("Ready for OpenGL 2.1\n");
	else {
		printf("OpenGL 2.1 not supported\n");
		exit(1);
	}
	if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader
			&& GL_EXT_geometry_shader4)
		printf("Ready for GLSL - vertex, fragment, and geometry units\n");
	else {
		printf("Not totally ready :( \n");
		exit(1);
	}

	if(argc==7) colorMapRead(argv[6],cm);
	else {
		createColorMap(cm);
		//colorMapWrite("teste.map", cm);
		//colorMapRead("teste.map", cm);
	}

	InitGL(640, 640);

	/* Start Event Processing Engine */
	glutMainLoop();

	return 1;
}
开发者ID:agnus-fem,项目名称:VisDaVol,代码行数:57,代码来源:main.cpp

示例10: main

int main( int argc, char* argv[] )
{
    g_InitialCameraPosition = glm::vec3( 0, 0, 10 );
    g_Camera.SetPosition( g_InitialCameraPosition );
    g_Camera.SetRotation( g_InitialCameraRotation );

    InitGL(argc, argv);
    InitGLEW();

    // Load some shaders.
    GLuint vertexShader = LoadShader( GL_VERTEX_SHADER, "../data/shaders/simpleShader.vert" );
    GLuint fragmentShader = LoadShader( GL_FRAGMENT_SHADER, "../data/shaders/simpleShader.frag" );

    std::vector<GLuint> shaders;
    shaders.push_back(vertexShader);
    shaders.push_back(fragmentShader);

    // Create the shader program.
    g_ShaderProgram = CreateShaderProgram( shaders );
    assert( g_ShaderProgram != 0 );

    GLint positionAtribID = glGetAttribLocation( g_ShaderProgram, "in_position" );
    GLint colorAtribID = glGetAttribLocation( g_ShaderProgram, "in_color" );
    g_uniformMVP = glGetUniformLocation( g_ShaderProgram, "MVP" );

    // Create a VAO for the cube.
    glGenVertexArrays( 1, &g_vaoCube );
    glBindVertexArray( g_vaoCube );

    GLuint vertexBuffer, indexBuffer;
    glGenBuffers( 1, &vertexBuffer );
    glGenBuffers( 1, &indexBuffer );

    glBindBuffer( GL_ARRAY_BUFFER, vertexBuffer );
    glBufferData( GL_ARRAY_BUFFER, sizeof(g_Vertices), g_Vertices, GL_STATIC_DRAW );

    glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, indexBuffer );
    glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(g_Indices), g_Indices, GL_STATIC_DRAW );

    glVertexAttribPointer( positionAtribID, 3, GL_FLOAT, false, sizeof(VertexXYZColor),
                            reinterpret_cast<const GLvoid*>(offsetof(VertexXYZColor,m_Pos)) );
    glEnableVertexAttribArray( positionAtribID );

    glVertexAttribPointer( colorAtribID, 3, GL_FLOAT, false, sizeof(VertexXYZColor),
                            reinterpret_cast<const GLvoid*>(offsetof(VertexXYZColor,m_Color)));
    glEnableVertexAttribArray( colorAtribID );

    // Make sure we disable and unbind everything to prevent rendering issues later.
    glBindVertexArray( 0 );
    glBindBuffer( GL_ARRAY_BUFFER, 0 );
    glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
    glDisableVertexAttribArray( positionAtribID );
    glDisableVertexAttribArray( colorAtribID );

    glutMainLoop();
}
开发者ID:LingboTang,项目名称:GameDev,代码行数:56,代码来源:mainCube.cpp

示例11: InitGL

//---------------------------------------------------------------------------
int CFabAtHomeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
//---------------------------------------------------------------------------
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	InitGL();	// initialize OpenGL
	
	return 0;
}
开发者ID:idle-git,项目名称:fabathome,代码行数:11,代码来源:FabAtHomeView.cpp

示例12: main

int main(int argc, char* argv[])
{
	g_PreviousTime = std::clock();
	std::string windowname = "test";

	InitGL(argc, argv, windowname); //create window with name
	glutMainLoop(); //enter openGL's main loop

	return 0;
}
开发者ID:TheMeII,项目名称:T3DRIS,代码行数:10,代码来源:Engine.cpp

示例13: main

int main(int argc,char **argv)
{
  srandom(123456789);
  init_particles();
  InitGL(argc, argv);
  InitCL(); 
  glutDisplayFunc(mydisplayfunc);
  glutKeyboardFunc(getout);
  glutMainLoop();
}
开发者ID:awbrenn,项目名称:particle_sytem,代码行数:10,代码来源:particle_system.cpp

示例14: main

// The ubiquituous main function.
int main ( int argc, char** argv )   // Create Main Function For Bringing It All Together
{
	// get the the filename from the commandline.
	/*if (argc!=2)
	{
		printf("usage: %s trackfilname\n", argv[0]);
		system("PAUSE");
		exit(1);
	}*/

	/* load the track, this routine aborts if it fails */
	g_Track.loadSplineFrom("track");



	/*** The following are commands for setting up GL      ***/
	/*** No OpenGl call should be before this sequence!!!! ***/

	/* Initialize glut */
	glutInit(&argc,argv);
	/* Set up window modes */
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	/* Set window position (where it will appear when it opens) */
	glutInitWindowPosition(0,0);
	/* Set size of window */
	glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	/* Create the window */
	glutCreateWindow    ( "CMPSC 458: Rollercoaster" ); // Window Title (argv[0] for current directory as title)
	/**** Call to our initialization routine****/
	InitGL ();
	/* tells glut to use a particular display function to redraw */
	glutDisplayFunc(display);
	/** allow the user to quit using the right mouse button menu **/
	/* Set menu function callback */
	g_iMenuId = glutCreateMenu(menufunc);
	/* Set identifier for menu */
	glutSetMenu(g_iMenuId);
	/* Add quit option to menu */
	glutAddMenuEntry("Quit",0);
	/* Add any other menu functions you may want here.  The format is:
	* glutAddMenuEntry(MenuEntry, EntryIndex)
	* The index is used in the menufunc to determine what option was selected
	*/
	/* Attach menu to right button clicks */
	glutAttachMenu(GLUT_RIGHT_BUTTON);
	/* Set idle function.  You can change this to call code for your animation,
	* or place your animation code in doIdle */
	glutIdleFunc(doIdle);
	/* callback for keyboard input */
	glutKeyboardFunc(keyboardfunc);

	glutMainLoop        ( );          // Initialize The Main Loop

	return 0;
}
开发者ID:jbl5088,项目名称:psu,代码行数:56,代码来源:rc_main.cpp

示例15: _tWinMain

int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;
	angle = 0.0f;
	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_OPENGLWIN32PROJECT, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_OPENGLWIN32PROJECT));
	
	InitGL();
	glClear(GL_COLOR_BUFFER_BIT);
	bExit = false;
	//main game loop
	while (!bExit)
	{
		
		
		// Main message loop:
		PeekMessage(&msg, hWnd, NULL, NULL, PM_REMOVE);
		if (msg.message == WM_QUIT)
		{
			bExit = true;
		}
		else
		{
			//draw functions
			Render();

			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		
	}

	

	return (int) msg.wParam;
}
开发者ID:jason-bunn,项目名称:Win32Tutorials,代码行数:55,代码来源:OpenGlWin32Project.cpp


注:本文中的InitGL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。