这篇教程C++ GLCheck函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GLCheck函数的典型用法代码示例。如果您正苦于以下问题:C++ GLCheck函数的具体用法?C++ GLCheck怎么用?C++ GLCheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GLCheck函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GLCheckvoid 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,
示例2: Assertvoid 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,
示例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,
示例4: send_attributevoid 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,
示例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,
示例6: ImageImage 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,
示例7: Updatebool 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,
示例8: GLCheckvoid 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,
示例9: GLCheckvoid 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,
示例10: assertvoid 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,
示例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,
示例12: GLCheckvoid 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,
示例13: GLCheckRenderImageImplFBO::~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,
示例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,
示例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,
示例16: calculate_ratios_from_viewportvoid Viewport::apply(const RenderTarget& target) { if(type_ != VIEWPORT_TYPE_CUSTOM) { calculate_ratios_from_viewport(type_, x_, y_, width_, height_); } GLCheck(glDisable, GL_SCISSOR_TEST); double x = x_ * target.width(); double y = y_ * target.height(); double width = width_ * target.width(); double height = height_ * target.height(); GLCheck(glEnable, GL_SCISSOR_TEST); GLCheck(glScissor, x, y, width, height); GLCheck(glViewport, x, y, width, height);}
开发者ID:Kazade,项目名称:KGLT,代码行数:16,
示例17: GLCheck void UploaderTextureRect::uploadImage ( TextureMipmapFlag texMipMapFlag, const std::shared_ptr<Image> &image ) { PixelFormat format = (*image)[0].getFormat(); uvec2 dim = (*image)[0].getDimensions(); if( !PixelFormatInfos::getInfos(format).isCompressed() ) GLCheck( glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, dim.x, dim.y, GLEnum::getExternalFormat(format), GLEnum::getType(format), (*image)[0].getPixels() )); else GLCheck( glCompressedTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0 , dim.x, dim.y, GLEnum::getExternalFormat(format), dim.x * dim.y * PixelFormatInfos::getInfos(format).size(), (*image)[0].getPixels())); }
开发者ID:anonreclaimer,项目名称:plastic-dev,代码行数:16,
示例18: EnsureGlContextvoid Texture::SetSmooth(bool smooth){ if (smooth != myIsSmooth) { myIsSmooth = smooth; if (myTexture) { EnsureGlContext(); GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST)); GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST)); } }}
开发者ID:IdeasStorm,项目名称:SFML,代码行数:16,
示例19: EnsureGlContextShader::~Shader(){ EnsureGlContext(); // Destroy effect program if (myShaderProgram) GLCheck(glDeleteObjectARB(myShaderProgram));}
开发者ID:ChrisJansson,项目名称:Graphics,代码行数:8,
示例20: assertvoid 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)) { // Make sure that the current texture binding will be preserved priv::TextureSaver save; // 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; myCacheId = GetUniqueId(); }}
开发者ID:ChrisJansson,项目名称:Graphics,代码行数:17,
示例21: GLCheckvoid Lab::onRender(float dt, float interpolation) { GLCheck(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); m_planeEntity->render(m_camera, m_pointLight, m_ambientLight); m_boxEntity->render(m_camera, m_pointLight, m_ambientLight); glfwSwapBuffers();}
开发者ID:rarosu,项目名称:audio_project,代码行数:8,
示例22: GLCheck/////////////////////////////////////////////////////////////// /see sfDrawable::Render////////////////////////////////////////////////////////////void Sprite::Render(RenderTarget&) const{ // Get the sprite size float Width = static_cast<float>(mySubRect.GetWidth()); float Height = static_cast<float>(mySubRect.GetHeight()); // Check if the image is valid if (myImage && (myImage->GetWidth() > 0) && (myImage->GetHeight() > 0)) { // Use the "offset trick" to get pixel-perfect rendering // see http://www.opengl.org/resources/faq/technical/transformations.htm#tran0030 GLCheck(glTranslatef(0.375f, 0.375f, 0.f)); // Bind the texture myImage->Bind(); // Calculate the texture coordinates FloatRect TexCoords = myImage->GetTexCoords(mySubRect); FloatRect Rect(myIsFlippedX ? TexCoords.Right : TexCoords.Left, myIsFlippedY ? TexCoords.Bottom : TexCoords.Top, myIsFlippedX ? TexCoords.Left : TexCoords.Right, myIsFlippedY ? TexCoords.Top : TexCoords.Bottom); // Draw the sprite's triangles glBegin(GL_QUADS); glTexCoord2f(Rect.Left, Rect.Top); glVertex2f(0, 0); glTexCoord2f(Rect.Left, Rect.Bottom); glVertex2f(0, Height); glTexCoord2f(Rect.Right, Rect.Bottom); glVertex2f(Width, Height); glTexCoord2f(Rect.Right, Rect.Top); glVertex2f(Width, 0) ; glEnd(); } else { // Disable texturing GLCheck(glDisable(GL_TEXTURE_2D)); // Draw the sprite's triangles glBegin(GL_QUADS); glVertex2f(0, 0); glVertex2f(0, Height); glVertex2f(Width, Height); glVertex2f(Width, 0); glEnd(); }}
开发者ID:AwkwardDev,项目名称:MangosFX,代码行数:48,
示例23: glGetHandleARBvoid Shader::SetParameter(const std::string& name, float x, float y, float z, float w){ if (myShaderProgram) { // Enable program GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB); GLCheck(glUseProgramObjectARB(myShaderProgram)); // Get parameter location and assign it new values GLint location = glGetUniformLocationARB(myShaderProgram, name.c_str()); if (location != -1) GLCheck(glUniform4fARB(location, x, y, z, w)); else Err() << "Parameter /"" << name << "/" not found in shader" << std::endl; // Disable program GLCheck(glUseProgramObjectARB(program)); }}
开发者ID:vidjogamer,项目名称:ProjectTemplate,代码行数:19,
注:本文中的GLCheck函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GLES_ActivateRenderer函数代码示例 C++ GLC函数代码示例 |