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


C++ GLCheck函数代码示例

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


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

示例1: GLCheck

void RenderableObject::CompileBuffers()
{
	Logger::Log() << "[INFO] Generate " << m_buffers.size() + 1
			<< " buffers ... \n";
	m_is_compiled = true;
	m_indices_buffers = new unsigned int[m_buffers.size() + 1];
	GLCheck(glGenBuffers( m_buffers.size()+1, m_indices_buffers ));
	Logger::Log() << "  * indice id : " << m_indices_buffers[0] << "\n";
	// Add index buffer
	Logger::Log() << "   * load indices buffers ... " << m_indices_buffers[0]
			<< "\n";
	GLCheck(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indices_buffers[0]));
	GLCheck(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int)*m_indices_size, m_indices, GL_STATIC_DRAW));
	// Add all others buffers
	int i = 1;
	for (BufferMap::iterator it = m_buffers.begin(); it != m_buffers.end();
			it++)
			{
		Logger::Log() << "   * load other buffers ... " << m_indices_buffers[i]
				<< "\n";
		GLCheck(glBindBuffer(GL_ARRAY_BUFFER, m_indices_buffers[i]));
		GLCheck(glBufferData(GL_ARRAY_BUFFER, sizeof(float)*it->second.size, it->second.buffer, GL_STATIC_DRAW));
		i++;
	}
}
开发者ID:beltegeuse,项目名称:Amaterasu3D,代码行数:25,代码来源:RenderableObject.cpp

示例2: Assert

void RenderableObject::Draw()
{
	Assert(m_is_compiled);
	// pas de shader
	if (!CShaderManager::Instance().activedShader())
	{
		Logger::Log()
				<< "[Warning] No actived shader. Nothings to render ... \n";
	}
	// Material activation
	for (MaterialMap::iterator it = m_material_map.begin();
			it != m_material_map.end(); it++)
			{
			if (!CShaderManager::Instance().currentShader()->IsMaterialAvailable(it->first))
				continue;
			CShaderManager::Instance().currentShader()->SetMaterialValue(it->first,it->second);
	}
	// Textures activation
	for (TexturesMap::iterator it = m_textures_map.begin();
			it != m_textures_map.end(); it++)
			{
		if (!CShaderManager::Instance().currentShader()->IsTextureAvailable(
				it->first))
			continue;
		it->second->activateMultiTex(it->first);
	}
	// Buffer activation
	int i = 1;
	for (BufferMap::iterator it = m_buffers.begin(); it != m_buffers.end(); it++)
	{
		if (!CShaderManager::Instance().currentShader()->IsAttributAvailable(it->first))
			continue;
		GLCheck(glBindBuffer(GL_ARRAY_BUFFER, m_indices_buffers[i]));
		glEnableVertexAttribArray(it->first);
		GLCheck(glVertexAttribPointer(it->first, it->second.dimension, GL_FLOAT, GL_FALSE, 0, 0));
		i++;
	}
	// Drawing
	CShaderManager::Instance().currentShader()->OnDraw();
	GLCheck(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indices_buffers[0]));
	GLCheck(glDrawElements(m_DrawMode, m_indices_size, GL_UNSIGNED_INT, 0));
	// Buffer desactivation
	for (BufferMap::iterator it = m_buffers.begin(); it != m_buffers.end();
			it++)
			{
		if (!CShaderManager::Instance().currentShader()->IsAttributAvailable(
				it->first))
			continue;
		glDisableVertexAttribArray(it->first);
	}
	// Textures desactivations
	for (TexturesMap::reverse_iterator it = m_textures_map.rbegin();
			it != m_textures_map.rend(); it++)
			{
		if (!CShaderManager::Instance().currentShader()->IsTextureAvailable(
				it->first))
			continue;
		it->second->desactivateMultiTex(it->first);
	}
}
开发者ID:beltegeuse,项目名称:Amaterasu3D,代码行数:60,代码来源:RenderableObject.cpp

示例3: glGetUniformLocation

////////////////////////////////////////////////////////////
/// Change la valeur d'un paramètre (scalaire ou vecteur) du shader
///
/// \param Name :  Nom du paramètre
/// \param Value : Valeur du paramètre (quadruplet de flottants)
///
////////////////////////////////////////////////////////////
void GLShader::SetParameter(const std::string& Name, const size_t count_, const float* Value)
{
	GLuint paramID = glGetUniformLocation(m_ProgramID, Name.c_str());
	/*
	glUniform1f (GLint location, GLfloat v0);
	glUniform2f (GLint location, GLfloat v0, GLfloat v1);
	glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
	glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
	*/

	switch (count_)
	{
	case 1:
		GLCheck(glUniform1fv(paramID, 1, Value));
		break;

	case 2:
		GLCheck(glUniform2fv(paramID, 1, Value));
		break;

	case 3:
		GLCheck(glUniform3fv(paramID, 1, Value));
		break;

	case 4:
		GLCheck(glUniform4fv(paramID, 1, Value));
		break;
	}
}
开发者ID:xcasadio,项目名称:casaengine,代码行数:36,代码来源:GLShader.cpp

示例4: send_attribute

void send_attribute(ShaderAvailableAttributes attr,
                    const VertexData& data,
                    EnabledMethod exists_on_data_predicate,
                    OffsetMethod offset_func) {

    int32_t loc = (int32_t) attr;

    auto get_has_attribute = std::bind(exists_on_data_predicate, std::reference_wrapper<const VertexData>(data));

    if(get_has_attribute()) {
        auto get_offset = std::bind(offset_func, std::reference_wrapper<const VertexData>(data));

        GLCheck(glEnableVertexAttribArray, loc);
        GLCheck(glVertexAttribPointer,
            loc,
            SHADER_ATTRIBUTE_SIZES.find(attr)->second,
            GL_FLOAT,
            GL_FALSE,
            data.stride(),
            BUFFER_OFFSET(get_offset())
        );
    } else {
        //L_WARN_ONCE(_u("Couldn't locate attribute on the mesh: {0}").format(attr));
    }
}
开发者ID:aonorin,项目名称:KGLT,代码行数:25,代码来源:generic_renderer.cpp

示例5: GLCheck

////////////////////////////////////////////////////////////
/// Called when the window displays its content on screen
////////////////////////////////////////////////////////////
void RenderWindow::OnDisplay()
{
    // Clear the frame buffer with the background color, for next frame
    GLCheck(glClearColor(myBackgroundColor.r / 255.f,
                         myBackgroundColor.g / 255.f,
                         myBackgroundColor.b / 255.f,
                         myBackgroundColor.a / 255.f));
    GLCheck(glClear(GL_COLOR_BUFFER_BIT));
}
开发者ID:fu7mu4,项目名称:entonetics,代码行数:12,代码来源:RenderWindow.cpp

示例6: Image

Image Texture::CopyToImage() const
{
    // Easy case: empty texture
    if (!myTexture)
        return Image();

    EnsureGlContext();

    // Make sure that the current texture binding will be preserved
    priv::TextureSaver save;

    // Create an array of pixels
    std::vector<Uint8> pixels(myWidth * myHeight * 4);

    if ((myWidth == myTextureWidth) && (myHeight == myTextureHeight) && !myPixelsFlipped)
    {
        // Texture is not padded nor flipped, we can use a direct copy
        GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
        GLCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]));
    }
    else
    {
        // Texture is either padded or flipped, we have to use a slower algorithm

        // All the pixels will first be copied to a temporary array
        std::vector<Uint8> allPixels(myTextureWidth * myTextureHeight * 4);
        GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
        GLCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &allPixels[0]));

        // Then we copy the useful pixels from the temporary array to the final one
        const Uint8* src = &allPixels[0];
        Uint8* dst = &pixels[0];
        int srcPitch = myTextureWidth * 4;
        int dstPitch = myWidth * 4;

        // Handle the case where source pixels are flipped vertically
        if (myPixelsFlipped)
        {
            src += srcPitch * (myHeight - 1);
            srcPitch = -srcPitch;
        }

        for (unsigned int i = 0; i < myHeight; ++i)
        {
            std::memcpy(dst, src, dstPitch);
            src += srcPitch;
            dst += dstPitch;
        }
    }

    // Create the image
    Image image;
    image.Create(myWidth, myHeight, &pixels[0]);

    return image;
}
开发者ID:ChrisJansson,项目名称:Graphics,代码行数:56,代码来源:Texture.cpp

示例7: Update

bool Texture::LoadFromImage(const Image& image, const IntRect& area)
{
    // Retrieve the image size
    int width = static_cast<int>(image.GetWidth());
    int height = static_cast<int>(image.GetHeight());

    // Load the entire image if the source area is either empty or contains the whole image
    if (area.Width == 0 || (area.Height == 0) ||
       ((area.Left <= 0) && (area.Top <= 0) && (area.Width >= width) && (area.Height >= height)))
    {
        // Load the entire image
        if (Create(image.GetWidth(), image.GetHeight()))
        {
            Update(image);
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        // Load a sub-area of the image

        // Adjust the rectangle to the size of the image
        IntRect rectangle = area;
        if (rectangle.Left   < 0) rectangle.Left = 0;
        if (rectangle.Top    < 0) rectangle.Top  = 0;
        if (rectangle.Left + rectangle.Width > width)  rectangle.Width  = width - rectangle.Left;
        if (rectangle.Top + rectangle.Height > height) rectangle.Height = height - rectangle.Top;

        // Create the texture and upload the pixels
        if (Create(rectangle.Width, rectangle.Height))
        {
            // Make sure that the current texture binding will be preserved
            priv::TextureSaver save;

            // Copy the pixels to the texture, row by row
            const Uint8* pixels = image.GetPixelsPtr() + 4 * (rectangle.Left + (width * rectangle.Top));
            GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
            for (int i = 0; i < rectangle.Height; ++i)
            {
                GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, myWidth, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
                pixels += 4 * width;
            }

            return true;
        }
        else
        {
            return false;
        }
    }
}
开发者ID:ChrisJansson,项目名称:Graphics,代码行数:55,代码来源:Texture.cpp

示例8: GLCheck

void Renderer::RestoreGLStates()
{
    // Restore render states
    GLCheck(glPopAttrib());

    // Restore matrices
    GLCheck(glMatrixMode(GL_PROJECTION));
    GLCheck(glPopMatrix());
    GLCheck(glMatrixMode(GL_MODELVIEW));
    GLCheck(glPopMatrix());
}
开发者ID:TheMiss,项目名称:SFML,代码行数:11,代码来源:Renderer.cpp

示例9: GLCheck

void RenderImageImplDefault::UpdateTexture(unsigned int textureId)
{
    GLint previous;
    GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previous));

    // Copy the rendered pixels to the image
    GLCheck(glBindTexture(GL_TEXTURE_2D, textureId));
    GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, myWidth, myHeight));

    GLCheck(glBindTexture(GL_TEXTURE_2D, previous));
}
开发者ID:TheMiss,项目名称:SFML,代码行数:11,代码来源:RenderImageImplDefault.cpp

示例10: assert

void Texture::Update(const Window& window, unsigned int x, unsigned int y)
{
    assert(x + window.GetWidth() <= myWidth);
    assert(y + window.GetHeight() <= myHeight);

    if (myTexture && window.SetActive(true))
    {
        // Copy pixels from the back-buffer to the texture
        GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
        GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, window.GetWidth(), window.GetHeight()));
        myPixelsFlipped = true;
    }
}
开发者ID:IdeasStorm,项目名称:SFML,代码行数:13,代码来源:Texture.cpp

示例11: GLCheck

    void HardwareGeometry::cleanUp
    (

    )
    {
        if( glIsBuffer(m_vbo) )
            GLCheck(glDeleteBuffers(1, &m_vbo));

        if( glIsBuffer(m_ibo) )
            GLCheck(glDeleteBuffers(1, &m_ibo));

        if( glIsVertexArray(m_vao) )
            GLCheck(glDeleteVertexArrays(1, &m_vao));
    }
开发者ID:anonreclaimer,项目名称:plastic-dev,代码行数:14,代码来源:HardwareGeometry.cpp

示例12: GLCheck

void Shader::BindTextures() const
{
    TextureTable::const_iterator it = myTextures.begin();
    for (std::size_t i = 0; i < myTextures.size(); ++i)
    {
        GLint index = static_cast<GLsizei>(i + 1);
        GLCheck(glUniform1iARB(it->first, index));
        GLCheck(glActiveTextureARB(GL_TEXTURE0_ARB + index));
        it->second->Bind();
        it++;
    }

    // Make sure that the texture unit which is left active is the number 0
    GLCheck(glActiveTextureARB(GL_TEXTURE0_ARB));
}
开发者ID:vidjogamer,项目名称:ProjectTemplate,代码行数:15,代码来源:Shader.cpp

示例13: GLCheck

RenderImageImplFBO::~RenderImageImplFBO()
{
    // Destroy the depth buffer
    if (myDepthBuffer)
    {
        GLuint depthBuffer = static_cast<GLuint>(myDepthBuffer);
        GLCheck(glDeleteFramebuffersEXT(1, &depthBuffer));
    }

    // Destroy the frame buffer
    if (myFrameBuffer)
    {
        GLuint frameBuffer = static_cast<GLuint>(myFrameBuffer);
        GLCheck(glDeleteFramebuffersEXT(1, &frameBuffer));
    }
}
开发者ID:vidjogamer,项目名称:ProjectTemplate,代码行数:16,代码来源:RenderImageImplFBO.cpp

示例14: checkDimensionsArePowerOfTwo

    void UploaderTexture2D::allocateTextureMemory
    (
        PixelFormat format, 
        const uvec2 &dimensions,
        unsigned int levels
    )
    {
        checkDimensionsArePowerOfTwo(dimensions);
       
        // Use glTexStorage2D instead, it's the same but OpenGL 4.2!! Remplacer même l'exception
		//GLCheck(glTexStorage2D(GL_TEXTURE_2D, levels, GLEnum::getInternalFormat(format), dimensions.x, dimensions.y));

        if(levels < 1)
            throw std::runtime_error("Levels < 1");

        unsigned int width = dimensions.x;
        unsigned int height = dimensions.y;

        for (unsigned int i(0); i<levels; i++)
        {
            GLCheck( glTexImage2D(GL_TEXTURE_2D, i, GLEnum::getInternalFormat(format), width, height, 0, GLEnum::getExternalFormat(format), GLEnum::getType(format), NULL ));
            width = std::max(1u, width/2);
            height = std::max(1u, height/2);
        }
    }
开发者ID:anonreclaimer,项目名称:plastic-dev,代码行数:25,代码来源:UploaderTexture2D.cpp

示例15: GetWidth

////////////////////////////////////////////////////////////
/// Save the content of the window to an image
////////////////////////////////////////////////////////////
Image RenderWindow::Capture() const
{
    // Get the window dimensions
    const unsigned int Width  = GetWidth();
    const unsigned int Height = GetHeight();

    // Set our window as the current target for rendering
    if (SetActive())
    {
        // Get pixels from the backbuffer
        std::vector<Uint8> Pixels(Width * Height * 4);
        Uint8* PixelsPtr = &Pixels[0];
        GLCheck(glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, PixelsPtr));

        // Flip the pixels
        unsigned int Pitch = Width * 4;
        for (unsigned int y = 0; y < Height / 2; ++y)
            std::swap_ranges(PixelsPtr + y * Pitch, PixelsPtr + (y + 1) * Pitch, PixelsPtr + (Height - y - 1) * Pitch);

        // Create an image from the pixel buffer and return it
        return Image(Width, Height, PixelsPtr);
    }
    else
    {
        return Image(Width, Height, Color::White);
    }
}
开发者ID:fu7mu4,项目名称:entonetics,代码行数:30,代码来源:RenderWindow.cpp


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