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


C++ InitOpenGL函数代码示例

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


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

示例1: main

int
main(int argc, char **argv)
{
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    screen_width = framebuffer_width * zoomed_pixel_size;
    screen_height = framebuffer_height * zoomed_pixel_size;
    glutInitWindowSize(screen_width, screen_height);

    glutInitWindowPosition(20, 20);
    glutCreateWindow("Triangle rasterization");

    glutDisplayFunc(&DrawScene);
    glutIdleFunc(&DrawScene);
    //glutReshapeFunc(&ReSizeScene);
    //glutSpecialFunc(&specialKeyPressed);
    glutKeyboardFunc(&KeyPressed);
    //glutMouseFunc(&mouseFunc);
    //glutMotionFunc(&motionFunc);

    InitOpenGL();

    glutMainLoop();

    return 1;
}
开发者ID:sagieske,项目名称:gg_opdracht1,代码行数:28,代码来源:main.c

示例2: CreateWnd

// CreateWnd: creates a full screen window to span the projectors
void CreateWnd(HINSTANCE &hinst, int width, int height, int depth)
{
	// Find the middle projector
	POINT pt;
	pt.x = -SCRWIDTH;
	pt.y = 100;

	HMONITOR hmon; // monitor handles
	hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);

	MONITORINFO mi;
	mi.cbSize = sizeof(MONITORINFO);
	GetMonitorInfo(hmon, &mi);

	// Set the window position based on the projector locations
	int posx1 = mi.rcMonitor.left;
	int posy1 = mi.rcMonitor.top;

	// Constants for fullscreen mode
	long wndStyle = WS_POPUP | WS_VISIBLE;

	// create the window
	hwnd1 = CreateWindowEx(NULL,
		WNDCLASSNAME,
		WNDNAME,
		wndStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
		posx1, posy1,
		width, height,
		NULL,
		NULL,
		hinst,
		NULL);

	hdc1 = GetDC(hwnd1);

	PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		SCRDEPTH,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		32,
		0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
	};
	indexPixelFormat = ChoosePixelFormat(hdc1, &pfd);
	SetPixelFormat(hdc1, indexPixelFormat, &pfd);

	// Setup OpenGL
	hglrc = wglCreateContext(hdc1);
	wglMakeCurrent(hdc1, hglrc);
	glewExperimental = GL_TRUE;
	glewInit();
	InitOpenGL();
	ShowWindow(hwnd1, SW_SHOW);		// everything went OK, show the window
	UpdateWindow(hwnd1);
}
开发者ID:dteinferno,项目名称:OpenGL,代码行数:59,代码来源:winmain.cpp

示例3: glViewport

void WindowManager::Reinitialize()
{
	glViewport(0,0,_Window->w,_Window->h);		// Resize OpenGL Viewport to fit the screen/window
	IsGLErrors("ToggleFullscreen");
	InitOpenGL();
	TM->ReloadTextures();
	GetRenderer()->ReinitializeAll();
	_Active=true;
}
开发者ID:Rocks25,项目名称:Voa,代码行数:9,代码来源:WindowManager.cpp

示例4: TryCompileShader

int TryCompileShader(GLenum eGLSLShaderType, char* inFilename, char* shader, double* pCompileTime)
{
    GLint iCompileStatus;
    GLuint hShader;
    Timer_t timer;

    InitTimer(&timer);

    InitOpenGL();

    hShader = glCreateShaderObjectARB(eGLSLShaderType);
    glShaderSourceARB(hShader, 1, (const char **)&shader, NULL);

    ResetTimer(&timer);
    glCompileShaderARB(hShader);
    *pCompileTime = ReadTimer(&timer);

    /* Check it compiled OK */
    glGetObjectParameterivARB (hShader, GL_OBJECT_COMPILE_STATUS_ARB, &iCompileStatus);

    if (iCompileStatus != GL_TRUE)
    {
        FILE* errorFile;
        GLint iInfoLogLength = 0;
        char* pszInfoLog;
		bstring filename = bfromcstr(inFilename);
		char* cstrFilename;

        glGetObjectParameterivARB (hShader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &iInfoLogLength);

        pszInfoLog = malloc(iInfoLogLength);

        printf("Error: Failed to compile GLSL shader\n");

		glGetInfoLogARB (hShader, iInfoLogLength, NULL, pszInfoLog);

        printf(pszInfoLog);

		bcatcstr(filename, "_compileErrors.txt");

		cstrFilename = bstr2cstr(filename, '\0');

        //Dump to file
        errorFile = fopen(cstrFilename, "w");
        fprintf(errorFile, pszInfoLog);
        fclose(errorFile);

		bdestroy(filename);
		free(cstrFilename);
        free(pszInfoLog);

        return 0;
    }

    return 1;
}
开发者ID:Corillian,项目名称:HLSLCrossCompiler,代码行数:56,代码来源:toGLSLStandalone.c

示例5: main

int main (int argc, char **argv)
{
    glutInit(&argc, argv);
    CreateGlutWindow();
    CreateGlutCallbacks();
    InitOpenGL();
    glutMainLoop();
    ExitGlut();
    return 0;
}
开发者ID:nemediano,项目名称:OpenGLHomeworks,代码行数:10,代码来源:TransformFeedback.cpp

示例6: Install

/**
 * @brief Initializes the SpringApp instance
 * @return whether initialization was successful
 */
bool SpringApp::Initialize ()
{
    if (!ParseCmdLine ())
        return false;

#ifdef WIN32
    // Initialize crash reporting
    Install( (LPGETLOGFILE) crashCallback, "[email protected]", "TA Spring Crashreport");
#endif

    // Initialize class system
    creg::ClassBinder::InitializeClasses ();

#ifndef NO_LUA
    // Initialize lua bindings
    CLuaBinder lua;
    if (!lua.LoadScript("testscript.lua"))
        handleerror(NULL, lua.lastError.c_str(), "lua",MBF_OK|MBF_EXCL);
#endif

    InitVFS ();

    if (!InitWindow ("RtsSpring"))
    {
        SDL_Quit ();
        return false;
    }
    // Global structures
    ENTER_SYNCED;
    gs=new CGlobalSyncedStuff();
    ENTER_UNSYNCED;
    gu=new CGlobalUnsyncedStuff();

    InitOpenGL();

    palette.Init();

    // Initialize keyboard
    SDL_EnableUNICODE(1);
    SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
    SDL_SetModState (KMOD_NONE);

    keys = new Uint8[SDLK_LAST];
    memset (keys,0,sizeof(Uint8)*SDLK_LAST);

    // Initialize font
    font = new CglFont(32,223);
    LoadExtensions();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    SDL_GL_SwapBuffers();

    CreateGameSetup ();

    return true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:59,代码来源:Main.cpp

示例7: CreateNewWindow

 bool CreateNewWindow() {
   HWND hWnd = CreateNewWindow_impl();
   m_hWnd = hWnd;
   if (hWnd != INVALID_HANDLE_VALUE) {
     RegisterWindow(hWnd, this);
     ResetTimer();
     InitOpenGL(hWnd);
     return true;
   }
   return false;
 }
开发者ID:omochi64,项目名称:omochi-renderer3,代码行数:11,代码来源:WindowViewer.cpp

示例8: GLRB_DriverInit

/*
@@@@@@@@@@@@@@@@@@@@@

Returns the opengl graphics driver and sets up global state

@@@@@@@@@@@@@@@@@@@@@
*/
void GLRB_DriverInit( void )
{
    GFX_Shutdown = GLRB_Shutdown;
    GFX_UnbindResources = GLRB_RestoreTextureState;
    GFX_LastError = GLRB_LastError;
    GFX_ReadPixels = GLRB_ReadPixels;
    GFX_ReadDepth = GLRB_ReadDepth;
    GFX_ReadStencil = GLRB_ReadStencil;
    GFX_CreateImage = GL_CreateImage;
    GFX_DeleteImage = GL_DeleteImage;
    GFX_UpdateCinematic = GL_UpdateCinematic;
    GFX_DrawImage = GLRB_DrawImage;
    GFX_GetImageFormat = GL_GetImageFormat;
    GFX_SetGamma = GLRB_SetGamma;
    GFX_GetFrameImageMemoryUsage = GL_SumOfUsedImages;
    GFX_GraphicsInfo = GLRB_GfxInfo_f;
    GFX_Clear = GL_Clear;
    GFX_SetProjectionMatrix = GL_SetProjection;
    GFX_GetProjectionMatrix = GL_GetProjection;
    GFX_SetModelViewMatrix = GL_SetModelView;
    GFX_GetModelViewMatrix = GL_GetModelView;
    GFX_SetViewport = GL_SetViewport;
    GFX_Flush = GL_Finish;
    GFX_SetState = GL_State;
    GFX_ResetState2D = GLRB_ResetState2D;
    GFX_ResetState3D = GLRB_ResetState3D;
    GFX_SetPortalRendering = GLRB_SetPortalRendering;
    GFX_SetDepthRange = GL_SetDepthRange;
    GFX_SetDrawBuffer = GLRB_SetDrawBuffer;
    GFX_EndFrame = GLimp_EndFrame;
    GFX_MakeCurrent = GLimp_MakeCurrent;
    GFX_ShadowSilhouette = GLRB_ShadowSilhouette;
    GFX_ShadowFinish = GLRB_ShadowFinish;
    GFX_DrawSkyBox = GLRB_DrawSkyBox;
    GFX_DrawBeam = GLRB_DrawBeam;
    GFX_DrawStageGeneric = GLRB_StageIteratorGeneric;
    GFX_DrawStageVertexLitTexture = GLRB_StageIteratorVertexLitTexture;
    GFX_DrawStageLightmappedMultitexture = GLRB_StageIteratorLightmappedMultitexture;
    GFX_DebugDrawAxis = GLRB_SurfaceAxis;
    GFX_DebugDrawTris = GLRB_DebugDrawTris;
    GFX_DebugDrawNormals = GLRB_DebugDrawNormals;
    GFX_DebugSetOverdrawMeasureEnabled = GLRB_SetOverdrawMeasureEnabled;
    GFX_DebugSetTextureMode = GL_TextureMode;
    GFX_DebugDrawPolygon = GLRB_DebugPolygon;

    InitOpenGL();

    // Copy the resource strings to the vgConfig
    Q_strncpyz( vdConfig.renderer_string, glState.renderer_string, sizeof( vdConfig.renderer_string ) );
    Q_strncpyz( vdConfig.vendor_string, glState.vendor_string, sizeof( vdConfig.vendor_string ) );
    Q_strncpyz( vdConfig.version_string, glState.version_string, sizeof( vdConfig.version_string ) );
}
开发者ID:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:59,代码来源:gl_driver.c

示例9: TryCompileShader

int TryCompileShader(GLenum eGLSLShaderType, const char* inFilename, char* shader, double* pCompileTime)
{
    GLint iCompileStatus;
    GLuint hShader;
    Timer_t timer;

    InitTimer(&timer);

    InitOpenGL();

    hShader = glCreateShaderObjectARB(eGLSLShaderType);
    glShaderSourceARB(hShader, 1, (const char **)&shader, NULL);

    ResetTimer(&timer);
    glCompileShaderARB(hShader);
    *pCompileTime = ReadTimer(&timer);

    /* Check it compiled OK */
    glGetObjectParameterivARB (hShader, GL_OBJECT_COMPILE_STATUS_ARB, &iCompileStatus);

    FILE* errorFile;
    GLint iInfoLogLength = 0;
    char* pszInfoLog;
	std::string filename;

    filename += inFilename;

    glGetObjectParameterivARB (hShader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &iInfoLogLength);

	if (iInfoLogLength > 1)
	{
		pszInfoLog = new char[iInfoLogLength];

		if (iCompileStatus != GL_TRUE)
			printf("Error: Failed to compile GLSL shader\n");

		glGetInfoLogARB(hShader, iInfoLogLength, NULL, pszInfoLog);

		printf(pszInfoLog);

		filename += "_compileErrors.txt";

		//Dump to file
		errorFile = fopen(filename.c_str(), "w");
		fprintf(errorFile, pszInfoLog);
		fclose(errorFile);

		delete[] pszInfoLog;
	}
    return iCompileStatus == GL_TRUE ? 1 : 0;

}
开发者ID:AmesianX,项目名称:HLSLCrossCompiler,代码行数:52,代码来源:toGLSLStandalone.cpp

示例10: Win32InitOpenGL

internal void
Win32InitOpenGL(HDC WindowDC)
{
    Win32LoadWGLExtensions();

    HGLRC OpenGLRC       = 0;
    bool32 ModernContext = true;

    if(wglCreateContextAttribsARB)
    {
        int Win32OpenGLAttribs[] = {
            WGL_CONTEXT_MAJOR_VERSION_ARB,
            3,
            WGL_CONTEXT_MINOR_VERSION_ARB,
            1,
            WGL_CONTEXT_FLAGS_ARB,
            WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
#if LUDUS_INTERNAL
                |
                WGL_CONTEXT_DEBUG_BIT_ARB
#endif
            ,
            WGL_CONTEXT_PROFILE_MASK_ARB,
            WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
            0
        };

        Win32SetPixelFormat(WindowDC);
        OpenGLRC = wglCreateContextAttribsARB(WindowDC, 0, Win32OpenGLAttribs);
    }

    if(!OpenGLRC)
    {
        ModernContext = false;
        OpenGLRC      = wglCreateContext(WindowDC);
    }

    if(wglMakeCurrent(WindowDC, OpenGLRC))
    {
        InitOpenGL(ModernContext);

        if(wglSwapInterval)
        {
            wglSwapInterval(1);
        }
    }
    else
    {
        Win32Log("Couldnt set OpenGL context");
        LOG_FORMATTED_ERROR(4096);
    }
}
开发者ID:Clever-Boy,项目名称:Ludus,代码行数:52,代码来源:win32_ogl.cpp

示例11: SDL_Init

		SCSerror SCSapplication::Create (const SCSstring sTitle, const SCSstring sVersion, const SCSbool iFullscreen)
		{
			m_sTitle = sTitle;
			m_sVersion = sVersion;
			SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
			if (SCSdisplay::Singleton()->Create(iFullscreen)) return scsHandleError(SCS_ERROR_FRAMEWORK | SCS_ERROR_CREATE | SCS_ERROR_DISPLAY);
			SDL_WM_SetCaption(m_sTitle.c_str(), m_sTitle.c_str());
			InitOpenGL();
			SCSgraphics::Singleton()->Init();
			SCSmixer::Singleton()->Init(32);

			return SCS_ERROR_NONE;
		}
开发者ID:spdemille,项目名称:Game-Engine,代码行数:13,代码来源:scs-application.cpp

示例12: printf

openni::Status SampleViewer::Init(int argc, char **argv)
{
	// initial ros node
	ros::init(argc, argv, "user_viewer");
	ros::NodeHandle n;
	movePublisher = n.advertise<std_msgs::String>("cmd_erica", 20);
	// initial variable
	rightShoulderYaw = 0, rightShoulderPitch = 0, rightElbowTheta = 0, rightElbowYaw = 0;
	rightShoulderYawPub = 0, rightShoulderPitchPub = 0, rightElbowYawPub = 0, rightElbowThetaPub = 0;
	leftShoulderYaw = 0, leftShoulderPitch = 0, leftElbowTheta = 0, leftElbowYaw = 0;
	leftShoulderYawPub = 0, leftShoulderPitchPub = 0, leftElbowYawPub = 0, leftElbowThetaPub = 0;


	m_pTexMap = NULL;

	openni::Status rc = openni::OpenNI::initialize();
	if (rc != openni::STATUS_OK)
	{
		printf("Failed to initialize OpenNI\n%s\n", openni::OpenNI::getExtendedError());
		return rc;
	}

	const char* deviceUri = openni::ANY_DEVICE;
	for (int i = 1; i < argc-1; ++i)
	{
		if (strcmp(argv[i], "-device") == 0)
		{
			deviceUri = argv[i+1];
			break;
		}
	}

	rc = m_device.open(deviceUri);
	if (rc != openni::STATUS_OK)
	{
		printf("Failed to open device\n%s\n", openni::OpenNI::getExtendedError());
		return rc;
	}

	nite::NiTE::initialize();

	if (m_pUserTracker->create(&m_device) != nite::STATUS_OK)
	{
		return openni::STATUS_ERROR;
	}


	return InitOpenGL(argc, argv);

}
开发者ID:Newhandnew,项目名称:ROS-SkeletonTracking,代码行数:50,代码来源:user_viewer.cpp

示例13: main

//-----------------------------------------------------------------------------
int main(int argc, char **argv) {
	// Inicializações.
	InitOpenGL(&argc, argv);
	InitCallBacks();
	InitDataStructures();

	// Ajusta a função que chama as funções do mygl.h
	DrawFunc = MyGlDraw;

	// Framebuffer scan loop.
	glutMainLoop();

	return 0;
}
开发者ID:SoaresGabriel,项目名称:TrabalhoICG,代码行数:15,代码来源:main.cpp

示例14: CreateGameWindow

HDC GameWindow::Init(HINSTANCE hinstance) 
{
	m_hinstance = hinstance;

	CreateGameWindow("IN3026 Template");

	// If we never got a valid window handle, quit the program
	if(m_hwnd == NULL) {
		return NULL;
	} else {
		// INIT OpenGL
		InitOpenGL();
		return m_hdc;
	}
}
开发者ID:Displonker,项目名称:Bullet_Game,代码行数:15,代码来源:GameWindow.cpp

示例15: RE_Init

/*
===============
RE_Init
===============
*/
void RE_Init( void ) {	
	int	err;

	ST_Printf( PRINT_R_VERBOSE, "----- R_Init -----\n" );

	R_Register();

	InitOpenGL();

	err = glGetError();
	if ( err != GL_NO_ERROR )
		ST_Printf ( PRINT_R_VERBOSE, "glGetError() = 0x%x\n", err );

	ST_Printf( PRINT_R_VERBOSE, "----- finished R_Init -----\n" );
}
开发者ID:jite,项目名称:jquake,代码行数:20,代码来源:tr_init.c


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