本文整理汇总了C++中CHECK_GL_ERRORS函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_GL_ERRORS函数的具体用法?C++ CHECK_GL_ERRORS怎么用?C++ CHECK_GL_ERRORS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHECK_GL_ERRORS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_ingame_interface
void draw_ingame_interface()
{
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
#ifdef OLD_CLOSE_BAG
// watch for closing a bag
if(ground_items_win >= 0)
{
int old_view= view_ground_items;
view_ground_items= get_show_window(ground_items_win);
// watch for telling the server we need to close the bag
if(old_view && !view_ground_items)
{
unsigned char protocol_name;
protocol_name= S_CLOSE_BAG;
my_tcp_send(my_socket,&protocol_name,1);
}
}
#endif //OLD_CLOSE_BAG
glColor3f(1.0f, 1.0f, 1.0f);
draw_hud_frame();
//draw_hud_interface();
display_spells_we_have();
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
}
示例2: Enter2DModeExtended
void Enter2DModeExtended(int width, int height)
{
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
if (use_fog) glDisable(GL_FOG);
glPushAttrib(GL_LIGHTING_BIT|GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, width, height);
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, (GLdouble)width, (GLdouble)height, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
}
示例3: _alpha
texture_t::texture_t(aasset_buffer_t& buffer)
: _alpha(false)
{
raw_bitmap_t bitmap;
png_load_from_memory(buffer, &bitmap);
//Now generate the OpenGL texture object
glGenTextures(1, &_id);
glBindTexture(GL_TEXTURE_2D, _id);
CHECK_GL_ERRORS("Error texture bind");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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);
CHECK_GL_ERRORS("Error texture parameter setting");
glTexImage2D(GL_TEXTURE_2D, 0, bitmap.format(), bitmap.width(), bitmap.height(), 0, bitmap.format(),
GL_UNSIGNED_BYTE, (GLvoid*) bitmap.data());
CHECK_GL_ERRORS("Error texture createing");
glBindTexture(GL_TEXTURE_2D, 0);
CHECK_GL_ERRORS("Couldn't load texture");
if (bitmap.alpha()) _alpha = true;
}
示例4: glGenTextures
TextureFBO::TextureFBO(unsigned int width, unsigned int height, int targets, bool storeDepth, int format) {
this->width = width;
this->height = height;
texture.resize(targets);
// Initialize Texture
glGenTextures(targets, &texture[0]);
for (size_t i = 0; i < targets; i++) {
glBindTexture(GL_TEXTURE_2D, texture[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, GL_FLOAT, NULL);
}
if(!storeDepth){
//Create depth bufferGLuint rboId;
glGenRenderbuffers(1, &depth);
glBindRenderbuffer(GL_RENDERBUFFER_EXT, depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}else{
glGenTextures(1, &depth);
glBindTexture(GL_TEXTURE_2D, depth);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
}
CHECK_GL_ERRORS();
// Create FBO and attach buffers
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
std::vector<GLenum> attachments;
for (uint i = 0; i < targets; i++) {
attachments.push_back(GL_COLOR_ATTACHMENT0+i);
glFramebufferTexture2D(GL_FRAMEBUFFER, attachments[i], GL_TEXTURE_2D, texture[i], 0);
}
glDrawBuffers(targets, attachments.data());
if (!storeDepth) {
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
}else{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth, 0);
}
CHECK_GL_ERRORS();
CHECK_GL_FBO_COMPLETENESS();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
示例5: draw_string_zoomed_width
int draw_string_zoomed_width (int x, int y, const unsigned char * our_string, int max_width, int max_lines, float text_zoom)
{
float displayed_font_x_size= DEFAULT_FONT_X_LEN*text_zoom;
float displayed_font_y_size= DEFAULT_FONT_Y_LEN*text_zoom;
unsigned char cur_char;
int i;
int cur_x,cur_y;
int current_lines= 1;
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
glEnable(GL_ALPHA_TEST);//enable alpha filtering, so we have some alpha key
glAlphaFunc(GL_GREATER,0.1f);
bind_texture(font_text);
i=0;
cur_x=x;
cur_y=y;
glBegin(GL_QUADS);
while(1)
{
cur_char=our_string[i];
// watch for special characters
if(!cur_char) // end of line
{
break;
}
else if (cur_char == '\n' || cur_char == '\r') // newline
{
cur_y+=displayed_font_y_size;
cur_x=x;
i++;
current_lines++;
if(current_lines>max_lines)break;
continue;
}
else if (cur_x+displayed_font_x_size-x>=max_width){
cur_y+=displayed_font_y_size;
cur_x=x;
current_lines++;
if(current_lines>max_lines)break;
}
cur_x+=draw_char_scaled(cur_char, cur_x, cur_y, displayed_font_x_size, displayed_font_y_size);
i++;
}
glEnd();
glDisable(GL_ALPHA_TEST);
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
return current_lines;
}
示例6: draw_scene
void draw_scene()
{
CHECK_GL_ERRORS();
glClearColor(skybox_fog_color[0], skybox_fog_color[1], skybox_fog_color[2], 0.0);
if(!shadows_on || !have_stencil)glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
else glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
if (!have_display)
{
new_zoom_level = zoom_level; // No scrolling when switching modes...
if (quickbar_relocatable && quickbar_win >= 0) // Hack
{
if (get_show_window (quickbar_win) && windows_list.window[quickbar_win].cur_x < window_width - hud_x && window_height - windows_list.window[quickbar_win].cur_y > hud_y)
hide_window (quickbar_win);
}
}
glLoadIdentity (); // Reset The Matrix
Enter2DMode ();
display_windows (1);
// Have to draw the dragged item *after* all windows
glColor3f(1.0f,1.0f,1.0f);
if (item_dragged != -1)
drag_item (item_dragged, 0, 0);
else if (use_item != -1 && current_cursor == CURSOR_USE_WITEM)
drag_item (use_item, 0, 1);
else if (storage_item_dragged != -1)
drag_item (storage_item_dragged, 1, 0);
draw_special_cursors();
Leave2DMode ();
if(elwin_mouse >= 0)
{
if (current_cursor != elwin_mouse) change_cursor(elwin_mouse);
elwin_mouse = -1;
}
SDL_GL_SwapBuffers();
CHECK_GL_ERRORS();
/* start or stop the harvesting effect depending on harvesting state */
check_harvesting_effect();
if (draw_delay > 0)
{
SDL_Delay (draw_delay);
draw_delay = 0;
}
}
示例7: draw_string_small
void draw_string_small(int x, int y,const unsigned char * our_string,int max_lines)
{
//int displayed_font_x_size=SMALL_FONT_X_LEN;
//int displayed_font_y_size=SMALL_FONT_Y_LEN;
unsigned char cur_char;
int i;
int cur_x,cur_y;
int current_lines=0;
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
glEnable(GL_ALPHA_TEST);//enable alpha filtering, so we have some alpha key
glAlphaFunc(GL_GREATER,0.1f);
#ifdef NEW_TEXTURES
bind_texture(font_text);
#else /* NEW_TEXTURES */
get_and_set_texture_id(font_text);
#endif /* NEW_TEXTURES */
i=0;
cur_x=x;
cur_y=y;
glBegin(GL_QUADS);
while(1)
{
cur_char=our_string[i];
if(!cur_char)
{
break;
}
else if(cur_char=='\n')
{
cur_y+=SMALL_FONT_Y_LEN;
cur_x=x;
i++;
current_lines++;
if(current_lines>=max_lines)break;
continue;
}
cur_x+=draw_char_scaled(cur_char, cur_x, cur_y, SMALL_FONT_X_LEN, SMALL_FONT_Y_LEN);
i++;
}
glEnd();
glDisable(GL_ALPHA_TEST);
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
}
示例8: glViewport
void AppManager::runKernel(double dt){
kernel1->bind();
glViewport(0, 0, Nx, Ny);
lax_f->use();
float rx = (float)dt/(1.0f/(float)Nx);
float ry = (float)dt/(1.0f/(float)Ny);
//set uniforms
glUniform1f(lax_f->getUniform("rx"), rx);
glUniform1f(lax_f->getUniform("ry"), ry);
glUniform1f(lax_f->getUniform("gamma"), gamma);
glUniform1i(lax_f->getUniform("QTex"), 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, kernel0->getTexture());
glBindVertexArray(vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, NULL);
glBindVertexArray(0);
lax_f->disuse();
kernel1->unbind();
// Flip kernels for next iteration
TextureFBO* temp = kernel0;
kernel0 = kernel1;
kernel1 = temp;
CHECK_GL_ERRORS();
/* DOWNLOAD RESULTS */
glBindTexture(GL_TEXTURE_2D, kernel0->getTexture());
std::vector<GLfloat> data(Nx*Ny*4);
glGetTexImage(GL_TEXTURE_2D,0,GL_RGBA,GL_FLOAT,&data[0]);
glBindTexture(GL_TEXTURE_2D, 0);
float max = 0.0;
for (size_t x = 0; x < Nx; x++) {
for (size_t y = 0; y < Ny; y++) {
max = glm::max(max,data[(Nx * y + x)*4]);
}
}
std::cout << max << std::endl;
/* DOWNLOAD END */
CHECK_GL_ERRORS();
}
示例9: compileShader
GLuint compileShader(const char *shaderFilename, ShaderType shaderType) {
GLchar *shaderSource;
GLuint shader;
shaderSource = fileToCharArray(shaderFilename);
switch (shaderType) {
case ShaderTypeVertex:
shader = glCreateShader(GL_VERTEX_SHADER);
break;
case ShaderTypeFragment:
shader = glCreateShader(GL_FRAGMENT_SHADER);
break;
case ShaderTypeGeometry:
shader = glCreateShader(GL_GEOMETRY_SHADER);
break;
default:
return 0;
}
CHECK_GL_ERRORS();
glShaderSource(shader, 1, (const GLchar**)&shaderSource, 0);
CHECK_GL_ERRORS();
glCompileShader(shader);
CHECK_GL_ERRORS();
free(shaderSource);
int isShaderCompiled;
glGetShaderiv(shader, GL_COMPILE_STATUS, &isShaderCompiled);
if (isShaderCompiled == FALSE) {
int maxLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
char *infoLog = (char *)malloc(maxLength);
glGetShaderInfoLog(shader, maxLength, &maxLength, infoLog);
printf("Error compiling shader: %s\n", shaderFilename);
printf("Error: %s\n", infoLog);
free(infoLog);
return 0;
}
return shader;
}
示例10: glEnable
void OpenGL3RenderState::set_scissor(OpenGL3ContextState& state, const ScissorDesc& scissor_desc) const
{
if (state.scissor_test == scissor_desc.enabled && state.scissor == scissor_desc.scissor_rect)
return;
if (scissor_desc.enabled)
glEnable(GL_SCISSOR_TEST);
else
glDisable(GL_SCISSOR_TEST);
CHECK_GL_ERRORS();
glScissor(scissor_desc.scissor_rect.ll().x(), scissor_desc.scissor_rect.ll().y(),
scissor_desc.scissor_rect.width(), scissor_desc.scissor_rect.height());
CHECK_GL_ERRORS();
state.scissor = scissor_desc.scissor_rect;
state.scissor_test = scissor_desc.enabled;
}
示例11: reload_fonts
void reload_fonts()
{
int i;
int poor_man_save=poor_man;
int use_mipmaps_save=use_mipmaps;
poor_man=0;
use_mipmaps=0;
for(i=0;i < FONTS_ARRAY_SIZE; i++){
if(fonts[i] != NULL){
if(fonts[i]->texture_id>=0){
glDeleteTextures(1, (GLuint*)&texture_cache[fonts[i]->texture_id].texture_id);
texture_cache[fonts[i]->texture_id].texture_id=0;
get_texture_id(fonts[i]->texture_id);
}
}
}
poor_man=poor_man_save;
use_mipmaps=use_mipmaps_save;
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
}
示例12: glBindFramebuffer
void HZMap::build(){
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glBindTexture(GL_TEXTURE_2D, texture);
int numLevels = 1 + (int)glm::floor(glm::log2(glm::max((float)width, (float)height)));
int cWidth = width;
int cHeight = height;
for (int i = 1; i < numLevels; i++) {
HZMbuilder->use();
glUniform2iv(HZMbuilder->getUniform("lastMipSize"),1,
glm::value_ptr(glm::ivec2(cWidth,cHeight)));
cWidth /= 2;
cHeight /= 2;
cWidth = (cWidth > 0) ? cWidth : 1;
cHeight = (cHeight > 0) ? cHeight : 1;
glViewport(0,0,cWidth,cHeight);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, i-1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, i-1);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture, i);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
CHECK_GL_ERRORS();
CHECK_GL_FBO_COMPLETENESS();
// Render full screen quad
quad->render(HZMbuilder);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, numLevels-1);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
示例13: display_book
void display_book(book * b, int type)
{
page ** p=&b->pages[b->active_page];
int x=0;
switch(type){
case 2:
glPushMatrix();
glTranslatef(x,0,0);
display_page(b,*p);
glPopMatrix();
if(b->no_pages<=b->active_page)
break;
p++;
x+=250;
case 1:
default:
glPushMatrix();
glTranslatef(x,0,0);
display_page(b,*p);
glPopMatrix();
break;
}
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
}
示例14: sizeof
void AppManager::createVAO(){
GLfloat quad_vertices[] = {
-1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f,
};
vert = new BO<GL_ARRAY_BUFFER>(quad_vertices, sizeof(quad_vertices));
GLubyte quad_indices[] = {
0, 1, 2, //triangle 1
2, 3, 0, //triangle 2
};
ind = new BO<GL_ELEMENT_ARRAY_BUFFER>(quad_indices, sizeof(quad_indices));
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
visualize->use();
vert->bind();
visualize->setAttributePointer("position", 2);
ind->bind();
glBindVertexArray(0);
CHECK_GL_ERRORS();
}
示例15: CHECK_GL_ERRORS
void OpenGL3Driver::bind_uniform(const UniformBuffer& uniform, size_t unit)
{
const OpenGL3UniformBuffer* buffer = static_cast<const OpenGL3UniformBuffer*>(uniform.impl());
// TODO: need to add state checks
buffer->bind(current_shader_program_, unit);
CHECK_GL_ERRORS();
}