本文整理汇总了C++中CheckGLError函数的典型用法代码示例。如果您正苦于以下问题:C++ CheckGLError函数的具体用法?C++ CheckGLError怎么用?C++ CheckGLError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckGLError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/**
* Sets an uniform matrix.
* Matrices are always of type float.
* \warning uses glGetError();
* \remark only available if GLSL_ALLOW_IMPLICIT_CASTS is defined.
* \param name - name of the parameter
* \param m - an int array containing up to 16 ints for the matrix. Ints are converted to float before uploading.
* \param bTranspose - if true, the matrix will be transposed before uploading.
* \return void
* \author <a href="mailto:[email protected]">Jens Schneider</a>
* \date Mar.2005
*/
void GLSLProgram::SetUniformMatrix(const char *name,const bool *m, bool bTranspose) const {
assert(m_bEnabled);
CheckGLError();
GLenum iType;
GLint iLocation;
try {
iLocation = get_uniform_vector(name, m_hProgram, &iType);
} catch(tuvok::GLError gl) {
T_ERROR("Error (%d) obtaining uniform %s in '%s' or '%s'.", gl.errno(),
name, m_sVS.c_str(), m_sFS.c_str());
return;
}
float M[16];
switch (iType) {
case GL_FLOAT_MAT2:
for (unsigned int ui=0; ui<4; ui++) M[ui]=(m[ui] ? 1.0f : 0.0f);
glUniformMatrix2fv(iLocation,1,bTranspose,M);
break;
case GL_FLOAT_MAT3:
for (unsigned int ui=0; ui<9; ui++) M[ui]=(m[ui] ? 1.0f : 0.0f);
glUniformMatrix3fv(iLocation,1,bTranspose,M);
break;
case GL_FLOAT_MAT4:
for (unsigned int ui=0; ui<16; ui++) M[ui]=(m[ui] ? 1.0f : 0.0f);
glUniformMatrix4fv(iLocation,1,bTranspose,M);
break;
default:
T_ERROR("Unknown type (%d) for %s.", iType, name);
break;
}
#ifdef GLSL_DEBUG
CheckGLError("SetUniformMatrix(%s,int*,bool)",name);
#endif
}
示例2: UnloadAssets
void Renderer::SetupUi(Ui* pUiPtr)
{
UnloadAssets();
_uiPtr = pUiPtr;
for (UiElement* elem : _uiPtr->GetElements())
{
ProcessElement(elem);
}
if(_menuPtr != nullptr)
ProcessElement(_menuPtr);
CheckGLError();
}
示例3: wxGLContext
LabyrinthGLContext::LabyrinthGLContext(wxGLCanvas *canvas)
: wxGLContext(canvas)
{
SetCurrent(*canvas);
wxRect rect = canvas->GetRect();
m_width = rect.GetWidth();
m_height = rect.GetHeight();
MyInit();
DrawScene();
CheckGLError();
}
示例4: LoadShaders
/**
* Class constructor, loads shaders & gets locations of variables in them
*/
AssimpLoader::AssimpLoader() {
importerPtr = new Assimp::Importer;
scene = NULL;
isObjectLoaded = false;
// shader related setup -- loading, attribute and uniform locations
std::string vertexShader = "shaders/modelTextured.vsh";
std::string fragmentShader = "shaders/modelTextured.fsh";
shaderProgramID = LoadShaders(vertexShader, fragmentShader);
vertexAttribute = GetAttributeLocation(shaderProgramID, "vertexPosition");
vertexUVAttribute = GetAttributeLocation(shaderProgramID, "vertexUV");
mvpLocation = GetUniformLocation(shaderProgramID, "mvpMat");
textureSamplerLocation = GetUniformLocation(shaderProgramID, "textureSampler");
CheckGLError("AssimpLoader::AssimpLoader");
}
示例5: UpdateDynamicElements
/**
* Draw a frame
* @param delta Delta time between the last frame and now
*/
void Renderer::DrawFrame(float pDelta, bool pDisplayMenu)
{
UpdateDynamicElements();
glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT);
glViewport(0, 0, _width, _height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
DrawUi(pDelta);
if (pDisplayMenu && _menuPtr != nullptr)
DrawMenu(pDelta);
CheckGLError();
}
示例6: glClear
void Scene::DrawScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
camera.SetUpCamera();
for( Object *obj : sceneObjs )
obj->Draw();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
CheckGLError();
}
示例7: wxGLContext
AppGLContext::AppGLContext(wxGLCanvas *canvas)
: wxGLContext(canvas),
mainFrame(NULL),
seabed(NULL),
dolphin(NULL),
aquaSurf(NULL),
sky(NULL)
{
SetCurrent(*canvas);
GLenum err = glewInit();
if( GLEW_OK != err )
{
wxLogError("Can't initialize GLEW! Error: %s", glewGetErrorString(err));
}
glsl120fallback = false;
fpsCount = 0;
initShaders();
seabed = new CMesh();
seabed->Create("seabed.obj");
seabed->setGLSLProgram(&prog);
dolphin = new CMesh();
dolphin->Create("Dolphin.obj");
dolphin->setGLSLProgram(&prog);
dolphinWorld = mat4(1.0f);
aquaSurf = new AquaSurface("aqua.jpg", "aqua_nrm.png", 4.0f, 80);
sky = new SkyBox();
sky->loadCubeMap("texture/pos_x.jpg",
"texture/neg_x.jpg",
"texture/pos_y.jpg",
"texture/neg_y.jpg",
"texture/pos_z.jpg",
"texture/neg_z.jpg");
sky->buildEffect("cubemap");
//Initialize light data
lightPos = glm::vec4(0.0f, 1.0f, 0.0f, 1.0f);
CheckGLError();
}
示例8: SetViewport
void DaydreamRenderer::DrawFrame(JNIEnv &env) {
// use the scratch list to get the recommended viewports
scratch_viewport_list_->SetToRecommendedBufferViewports();
// construct FBO backed viewports
gvr::BufferViewport fbo_viewport = gvr_api_->CreateBufferViewport();
scratch_viewport_list_->GetBufferViewport(0, &scratch_viewport_);
fbo_viewport.SetSourceBufferIndex(0);
fbo_viewport.SetSourceFov(scratch_viewport_.GetSourceFov());
fbo_viewport.SetReprojection(scratch_viewport_.GetReprojection());
fbo_viewport.SetSourceUv(kDefaultUV);
fbo_viewport.SetTargetEye(GVR_LEFT_EYE);
viewport_list_->SetBufferViewport(0, fbo_viewport);
scratch_viewport_list_->GetBufferViewport(1, &scratch_viewport_);
fbo_viewport.SetSourceBufferIndex(1);
fbo_viewport.SetSourceFov(scratch_viewport_.GetSourceFov());
fbo_viewport.SetReprojection(scratch_viewport_.GetReprojection());
fbo_viewport.SetSourceUv(kDefaultUV);
fbo_viewport.SetTargetEye(GVR_RIGHT_EYE);
viewport_list_->SetBufferViewport(1, fbo_viewport);
gvr::Frame frame = swapchain_->AcquireFrame();
gvr::ClockTimePoint target_time = gvr::GvrApi::GetTimePointNow();
target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos;
head_view_ = gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time);
cameraRig_->getHeadTransform()->setModelMatrix(MatrixToGLMMatrix(head_view_));
// Render the eye images.
for (int eye = 0; eye < 2; eye++) {
frame.BindBuffer(eye);
viewport_list_->GetBufferViewport(eye, &scratch_viewport_);
SetViewport(scratch_viewport_);
env.CallVoidMethod(rendererObject_, onDrawEyeMethodId_, eye);
frame.Unbind();
}
// Submit frame.
frame.Submit(*viewport_list_, head_view_);
CheckGLError("onDrawFrame");
}
示例9: glUseProgram
/**
* Renders the 3D model by rendering every mesh in the object
*/
void AssimpLoader::Render3DModel(glm::mat4 *mvpMat) {
if (!isObjectLoaded) {
return;
}
glUseProgram(shaderProgramID);
glUniformMatrix4fv(mvpLocation, 1, GL_FALSE, (const GLfloat *) mvpMat);
glActiveTexture(GL_TEXTURE0);
glUniform1i(textureSamplerLocation, 0);
unsigned int numberOfLoadedMeshes = modelMeshes.size();
// render all meshes
for (unsigned int n = 0; n < numberOfLoadedMeshes; ++n) {
// Texture
if (modelMeshes[n].textureIndex) {
glBindTexture( GL_TEXTURE_2D, modelMeshes[n].textureIndex);
}
// Faces
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelMeshes[n].faceBuffer);
// Vertices
glBindBuffer(GL_ARRAY_BUFFER, modelMeshes[n].vertexBuffer);
glEnableVertexAttribArray(vertexAttribute);
glVertexAttribPointer(vertexAttribute, 3, GL_FLOAT, 0, 0, 0);
// Texture coords
glBindBuffer(GL_ARRAY_BUFFER, modelMeshes[n].textureCoordBuffer);
glEnableVertexAttribArray(vertexUVAttribute);
glVertexAttribPointer(vertexUVAttribute, 2, GL_FLOAT, 0, 0, 0);
glDrawElements(GL_TRIANGLES, modelMeshes[n].numberOfFaces * 3, GL_UNSIGNED_INT, 0);
// unbind buffers
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
CheckGLError("AssimpLoader::renderObject() ");
}
示例10: glClear
void GLMainContext::DrawScene()
{
glClear(GL_COLOR_BUFFER_BIT);
// Draw the grass
int xPos=0, yPos=0;
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 6; j++)
{
xPos = i * 256/2 - 128;
if (i%2)
yPos = (j * 128) - 128/2;
else
yPos = (j * 128);
m_pGrassImg->BlitImage(xPos, yPos);
}
}
// Draw some trees
m_pTreesImg[0]->BlitImage(15,25);
m_pTreesImg[1]->BlitImage(695,55);
m_pTreesImg[2]->BlitImage(15,25);
m_pTreesImg[3]->BlitImage(300,400);
m_pTreesImg[4]->BlitImage(125,75);
m_pTreesImg[5]->BlitImage(350,250);
m_pTreesImg[6]->BlitImage(400,350);
m_pTreesImg[7]->BlitImage(350,105);
m_pTreesImg[8]->BlitImage(530,76);
m_pTreesImg[9]->BlitImage(125,450);
m_pTreesImg[10]->BlitImage(425,390);
m_pTreesImg[11]->BlitImage(25,125);
m_pTreesImg[12]->BlitImage(550,365);
m_pTreesImg[13]->BlitImage(680,250);
m_pTreesImg[14]->BlitImage(245,325);
m_pTreesImg[15]->BlitImage(300,245);
// Draw the knight
m_pKnightSprite->DrawSprite();
// Move to the next frame of the animation
m_pKnightSprite->NextFrame();
glFlush();
CheckGLError();
}
示例11: MyGLInits
/**
* Perform inits and load the triangle's vertices/colors to GLES
*/
void Triangle::PerformGLInits() {
MyGLInits();
//specify 3 vertices of the triangle
static const GLfloat vertexBufferData[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f
};
// Generate a vertex buffer and load the vertices into it
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexBufferData), vertexBufferData, GL_DYNAMIC_DRAW);
//specify colors of the 3 vertices
static const GLfloat colorBufferData[] = {
0.0f, 1.0f, 0.0f, //green
0.0f, 1.0f, 0.0f, //green
0.0f, 0.0f, 1.0f //blue
};
// Generate a vertex buffer and load the colors into it
glGenBuffers(1, &colorBuffer);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(colorBufferData), colorBufferData, GL_STATIC_DRAW);
// shader related setup
std::string vertexShader = "shaders/colorTriangle.vsh";
std::string fragmentShader = "shaders/colorTriangle.fsh";
// compile the vertex and fragment shaders, and link them together
shaderProgramID = LoadShaders(vertexShader, fragmentShader);
// fetch the locations of "vertexPosition" and "vertexColor" from the shader
vertexAttribute = GetAttributeLocation(shaderProgramID, "vertexPosition");
colorAttribute = GetAttributeLocation(shaderProgramID, "vertexColor");
// set parameters that control animation of the triangle
triangleVertexDelta = 0;
triangleSwapRate = 0.01; // increase this to speedup the animation
CheckGLError("Triangle::PerformGLInits");
initsDone = true;
}
示例12: fns
void Image::Load(const std::wstring& fn)
{
texture = std::make_shared<Texture>();
std::string fns(fn.begin(), fn.end());
unsigned char* data = stbi_load(fns.c_str(), &w, &h, &channels, STBI_default);
Bind bind(*this);
if (channels==4)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
else if (channels == 3)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
else
assert(false && "Unsupported image format");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_MAX_LEVEL, 0);
CheckGLError();
stbi_image_free(data);
}
示例13: MultisampleBuffer
MultisampleBuffer(GLsizei bufferWidth, GLsizei bufferHeight) {
maxSize = 0;
// Query the maximum size
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxSize);
printf("Maximum reported renderbuffer size is: %d\n", maxSize);
// Gen buffers
glGenFramebuffers(1, &fbo);
glGenTextures(1, &colorBuffer);
glGenFramebuffers(1, &multisampleFBO);
glGenRenderbuffers(1, &multisampleColorBuffer);
glGenRenderbuffers(1, &multisampleDepthBuffer);
// Setup Standard FBO
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glBindTexture(GL_TEXTURE_2D, colorBuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bufferWidth, bufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBuffer, 0);
// Setup Multisample FBO
glBindFramebuffer(GL_FRAMEBUFFER, multisampleFBO);
glBindRenderbuffer(GL_RENDERBUFFER, multisampleColorBuffer);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_RGBA, bufferWidth, bufferHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, multisampleColorBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, multisampleDepthBuffer);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_DEPTH_COMPONENT24, bufferWidth, bufferHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, multisampleDepthBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
width = bufferWidth;
height = bufferHeight;
CheckGLError("MultisampleBuffer created");
}
示例14: glGetIntegerv
void VideoEngine::MakeScreenshot(const std::string &filename)
{
private_video::ImageMemory buffer;
// Retrieve the width and height of the viewport.
GLint viewport_dimensions[4]; // viewport_dimensions[2] is the width, [3] is the height
glGetIntegerv(GL_VIEWPORT, viewport_dimensions);
// Buffer to store the image before it is flipped
buffer.width = viewport_dimensions[2];
buffer.height = viewport_dimensions[3];
buffer.pixels = malloc(buffer.width * buffer.height * 3);
buffer.rgb_format = true;
// Read the viewport pixel data
glReadPixels(viewport_dimensions[0], viewport_dimensions[1],
buffer.width, buffer.height, GL_RGB, GL_UNSIGNED_BYTE, buffer.pixels);
if(CheckGLError() == true) {
IF_PRINT_WARNING(VIDEO_DEBUG) << "an OpenGL error occured: " << CreateGLErrorString() << std::endl;
free(buffer.pixels);
buffer.pixels = NULL;
return;
}
// Vertically flip the image, then swap the flipped and original images
void *buffer_temp = malloc(buffer.width * buffer.height * 3);
for(uint32 i = 0; i < buffer.height; ++i) {
memcpy((uint8 *)buffer_temp + i * buffer.width * 3,
(uint8 *)buffer.pixels + (buffer.height - i - 1) * buffer.width * 3, buffer.width * 3);
}
void *temp = buffer.pixels;
buffer.pixels = buffer_temp;
buffer_temp = temp;
buffer.SaveImage(filename);
free(buffer_temp);
free(buffer.pixels);
buffer.pixels = NULL;
}
示例15: sprintf
void AppGLContext::render()
{
//calc fps & update status bar
fpsTimer.AdvanceTime();
fpsCount++;
if(fpsTimer.GetElapsedTime()>1)
{
if( mainFrame )
{
char tempBuf[512];
sprintf(tempBuf,"FPS: %d",fpsCount);
mainFrame->getStatusBar()->SetStatusText(tempBuf);
}
fpsTimer.Reset();
fpsCount=0;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if( seabed )
{
seabed->Render();
}
if( dolphin )
{
dolphin->Render();
}
if( aquaSurf )
{
aquaSurf->render();
}
if( sky )
{
sky->render();
}
CheckGLError();
}