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


C++ GLRenderSystem类代码示例

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


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

示例1: _unregisterContext

	void OSXContext::_unregisterContext()
	{
		// NB have to do this is subclass to ensure any methods called back
		// are on this subclass and not half-destructed superclass
		GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
		rs->_unregisterContext(this);
	}
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:7,代码来源:OgreOSXContext.cpp

示例2: mDrawable

	GLXContext::GLXContext(GLXGLSupport* glsupport, ::GLXFBConfig fbconfig, ::GLXDrawable drawable, ::GLXContext context) :
		mDrawable(drawable), mContext(0), mFBConfig(fbconfig), mGLSupport(glsupport), mExternalContext(false)
	{
		GLRenderSystem *renderSystem = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
		GLXContext* mainContext = static_cast<GLXContext*>(renderSystem->_getMainContext());
		::GLXContext shareContext = 0;
		
		if (mainContext)
		{
			shareContext = mainContext->mContext;
		}
		
		if (context)
		{
			mContext = context;
			mExternalContext = true;
		}
		else
		{
			mContext = mGLSupport->createNewContext(mFBConfig, GLX_RGBA_TYPE, shareContext, GL_TRUE);
		}

		if (! mContext)
		{
			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to create a suitable GLXContext", "GLXContext::GLXContext");
		}
	}
开发者ID:terminus510,项目名称:OgreBulletTest,代码行数:27,代码来源:OgreGLXContext.cpp

示例3: aglChoosePixelFormat

    void OSXCarbonWindow::createAGLContext(size_t fsaa_samples, int depth)
    {
        if(!mAGLContext)
        {
            int i = 0;
            GLint attribs[ 20 ];
            
            attribs[ i++ ] = AGL_NO_RECOVERY;
            attribs[ i++ ] = GL_TRUE;
            attribs[ i++ ] = AGL_ACCELERATED;
            attribs[ i++ ] = GL_TRUE;
            attribs[ i++ ] = AGL_RGBA;
            attribs[ i++ ] = AGL_DOUBLEBUFFER;
            attribs[ i++ ] = AGL_ALPHA_SIZE;
            attribs[ i++ ] = 8;
            attribs[ i++ ] = AGL_STENCIL_SIZE;
            attribs[ i++ ] = 8;
            attribs[ i++ ] = AGL_DEPTH_SIZE;
            attribs[ i++ ] = depth;
            
            if(fsaa_samples > 1)
            {
                attribs[ i++ ] = AGL_MULTISAMPLE;
                attribs[ i++ ] = AGL_SAMPLE_BUFFERS_ARB;
                attribs[ i++ ] = 1;
                attribs[ i++ ] = AGL_SAMPLES_ARB;
                attribs[ i++ ] = fsaa_samples;
            }

#if OGRE_STEREO_ENABLE
            if (mStereoEnabled)
                attribs[i++] = AGL_STEREO;
#endif

            attribs[ i++ ] = AGL_NONE;
            
            mAGLPixelFormat = aglChoosePixelFormat( NULL, 0, attribs );

            if(!mAGLPixelFormat)
            {
                OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
                            "Unable to create a valid pixel format with selected attributes.",
                            "OSXCarbonWindow::createAGLContext" );
            }
            
            // Create the AGLContext from our pixel format
            // Share it with main
            GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
            OSXContext* mainContext = static_cast<OSXContext*>( rs->_getMainContext() );
            if(mainContext == 0 || !(mainContext->getContextType() == "AGL"))
            {
                mAGLContext = aglCreateContext(mAGLPixelFormat, NULL);
            }
            else
            {
                OSXCarbonContext* context = static_cast<OSXCarbonContext*>( rs->_getMainContext() );
                mAGLContext = aglCreateContext(mAGLPixelFormat, context->getContext());
            }
        }
    }
开发者ID:j-rivero,项目名称:ogre-acornacorn,代码行数:60,代码来源:OgreOSXCarbonWindow.cpp

示例4:

	GLXContext::~GLXContext() 	
	{
		GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
		
		if (!mExternalContext)
			glXDestroyContext(mGLSupport->getGLDisplay(), mContext);
		
		rs->_unregisterContext(this);
	}
开发者ID:terminus510,项目名称:OgreBulletTest,代码行数:9,代码来源:OgreGLXContext.cpp

示例5: upload_params

	void GLMaterial::upload_params(GLRenderSystem& renderer, const Table<String, Material::Param>& params, uint32& texIndex)
	{
		for (const auto& param : params)
		{
			// Handles parameter binding in a generic way
			auto bindHandler = [&](auto value)
			{
				using T = std::decay_t<decltype(value)>;

				// Get param location
				int32 location = glGetUniformLocation(_id, param.First.Cstr());

				// Handle texture case
				if (std::is_same<ResourceHandle<Texture>, T>::value)
				{
					const auto& texValue = reinterpret_cast<const ResourceHandle<Texture>&>(value);

					// Set active texture, and upload
					glActiveTexture(GL_TEXTURE0 + texIndex);
					glBindTexture(GL_TEXTURE_2D, renderer.find_texture(texValue).get_id());
					glUniform1i(location, texIndex);
					++texIndex;
				}

				// Upload the parameter
				this->upload_param(location, value);
			};

			param.Second.Invoke(bindHandler);
		}
	}
开发者ID:willcassella,项目名称:WillowEngine,代码行数:31,代码来源:GLMaterial.cpp

示例6: aglChoosePixelFormat

 void OSXCarbonWindow::createAGLContext(size_t fsaa_samples, int depth)
 {
     if(!mAGLContext)
     {
         int i = 0;
         GLint attribs[ 20 ];
         
         attribs[ i++ ] = AGL_NO_RECOVERY;
         attribs[ i++ ] = GL_TRUE;
         attribs[ i++ ] = AGL_ACCELERATED;
         attribs[ i++ ] = GL_TRUE;
         attribs[ i++ ] = AGL_RGBA;
         attribs[ i++ ] = AGL_DOUBLEBUFFER;
         attribs[ i++ ] = AGL_ALPHA_SIZE;
         attribs[ i++ ] = 8;
         attribs[ i++ ] = AGL_STENCIL_SIZE;
         attribs[ i++ ] = 8;
         attribs[ i++ ] = AGL_DEPTH_SIZE;
         attribs[ i++ ] = depth;
         
         if(fsaa_samples > 1)
         {
             attribs[ i++ ] = AGL_MULTISAMPLE;
             attribs[ i++ ] = 1;
             attribs[ i++ ] = AGL_SAMPLE_BUFFERS_ARB;
             attribs[ i++ ] = fsaa_samples;
         }
         
         attribs[ i++ ] = AGL_NONE;
         
         mAGLPixelFormat = aglChoosePixelFormat( NULL, 0, attribs );
         
         // Create the AGLContext from our pixel format
         // Share it with main
         GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
         OSXContext* mainContext = static_cast<OSXContext*>( rs->_getMainContext() );
         if(mainContext == 0 || !(mainContext->getContextType() == "AGL"))
         {
             mAGLContext = aglCreateContext(mAGLPixelFormat, NULL);
         }
         else
         {
             OSXCarbonContext* context = static_cast<OSXCarbonContext*>( rs->_getMainContext() );
             mAGLContext = aglCreateContext(mAGLPixelFormat, context->getContext());
         }
     }
 }
开发者ID:Strongc,项目名称:game-ui-solution,代码行数:47,代码来源:OgreOSXCarbonWindow.cpp

示例7: glCreateProgram

	GLMaterial::GLMaterial(GLRenderSystem& renderer, const Material& mat)
		: _params(mat.default_params)
	{
		_id = glCreateProgram();

		BufferID vShader = renderer.find_shader(mat.vertex_shader).get_id();
		BufferID fShader = renderer.find_shader(mat.fragment_shader).get_id();

		glAttachShader(_id, vShader);
		glAttachShader(_id, fShader);
		glBindAttribLocation(_id, 0, "vPosition");
		glBindAttribLocation(_id, 1, "vTexCoord");
		glBindAttribLocation(_id, 2, "vNormal");
		glLinkProgram(_id);

		// Make sure program successfully linked
		GLint linked;
		glGetProgramiv(_id, GL_LINK_STATUS, &linked);
		if (!linked)
		{
			GLsizei length;
			glGetProgramiv(_id, GL_INFO_LOG_LENGTH, &length);

			GLchar* log = new GLchar[length + 1];
			glGetProgramInfoLog(_id, length, &length, log);
			Console::WriteLine("Material compilation failed: \"@\"", log);
			delete[] log;
		}

		_model = glGetUniformLocation(_id, "model");
		_view = glGetUniformLocation(_id, "view");
		_projection = glGetUniformLocation(_id, "projection");

		glDetachShader(_id, vShader);
		glDetachShader(_id, fShader);
	}
开发者ID:willcassella,项目名称:WillowEngine,代码行数:36,代码来源:GLMaterial.cpp

示例8: if

//-------------------------------------------------------------------------------------------------//
void OSXCarbonWindow::create( const String& name, unsigned int width, unsigned int height,
	            bool fullScreen, const NameValuePairList *miscParams )
{
	bool hasDepthBuffer;
	String title = name;
	size_t fsaa_samples = 0;
	int left = 0;
	int top = 0;
	int depth = 32;
	
	if( miscParams )
	{
		
		NameValuePairList::const_iterator opt = NULL;
		
		// Full screen anti aliasing
		opt = miscParams->find( "FSAA" );
		if( opt != miscParams->end() )
			fsaa_samples = StringConverter::parseUnsignedInt( opt->second );

		opt = miscParams->find( "left" );
		if( opt != miscParams->end() )
			left = StringConverter::parseUnsignedInt( opt->second );

		opt = miscParams->find( "top" );
		if( opt != miscParams->end() )
			top = StringConverter::parseUnsignedInt( opt->second );

		opt = miscParams->find( "title" );
		if( opt != miscParams->end() )
			title = opt->second;

		opt = miscParams->find( "depthBuffer" );
		if( opt != miscParams->end() )
			hasDepthBuffer = StringConverter::parseBool( opt->second );
		
		opt = miscParams->find( "colourDepth" );
		if( opt != miscParams->end() )
			depth = StringConverter::parseUnsignedInt( opt->second );
	}
	
	if(fullScreen)
	{
		GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
		OSXContext *mainContext = (OSXContext*)rs->_getMainContext();
		
		CGLContextObj share = NULL;
		if(mainContext == 0)
		{
			share = NULL;
		}
		else if(mainContext->getContextType() == "AGL")
		{
			OSXCarbonContext* aglShare = static_cast<OSXCarbonContext*>(mainContext);
			aglGetCGLContext(aglShare->getContext(), &((void*)share));
		}
		else if(mainContext->getContextType() == "CGL")
		{
			OSXCGLContext* cglShare = static_cast<OSXCGLContext*>(mainContext);
			share = cglShare->getContext();
		}
		
		// create the context
		createCGLFullscreen(width, height, depth, fsaa_samples, share);		
	}
	else
	{
		int i = 0;
		AGLPixelFormat pixelFormat;
		GLint attribs[ 20 ];
		
		attribs[ i++ ] = AGL_NO_RECOVERY;
		attribs[ i++ ] = GL_TRUE;
		attribs[ i++ ] = AGL_ACCELERATED;
		attribs[ i++ ] = GL_TRUE;
		attribs[ i++ ] = AGL_RGBA;
		attribs[ i++ ] = AGL_DOUBLEBUFFER;
		attribs[ i++ ] = AGL_ALPHA_SIZE;
		attribs[ i++ ] = 8;
		attribs[ i++ ] = AGL_STENCIL_SIZE;
		attribs[ i++ ] = 8;
		attribs[ i++ ] = AGL_DEPTH_SIZE;
		attribs[ i++ ] = depth;
	
		if(fsaa_samples > 1)
		{
			attribs[ i++ ] = AGL_MULTISAMPLE;
			attribs[ i++ ] = 1;
			attribs[ i++ ] = AGL_SAMPLE_BUFFERS_ARB;
			attribs[ i++ ] = fsaa_samples;
		}
	
		attribs[ i++ ] = AGL_NONE;
	
		pixelFormat = aglChoosePixelFormat( NULL, 0, attribs );
	
		// Create the AGLContext from our pixel format
		// Share it with main
		GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
//.........这里部分代码省略.........
开发者ID:jjiezheng,项目名称:pap_full,代码行数:101,代码来源:OgreOSXCarbonWindow.cpp

示例9: createAGLContext

    void OSXCarbonWindow::setFullscreen(bool fullScreen, unsigned int width, unsigned int height)
    {
        if (mIsFullScreen != fullScreen || width != mWidth || height != mHeight)
        {
            // Set the full screen flag
            mIsFullScreen = fullScreen;

            createAGLContext(mFSAA, mColourDepth);

            if (mIsFullScreen)
            {
                GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());

                CGLContextObj share = NULL;
                aglGetCGLContext(mAGLContext, (void**)&share);

                // Create the CGL context object if it doesn't already exist, sharing the AGL context.
                if(!mCGLContext)
                {
                    void *cglPixFormat;
                    aglGetCGLPixelFormat(mAGLPixelFormat, (void **)&cglPixFormat);
                    mCGLContext = OGRE_NEW OSXCGLContext(mCGLContextObj, (CGLPixelFormatObj) cglPixFormat);
                }

                // Create the context, keeping the current colour depth and FSAA settings
                createCGLFullscreen(width, height, getColourDepth(), getFSAA(), share);
                rs->_switchContext(mContext);

                // Hide the Carbon window
                HideWindow(mWindow);

                // And tell the rendersystem to stop rendering to it too
                WindowEventUtilities::_removeRenderWindow(this);
            }
            else
            {
                // Create a new AGL context and pixel format if necessary
                createAGLContext(mFSAA, mColourDepth);

                // Create a window if we haven't already, existence check is done within the functions
                if(!mWindow)
                {
                    if(mIsExternal)
                        createWindowFromExternal(mView);
                    else
                        createNewWindow(width, height, mWindowTitle);
                }

                // Destroy the current CGL context, we will create a new one when/if we go back to full screen
                destroyCGLFullscreen();

                // Set the drawable, and current context
                // If you do this last, there is a moment before the rendering window pops-up
                #if defined(MAC_OS_X_VERSION_10_4) && MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
                    aglSetDrawable(mAGLContext, GetWindowPort(mWindow));
                #else
                    aglSetWindowRef(mAGLContext, mWindow);
                #endif
                aglSetCurrentContext(mAGLContext);

                if(!mCarbonContext)
                {
                    mCarbonContext = OGRE_NEW OSXCarbonContext(mAGLContext, mAGLPixelFormat);
                }
                
                GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem());
                mContext = mCarbonContext;
                rs->_switchContext(mContext);

                WindowEventUtilities::_addRenderWindow(this);

                ShowWindow(mWindow);
                SelectWindow(mWindow);
                RepositionWindow(mWindow, NULL, kWindowCenterOnMainScreen);
            }
            mWidth = width;
            mHeight = height;
        }
    }
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:79,代码来源:OgreOSXCarbonWindow.cpp


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