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


C++ CHECK_GL_ERROR函数代码示例

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


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

示例1: glStencilFunc

//applying the light at the "stencil-approved" areas
void DefRenderer::LightPass(Camera *cam, Renderer *r)
{
	//setting to pass the stencil test when != 0
	glStencilFunc(GL_NOTEQUAL, 0, 0xFF);

	//writing only on top of the colors from geometry pass
	glDrawBuffer(GL_COLOR_ATTACHMENT0);
	
	glDisable(GL_DEPTH_TEST);
	
	//using additive blending to mix the light and scene fragments
	glEnable(GL_BLEND);
	glBlendFunc(GL_ONE, GL_ONE);

	//try to render from the back to preserve depth information
	glEnable(GL_CULL_FACE);
	glCullFace(GL_FRONT);

	r->Ready();
	mat4 model = r->GetParentGO()->GetModelMatrix();
	mat4 mvp = cam->Get() * model;
	r->GetProgram()->SetUniform("Model", value_ptr(model));
	r->GetProgram()->SetUniform("MVP", value_ptr(mvp));
	vec4 deviceCenter = vec4(mvp * vec4(0, 0, 0, 1)); //center in device coords
	vec3 center(deviceCenter.x, deviceCenter.y, deviceCenter.z);
	r->GetProgram()->SetUniform("Center", &center);
	Light *l = r->GetParentGO()->GetLight();
	float intensity = l->GetIntensity();
	r->GetProgram()->SetUniform("Intensity", &intensity);
	vec4 color = l->GetColor();
	r->GetProgram()->SetUniform("Color", &color);
	r->Render();

	glCullFace(GL_BACK);

	glDisable(GL_BLEND);
	CHECK_GL_ERROR();
}
开发者ID:Dwarfius,项目名称:GP2,代码行数:39,代码来源:DefRenderer.cpp

示例2: ResourceManager

void Game::LoadResources()
{
	resourceManager = new ResourceManager();
	currentScene = new Scene(resourceManager);
	sceneManager = new SceneManager(resourceManager);

	DefRenderer::Init();
	PostProcessing::Init();
	CHECK_GL_ERROR();

	//======================== TEXTURES ========================
	//HIDE THIS AWAY IN TO SCENE MANAGER LOADER AT SOME POINT!
	Texture* skyTexture = new Texture(TEXTURE_PATH + "right.jpg", TEXTURE_PATH + "left.jpg", TEXTURE_PATH + "top.jpg", TEXTURE_PATH + "bottom.jpg", TEXTURE_PATH + "back.jpg", TEXTURE_PATH + "front.jpg");
	resourceManager->AddTexture("skyTexture", skyTexture);
	Texture* skyNightTexture = new Texture(TEXTURE_PATH + "night_right.jpg", TEXTURE_PATH + "night_left.jpg", TEXTURE_PATH + "night_top.jpg", TEXTURE_PATH + "night_bottom.jpg", TEXTURE_PATH + "night_back.jpg", TEXTURE_PATH + "night_front.jpg");
	resourceManager->AddTexture("skyNightTexture", skyNightTexture);

	//========================  MODELS  ========================
	Model *terrainModel = new Model();
	terrainModel->SetUpAttrib(0, 3, GL_FLOAT, 0); //pos
	terrainModel->SetUpAttrib(1, 4, GL_FLOAT, sizeof(vec3)); //coeffs
	terrainModel->SetUpAttrib(2, 2, GL_FLOAT, sizeof(vec3) + sizeof(vec4)); //uv
	terrainModel->SetUpAttrib(3, 3, GL_FLOAT, sizeof(vec3) + sizeof(vec4) + sizeof(vec2)); //normals
	resourceManager->AddModel("Terrain", terrainModel);

	Model *skyModel = new Model();
	vector<Vertex> *verts = new vector<Vertex>(skyBoxverts);
	vector<int> *indcs = new vector<int>(skyBoxIndices);
	skyModel->SetVertices(verts, GL_STATIC_DRAW, true);
	skyModel->SetIndices(indcs, GL_STATIC_DRAW, true);
	skyModel->FlushBuffers();
	skyModel->SetUpAttrib(0, 3, GL_FLOAT, 0);
	resourceManager->AddModel("skyModel", skyModel);

	//======================== SCENEMANAGEMENT  ====================
	sceneManager->LoadSceneDirectories();
	sceneManager->LoadScene(0, currentScene);
}
开发者ID:Dwarfius,项目名称:GP2,代码行数:38,代码来源:Game.cpp

示例3: glClearColor

void ComputeBasicGLSL::drawImage(GLuint texture)
{
    float const vertexPosition[] = {
        m_aspectRatio, -1.0f,
        -m_aspectRatio, -1.0f,
        m_aspectRatio, 1.0f,
        -m_aspectRatio, 1.0f
    };

    float const textureCoord[] = {
        1.0f, 0.0f,
        0.0f, 0.0f,
        1.0f, 1.0f,
        0.0f, 1.0f
    };

    glClearColor(0.2f, 0.0f, 0.2f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glUseProgram(m_blitProg->getProgram());

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture);

    glUniform1i(m_blitProg->getUniformLocation("uSourceTex"), 0);
    int aPosCoord = m_blitProg->getAttribLocation("aPosition");
    int aTexCoord = m_blitProg->getAttribLocation("aTexCoord");

    glVertexAttribPointer(aPosCoord, 2, GL_FLOAT, GL_FALSE, 0, vertexPosition);
    glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, textureCoord);
    glEnableVertexAttribArray(aPosCoord);
    glEnableVertexAttribArray(aTexCoord);

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    CHECK_GL_ERROR();

}
开发者ID:yangshuang-developer,项目名称:OpenGLSamples,代码行数:38,代码来源:ComputeBasicGLSL.cpp

示例4: MotionBlurShader

    MotionBlurShader(void) :
        BaseProjNormalShader("shaders/motionblur.vert",
                             "shaders/motionblur.frag"),
        viewMatUHandle(-1),
        currentModelMatUHandle(-1),
        previousModelMatUHandle(-1),
        stretchScaleUHandle(-1),
        colorTexUHandle(-1)
    {
        // uniforms
        viewMatUHandle =
            getUniformLocation("u_mViewMat");
        currentModelMatUHandle =
            getUniformLocation("u_mCurrentModelMat");
        previousModelMatUHandle =
            getUniformLocation("u_mPreviousModelMat");
        stretchScaleUHandle =
            getUniformLocation("u_fStretchScale");
        colorTexUHandle =
            getUniformLocation("u_tColorTex");

        CHECK_GL_ERROR();
    }
开发者ID:Ninglin,项目名称:OpenGLSamples,代码行数:23,代码来源:MotionBlur.cpp

示例5: printGLString

void CascadedShadowMapping::initRendering(void) {
    printGLString("Version", GL_VERSION);
    printGLString("Vendor", GL_VENDOR);
    printGLString("Renderer", GL_RENDERER);
    printGLString("Extensions", GL_EXTENSIONS);

    GLint depthBits;
    glGetIntegerv(GL_DEPTH_BITS, &depthBits);
    LOGI("depth bits = %d\n", depthBits);

    if (!requireMinAPIVersion(NvGfxAPIVersionGL4_3()))
        return;

    if (!requireExtension("GL_NV_viewport_array2"))
        return;

    if (!requireExtension("GL_NV_geometry_shader_passthrough"))
        return;

    m_renderer->initRendering();

    CHECK_GL_ERROR();
}
开发者ID:151706061,项目名称:OpenGLSamples,代码行数:23,代码来源:CascadedShadowMapping.cpp

示例6: glViewport

void Mercury::reshape(int32_t width, int32_t height)
{
    glViewport( 0, 0, (GLint) width, (GLint) height );

	// Rescale FBO and RBO as well
	glBindTexture(GL_TEXTURE_2D, gbuffer_tex[0]);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT, NULL);
	glBindTexture(GL_TEXTURE_2D, 0);

	glBindTexture(GL_TEXTURE_2D, gbuffer_tex[1]);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT, NULL);
	glBindTexture(GL_TEXTURE_2D, 0);

	glBindTexture(GL_TEXTURE_2D, gbuffer_tex[2]);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT, NULL);
	glBindTexture(GL_TEXTURE_2D, 0);

	glBindRenderbuffer(GL_RENDERBUFFER, rbo_depth);
	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
	glBindRenderbuffer(GL_RENDERBUFFER, 0);
	
    CHECK_GL_ERROR();
}
开发者ID:1753592,项目名称:GraphicsSamples,代码行数:23,代码来源:Mercury.cpp

示例7: glClearColor

void OptimizationApp::initRendering(void) {
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);

    NvAssetLoaderAddSearchPath("es2-aurora/OptimizationApp");

#ifdef GL_OES_texture_3D
    if (requireExtension("GL_EXT_framebuffer_blit", false)) {
        glBlitFramebufferFunc = (void (KHRONOS_APIENTRY *) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter))
                                getGLContext()->getGLProcAddress("glBlitFramebufferEXT");
    } else if (getGLContext()->getConfiguration().apiVer != NvGfxAPIVersionES2()) {
        glBlitFramebufferFunc = (void (KHRONOS_APIENTRY *) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter))
                                getGLContext()->getGLProcAddress("glBlitFramebuffer");
    } else {
        glBlitFramebufferFunc = NULL;
    }
#else
    glBlitFramebufferFunc = glBlitFramebuffer;
#endif

    if (getGLContext()->getConfiguration().apiVer == NvGfxAPIVersionES2()) {
        gFloatTypeEnum = 0x8D61; // GL_HALF_FLOAT_OES, not declared in GL
        gLumaTypeEnum = GL_LUMINANCE;
    } else {
        gFloatTypeEnum = GL_FLOAT;
        gLumaTypeEnum = 0x1903; // GL_RED, not declared in ES
    }

    m_sceneRenderer = new SceneRenderer(
        getGLContext()->getConfiguration().apiVer == NvGfxAPIVersionES2());
    CHECK_GL_ERROR();

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glClearColor(0.0, 0.0, 1.0, 1.0);
}
开发者ID:yangshuang-developer,项目名称:OpenGLSamples,代码行数:36,代码来源:OptimizationApp.cpp

示例8: glCreateShaderProgramv

GLuint ParticleSystem::createShaderPipelineProgram(GLuint target, const char* src)
{
    GLuint object;
    GLint status;

    const GLchar* fullSrc[2] = { m_shaderPrefix, src };
    object = glCreateShaderProgramv( target, 2, fullSrc);

    {
        GLint logLength;
        glGetProgramiv(object, GL_INFO_LOG_LENGTH, &logLength);
        char *log = new char [logLength];
        glGetProgramInfoLog(object, logLength, 0, log);
        LOGI("Shader pipeline program not valid:\n%s\n", log);
        delete [] log;
    }

    glBindProgramPipeline(m_programPipeline);
    glUseProgramStages(m_programPipeline, GL_COMPUTE_SHADER_BIT, object);
    glValidateProgramPipeline(m_programPipeline);
    glGetProgramPipelineiv(m_programPipeline, GL_VALIDATE_STATUS, &status);

    if (status != GL_TRUE) {
        GLint logLength;
        glGetProgramPipelineiv(m_programPipeline, GL_INFO_LOG_LENGTH, &logLength);
        char *log = new char [logLength];
        glGetProgramPipelineInfoLog(m_programPipeline, logLength, 0, log);
        LOGI("Shader pipeline not valid:\n%s\n", log);
        delete [] log;
    }

    glBindProgramPipeline(0);
    CHECK_GL_ERROR();

    return object;
}
开发者ID:1753592,项目名称:GraphicsSamples,代码行数:36,代码来源:ParticleSystem.cpp

示例9: nextHigher2

void GLTexture::allocBuffer(GLuint w, GLuint h) {
	_realWidth = w;
	_realHeight = h;

	if (!_refresh) {
		if (npot_supported && _filter == GL_LINEAR) {
			// Check if we already allocated a correctly-sized buffer
			// This is so we don't need to duplicate the last row/column
			if (w == _textureWidth && h == _textureHeight)
				return;
		} else {
			// Check if we already have a large enough buffer
			if (w <= _textureWidth && h <= _textureHeight)
				return;
		}
	}

	if (npot_supported) {
		_textureWidth = w;
		_textureHeight = h;
	} else {
		_textureWidth = nextHigher2(w);
		_textureHeight = nextHigher2(h);
	}

	// Select this OpenGL texture
	glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR();

	// Set the texture parameters
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _filter); CHECK_GL_ERROR();
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _filter); CHECK_GL_ERROR();
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); CHECK_GL_ERROR();
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); CHECK_GL_ERROR();

	// Allocate room for the texture
	glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat,
	             _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL); CHECK_GL_ERROR();

	_refresh = false;
}
开发者ID:CatalystG,项目名称:scummvm,代码行数:40,代码来源:gltexture.cpp

示例10: bind_texture

static void bind_texture(texture_asset* texture) {
	Assert(texture->resource_handle != 0);
	glBindTexture(GL_TEXTURE_2D, texture->resource_handle);
	CHECK_GL_ERROR();
	current_texture_asset = texture->handle;
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:6,代码来源:opengl.cpp

示例11: create_texture

static uint32 create_texture() {
	uint32 id = 0;
	glGenTextures(1, &id);
	CHECK_GL_ERROR();
	return id;
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:6,代码来源:opengl.cpp

示例12: set_uniform_int

static void set_uniform_int(int32 location, int32 value) {
	glUniform1i(location, value);
	CHECK_GL_ERROR();
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:4,代码来源:opengl.cpp

示例13: set_uniform_matrix4

static void set_uniform_matrix4(int32 location, const glm::mat4& matrix) {
	glUniformMatrix4fv(location, 1, false, glm::value_ptr(matrix));
	CHECK_GL_ERROR();
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:4,代码来源:opengl.cpp

示例14: set_vertex_attribute

static void set_vertex_attribute(vertex_attribute index, int components, int stride, void* pointer) {
	glVertexAttribPointer((GLuint) index, components, GL_FLOAT, GL_FALSE, stride, pointer);
	CHECK_GL_ERROR();
	glEnableVertexAttribArray((GLuint) index);
	CHECK_GL_ERROR();
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:6,代码来源:opengl.cpp

示例15: draw_vertex_array

static void draw_vertex_array(gl_vertex_array* vertex_array) {
	glDrawElements(vertex_array->mode, vertex_array->index_count, GL_UNSIGNED_INT, vertex_array->index_buffer.memory);
	CHECK_GL_ERROR();
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:4,代码来源:opengl.cpp


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