示例#1
0
void FrameBufferObject::resize() const
{
	if(m_depth && m_render != -1)
	{
        glBindRenderbuffer(GL_RENDERBUFFER, m_render);
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, m_size.x, m_size.y);
        glError();
        glBindRenderbuffer(GL_RENDERBUFFER, 0);
        glError();
	}

	if(m_texture != -1)
	{
		glBindTexture(GL_TEXTURE_2D, m_texture);

		glTexImage2D(GL_TEXTURE_2D, 0, m_internal, m_size.x, m_size.y, 0, m_format, m_type, 0);
		glError();

		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);  
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);  
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);  
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 

		glBindTexture(GL_TEXTURE_2D, 0);
		glError();
	}
}
示例#2
0
void PolygonalDrawable::draw(
    const Program & program
,   const glm::mat4 & transform)
{
    if(!m_geometry || m_geometry->indices().empty())
        return;

    if(m_arrayBOsByAttribute.empty() || m_elementArrayBOs.empty())
        initialize(program);

    program.use();
    program.setUniform(TRANSFORM_UNIFORM, transform);

    glBindVertexArray(m_vao);                                                                  
    glError();

    t_bufferObjects::const_iterator e(m_elementArrayBOs.begin());
    const t_bufferObjects::const_iterator eEnd(m_elementArrayBOs.end());

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    for(; e != eEnd; ++e)
        (*e)->draw(m_geometry->mode());

    glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);

    glBindVertexArray(0);
    glError();

    program.release();
}
示例#3
0
void enemy::draw()
{
glPushMatrix();
glError();

glTranslatef( pos.x, pos.y, pos.z );
glError();

glBegin( GL_LINES );

#define LEN 1.0f
#define line( _pt1,_pt2 ) glVertex3fv( _pt1 );glVertex3fv( _pt2 )
GLfloat v0[] = { -LEN, -LEN, 0.0f };
GLfloat v1[] = { -LEN,  LEN, 0.0f };
GLfloat v2[] = {  LEN,  LEN, 0.0f };
GLfloat v3[] = {  LEN, -LEN, 0.0f };

line( v0, v1 );
line( v1, v2 );
line( v2, v3 );
line( v3, v0 );

glEnd();
glError();

glPopMatrix();
glError();
}
示例#4
0
void PolygonalGeometry::initialize(const Program & program)
{
    if(!m_arrayBOsByAttribute.empty() && !m_elementArrayBOs.empty())
        return;
    
    deleteBuffers();

    glGenVertexArrays(1, &m_vao);
    glError();
    glBindVertexArray(m_vao);                                                                  
    glError();

    {
        VertexReuse vertexReuse;
        VertexCacheOptimizer vertexCacheOptimizer;
        applyOptimizer(&vertexReuse);
        applyOptimizer(&vertexCacheOptimizer);
    }

    // setup element array buffers

    BufferObject * indexBO = new BufferObject(GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW);
    indexBO->data<GLuint>(indices(), GL_UNSIGNED_INT, 1);

    m_elementArrayBOs.push_back(indexBO);

    // setup array buffers

    BufferObject * vertexBO = new BufferObject(GL_ARRAY_BUFFER, GL_STATIC_DRAW);
    vertexBO->data<glm::vec3>(copyVertices(), GL_FLOAT, 3);
    
    m_arrayBOsByAttribute["a_vertex"] = vertexBO;

    // TODO: the geometry should provide this information.

    if( !normals().isEmpty() )
    {
        BufferObject * normalBO = new BufferObject(GL_ARRAY_BUFFER, GL_STATIC_DRAW);
        normalBO->data<glm::vec3>(normals(), GL_FLOAT, 3);

        m_arrayBOsByAttribute["a_normal"] = normalBO;
    }

    // bind all buffers to their attributes

    t_bufferObjectsByAttribute::const_iterator i(m_arrayBOsByAttribute.begin());
    const t_bufferObjectsByAttribute::const_iterator iEnd(m_arrayBOsByAttribute.end());

    for( ; i != iEnd; ++i )
        i.value()->bind(program.attributeLocation(i.key()));

    glBindVertexArray(0);
    glError();
}
示例#5
0
void FrameBufferObject::bind() const
{
    if(!isFrameBuffer())
        initialize();

    glViewport(0, 0, m_size.x, m_size.y);
    glError();

    glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
    glError();
}
示例#6
0
文件: ship.cpp 项目: rsaxvc/vertifall
void ship::draw()
{
calcPos();
calcTail();
const position * last_pos = &pos;

for( std::list<position>::iterator it = tail.begin(); it != tail.end(); it++)
//for( int i = -1; i < (int)/*hack*/tail.size(); ++i )
	{
	glPushMatrix();
	glError();

	glTranslatef( last_pos->x, last_pos->y, 0 );
	glError();

	glBegin( GL_LINES );

	#define line( _pt1,_pt2 ) glVertex3fv( _pt1 );glVertex3fv( _pt2 )

	//triangle
	GLfloat v0[] = {      0,     HEIGHT, 0.0f };
	GLfloat v1[] = {   -WIDTH,       0, 0.0f };
	GLfloat v2[] = {    WIDTH,       0, 0.0f };

	//barrel
	GLfloat v3[] = {      0, 2 * HEIGHT, 0.0f };

	//suppressor
	GLfloat v4[] = { -WIDTH/3, 2 * HEIGHT - HEIGHT/3, 0.0f };
	GLfloat v5[] = {  WIDTH/3, 2 * HEIGHT - HEIGHT/3, 0.0f };

	line( v0, v1 );
	line( v1, v2 );
	line( v2, v0 );

	line( v0, v3 );

	line( v3, v4 );
	line( v4, v5 );
	line( v5, v3 );

	glEnd();
	glError();

	glPopMatrix();
	glError();

	last_pos = &*it;
	}
}
void SetExtGLFuncs(void)
{
 //----------------------------------------------------//

 SetFixes();                                           // update fix infos

 //----------------------------------------------------//

  {
   if(bAdvancedBlend) bUseMultiPass=TRUE;              // -> pseudo-advanced with 2 passes
   else               bUseMultiPass=FALSE;             // -> or simple 'bright color' mode
//   bGLBlend=FALSE;                                     // -> no ext blending!
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glError();
  }

 if(bOpaquePass)                                        // opaque mode?
  {
   if(dwActFixes&32) 
    {
     TCF[0]=CP8RGBA_0;
     PalTexturedColourFn=CP8RGBA;                      // -> init col func
    }
   else
    {
     TCF[0]=XP8RGBA_0;
     PalTexturedColourFn=XP8RGBA;                      // -> init col func
    }

   TCF[1]=XP8RGBA_1;
   glAlphaFuncx(GL_GREATER,0.49f); glError();

  }
 else                                                  // no opaque mode?
  {
   TCF[0]=TCF[1]=P8RGBA;
   PalTexturedColourFn=P8RGBA;                         // -> init col func
   glAlphaFuncx(GL_NOTEQUAL,0); glError();             // --> set alpha func

  }

 //----------------------------------------------------//

 LoadSubTexFn=LoadSubTexturePageSort;                  // init load tex ptr

 bBlendEnable=FALSE;                                   // init blending: off
 glDisable(GL_BLEND); glError();


 SetScanTrans();                                       // init scan lines (if wanted)
}
示例#8
0
文件: shader.cpp 项目: hpicgs/cgsee
const bool Shader::setSource(
    const QString & source
,   const bool update)
{
    m_source = source;

    const QByteArray bytes(m_source.toLocal8Bit());
    const GLchar * chr(bytes.constData());

    glShaderSource(m_shader, 1, &chr, nullptr);
    glError();
    glCompileShader(m_shader);
    glError();

    GLint status(GL_FALSE);
    glGetShaderiv(m_shader, GL_COMPILE_STATUS, &status);

    m_compiled = (GL_TRUE == status);
    m_log = "";

    if(!m_compiled)
    {
        GLint maxLength(0);
        GLint logLength(0);

        glGetShaderiv(m_shader, GL_INFO_LOG_LENGTH, &maxLength);
        glError();

        GLchar *log = new GLchar[maxLength];
        glGetShaderInfoLog(m_shader, maxLength, &logLength, log);
        glError();

        m_log = log;

        t_typeStrings::const_iterator i(typeStrings.find(type()));
        if(typeStrings.end() != i)
            qCritical("Compiling shader of type %s failed.", qPrintable(i.value()));
        else
            qCritical("Compiling shader of type %i failed.", type());

        if(!m_log.isEmpty())
            qCritical("%s", qPrintable(m_log));
    }

    if(update)
        this->update();

    return isCompiled();
}
示例#9
0
//.......................................................................................
void StateMain::SetupConsole()
{
	// console
	int m_iLineHeight = m_pFont->FontHeight();
	float ymin = -1.0f + ((1.0f / (float)(g_vWindowDimensions.y / 2)) * (m_iLineHeight + 5));

	GLfloat vertices[18][2] = {
		{ -1.0f, -1.0f }, // Triangle 1
		{ 1.0f, -1.0f },
		{ -1.0f, 1.0f },
		{ 1.0f, -1.0f }, // Triangle 2
		{ 1.0f, 1.0f },
		{ -1.0f, 1.0f },

		{ -1.0f, -1.0f }, // Triangle 3
		{ 1.0f, -1.0f },
		{ -1.0f, ymin },
		{ 1.0f, -1.0f }, // Triangle 4
		{ 1.0f, ymin },
		{ -1.0f, ymin },

		{ -1.0f, -1.0f }, // Triangle 5
		{ 1.0f, -1.0f },
		{ -1.0f, ymin },
		{ 1.0f, -1.0f }, // Triangle 6
		{ 1.0f, ymin },
		{ -1.0f, ymin },
	};

	glGenVertexArrays(1, &vao);
	glError("StateMain::SetupConsole()", "glGenVertexArrays() vao");

	glBindVertexArray(vao);
	glError("StateMain::SetupConsole()", "glBindVertexArray() vao");
	glGenBuffers(1, &vbo);
	glError("StateMain::SetupConsole()", "glGenBuffers() vao");
	glBindBuffer(GL_ARRAY_BUFFER, vbo);
	glError("StateMain::SetupConsole()", "glBindBuffer(GL_ARRAY_BUFFER, vbo)");
	glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * sizeof(vertices), (GLvoid *)vertices, GL_STATIC_DRAW);
	glError("StateMain::SetupConsole()", "glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3f) * vConsoleVertices.size(), (GLvoid *)&vConsoleVertices[0], GL_STATIC_DRAW)");

	GLuint aPos = m_pProgramManager->Program("consoleProgram1")->GetAttribute("attributePosition");
	Logw("aPos = %d\n", aPos);
	glEnableVertexAttribArray(aPos);
	glError("StateMain::SetupConsole()", "glEnableVertexAttribArray(pos)");
	glVertexAttribPointer(aPos, 2, GL_FLOAT, GL_FALSE, 0, (GLvoid *)0);
	glError("StateMain::SetupConsole()", "glVertexAttribPointer(pos, sizeof(Vector3f), GL_FLOAT, GL_FALSE, 0, (GLvoid *)0)");
	glDisableVertexAttribArray(aPos);
	glError("StateMain::SetupConsole()", "glDisableVertexAttribArray(pos)");
	glBindVertexArray(0);
	glError("StateMain::SetupConsole()", "glBindVertexArray(0)");

}
示例#10
0
void Menger::buildModel() {
  rebuild();
  glError("finished rebuild\n");

  glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
  vPosition = glGetAttribLocation(program, "vPosition");
  glEnableVertexAttribArray(vPosition);
  glVertexAttribPointer(vPosition, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
  glError("bound position");

  glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
  vColor = glGetAttribLocation(program, "vColor");
  glEnableVertexAttribArray(vColor);
  glVertexAttribPointer(vColor, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
  glError("bound color");
}
FastLaplaceComper::FastLaplaceComper()
    : _src_img(NULL),
      _tgt_img(NULL),
      _cd(NULL)
{
    const char *shader_src = "uniform sampler2D source_img;\n"
                       "void main()\n"
                       "{\n"
                       "    gl_FragColor = (2.0*gl_Color-1.0) + texture2D(source_img, gl_TexCoord[0].st);\n"
                       "}";

    m_fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(m_fragmentShader, 1, &shader_src, NULL);

    glCompileShader(m_fragmentShader);
    printLog(m_fragmentShader);

    m_shaderProgram = glCreateProgram();
    glAttachShader(m_shaderProgram, m_fragmentShader);
    glLinkProgram(m_shaderProgram);

    printLog(m_shaderProgram);

    m_srcImgTexLoc = glGetUniformLocation(m_shaderProgram, "source_img");

    glGenTextures(1, &m_srcImgTexId);
    glGenTextures(1, &m_tgtImgTexId);

    glError();

    _debugDrawMesh = false;
    _doInterp = true;
}
示例#12
0
void Viewer::PickModel()
{
	Gui::Fixed *f = new Gui::Fixed();
	f->SetSizeRequest(Gui::Screen::GetWidth()*0.5f, Gui::Screen::GetHeight()*0.5);
	Gui::Screen::AddBaseWidget(f, Gui::Screen::GetWidth()*0.25f, Gui::Screen::GetHeight()*0.25f);

	f->Add(new Gui::Label("Enter the name of the model you want to view:"), 0, 0);

	Gui::Label *errormsg = new Gui::Label("");
	f->Add(errormsg, 0, 64);

	Gui::TextEntry *entry = new Gui::TextEntry();
	entry->onKeyPress.connect(sigc::bind(sigc::mem_fun(this, &Viewer::TryModel), entry, errormsg));
	entry->Show();
	f->Add(entry, 0, 32);

	m_model = 0;

	while (!m_model) {
		this->Hide();
		f->ShowAll();
		PollEvents();
		Render::PrepareFrame();
		glClearColor(0,0,0,0);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		Render::PostProcess();
		Gui::Draw();
		glError();
		Render::SwapBuffers();
	}
	Gui::Screen::RemoveBaseWidget(f);
	delete f;
	this->Show();
}
示例#13
0
void FrameBufferObject::bindTexture2D(
    const Program & program
,   const QString & uniform
,   const glm::uint slot) const
{
    if(!isTexture())
        initialize();

    glActiveTexture(GL_TEXTURE0 + slot);
    glError();

    glBindTexture(GL_TEXTURE_2D, m_texture);
    glError();

    program.setUniform(uniform, slot);  
}
示例#14
0
文件: camera.cpp 项目: Jagholin/cgsee
void Camera::draw(
    Program * program
,   FrameBufferObject * target)
{
    if(m_invalidated)
        update();

    if(target)
        target->bind();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glViewport(0, 0, m_viewport.x, m_viewport.y);
    glError();

    if(program)
    {
        program->use();

        program->setUniform(VIEWPORT_UNIFORM, m_viewport);
        program->setUniform(VIEW_UNIFORM, m_view);
        program->setUniform(PROJECTION_UNIFORM, m_projection);
		
		program->setUniform(ZNEAR_UNIFORM, m_zNear);
		program->setUniform(ZFAR_UNIFORM, m_zFar);
    }
    
    Group::draw(program, glm::mat4());

    if(target)
        target->release();
}
示例#15
0
int setSavedGLState(int target)
{
	int error;

DMARK	/* restore original gl state */
	ORIG_GL(glPopAttrib)();
	error = glError();
	if (error) {
		return error;
	}

	/* save original gl state */
	error = saveGLState();
	if (error) {
		return error;
	}

	/* FIXME CHECK AGAIN!!!! 	*/
#if 0
	/* disable everything that could interfere when writting the debug result to
	 * the debug buffer and setup draw and read buffer.
	 */
	error = setDbgRenderState(target);
	if (error) {
		return error;
	}
#endif
	return DBG_NO_ERROR;
}
示例#16
0
文件: gpuquery.cpp 项目: hpicgs/cgsee
const QString GPUQuery::glew(const GLenum penum)
{
    const QString result(reinterpret_cast<const char*>(glewGetString(penum)));
    glError();

    return result;
}
示例#17
0
void FrameBufferObject::bindTexture2D(
    Program * minpathram
,   const std::string & uniform
,   const glm::uint slot) const
{
    if(!GPUQuery::isTexture(m_texture))
        initialize();

	glActiveTexture(GL_TEXTURE0 + slot);
	glError();

    glBindTexture(GL_TEXTURE_2D, m_texture);
    glError();

    if(minpathram)
        minpathram->setUniform(uniform, slot);  
}
示例#18
0
void FrameBufferObject::release() const
{
    if(!GPUQuery::isFrameBuffer(m_fbo))
        return;

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glError();
}
示例#19
0
void FrameBufferObject::releaseTexture2D() const
{
    if(!GPUQuery::isTexture(m_texture))
        return;

    glBindTexture(GL_TEXTURE_2D, 0);
    glError();
}
示例#20
0
void debugGLError( const std::string& when, const GLenum error,
                   const char* file, const int line )
{
    LBWARN << lunchbox::disableFlush << "Got " << glError( error ) << ' '
           << when << " in " << file << ':' << line << std::endl
           << lunchbox::backtrace << lunchbox::enableFlush << std::endl;
    throw GLException( error );
}
示例#21
0
/* TODO: error checking */
static void freeDbgShader(void)
{
	if (g.dbgShaderHandle != -1) {
		ORIG_GL(glDeleteProgram)(g.dbgShaderHandle);
		glError();
		g.dbgShaderHandle = -1;
	}
}
示例#22
0
/**
 * Update the sector for when the terrain is changed.
 */
static void updateSectorGeometry(int x, int y)
{
	RenderVertex *geometry;
	RenderVertex *water;
	DecalVertex *decaldata;
	int geometrySize = 0;
	int waterSize = 0;
	int decalSize = 0;
	
	geometry  = (RenderVertex *)malloc(sizeof(RenderVertex)*sectors[x*ySectors + y].geometrySize);
	water     = (RenderVertex *)malloc(sizeof(RenderVertex)*sectors[x*ySectors + y].waterSize);

	setSectorGeometry(x, y, geometry, water, &geometrySize, &waterSize);
	ASSERT(geometrySize == sectors[x*ySectors + y].geometrySize, "something went seriously wrong updating the terrain");
	ASSERT(waterSize    == sectors[x*ySectors + y].waterSize   , "something went seriously wrong updating the terrain");
	
	glBindBuffer(GL_ARRAY_BUFFER, geometryVBO); glError();
	glBufferSubData(GL_ARRAY_BUFFER, sizeof(RenderVertex)*sectors[x*ySectors + y].geometryOffset,
	                                 sizeof(RenderVertex)*sectors[x*ySectors + y].geometrySize, geometry); glError();
	glBindBuffer(GL_ARRAY_BUFFER, waterVBO); glError();
	glBufferSubData(GL_ARRAY_BUFFER, sizeof(RenderVertex)*sectors[x*ySectors + y].waterOffset,
	                                 sizeof(RenderVertex)*sectors[x*ySectors + y].waterSize, water); glError();

	free(geometry);
	free(water);

	if (sectors[x*ySectors + y].decalSize <= 0)
	{
		// Nothing to do here, and glBufferSubData(GL_ARRAY_BUFFER, 0, 0, *) crashes in my graphics driver. Probably shouldn't crash...
		return;
	}

	decaldata = (DecalVertex *)malloc(sizeof(DecalVertex)*sectors[x*ySectors + y].decalSize);
	setSectorDecals(x, y, decaldata, &decalSize);
	ASSERT(decalSize == sectors[x*ySectors + y].decalSize   , "the amount of decals has changed");
	
	glBindBuffer(GL_ARRAY_BUFFER, decalVBO); glError();
	glBufferSubData(GL_ARRAY_BUFFER, sizeof(DecalVertex)*sectors[x*ySectors + y].decalOffset,
	                                 sizeof(DecalVertex)*sectors[x*ySectors + y].decalSize, decaldata); glError();
	glBindBuffer(GL_ARRAY_BUFFER, 0);

	free (decaldata);

	glBindBuffer(GL_ARRAY_BUFFER, 0);  // HACK Must unbind GL_ARRAY_BUFFER (don't know if it has to be unbound everywhere), otherwise text rendering may mysteriously crash.
}
示例#23
0
FrameBufferObject::~FrameBufferObject()
{
	if(GPUQuery::isTexture(m_texture))
	{
        glDeleteTextures(1, &m_texture);
		glError();
	}
	if(GPUQuery::isRenderBuffer(m_render))
	{
        glDeleteRenderbuffers(1, &m_render);
		glError();
	}
	if(GPUQuery::isFrameBuffer(m_fbo))
	{
        glDeleteFramebuffers(1, &m_fbo);
		glError();
	}
}
示例#24
0
文件: gpuquery.cpp 项目: hpicgs/cgsee
const GLint GPUQuery::queryi(const GLenum penum)
{
    GLint result;
    glGetIntegerv(penum, &result);

    glError();

    return result;
}
示例#25
0
OGL3ConstantBuffer::OGL3ConstantBuffer(OpenGL3APIWrapper* pWrapper,HAGE::u32 nSize) : m_pWrapper(pWrapper),m_nSize(nSize)
{
	glGenBuffers(1,&m_cbo);
	glBindBuffer(GL_UNIFORM_BUFFER, m_cbo);
    glBufferData(GL_UNIFORM_BUFFER, m_nSize,
                     NULL, GL_DYNAMIC_DRAW);
	glBindBuffer(GL_UNIFORM_BUFFER, 0);
	glError();
}
示例#26
0
文件: main.cpp 项目: rsaxvc/vertifall
static void draw_screen( void )
{
static ship s;
/* Clear the color and depth buffers. */
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glError();

/* We don't want to modify the projection matrix. */
glMatrixMode( GL_MODELVIEW );
glError();
glLoadIdentity( );
glError();
/* Move down the z-axis. */
glTranslatef( 0.0, 0.0, -15.0 ); glError();

glPushMatrix(); glError();

/* Rotate. */
//glRotatef( 100 * tim_x.read(), 1.0, 0.0, 0.0 );
//glRotatef( 100 * tim_y.read(), 0.0, 1.0, 0.0 );
//    glRotatef( 100 * tim_c.read(), 0.0, 0.0, 1.0 );

glTranslatef( 5 * tim_x.read(), 5 * tim_y.read(), 0 );
glError();

glBegin( GL_LINES );

#define BRICK_CNT 40//actually sqrt(brick count)
for( int x=-BRICK_CNT;x<BRICK_CNT;++x )
	{
	for( int y=-BRICK_CNT;y<BRICK_CNT;++y)
		{
		draw_rect(x,y,1,1,y==0,true);
		}
	}
glEnd();
glError();

glPopMatrix();
glError();

glRotatef( 100 * tim_x.read(), 1.0, 0.0, 0.0 );
glRotatef( 100 * tim_y.read(), 0.0, 1.0, 0.0 );

s.draw();

/*
 * Swap the buffers. This this tells the driver to
 * render the next frame from the contents of the
 * back-buffer, and to set all rendering operations
 * to occur on what was the front-buffer.
 */
SDL_GL_SwapBuffers( );
}
示例#27
0
void FrameBufferObject::bind(GLenum target) const
{
    if(!GPUQuery::isFrameBuffer(m_fbo))
        initialize();

    glViewport(0, 0, m_size.x, m_size.y);

    glBindFramebuffer(target, m_fbo);
    glError();
}
示例#28
0
文件: shader.cpp 项目: Jagholin/cgsee
Shader::~Shader()
{
	if(GPUQuery::isShader(m_shader))
    {
        glDeleteShader(m_shader);
        glError();

        m_shader = 0;
    }
}
示例#29
0
文件: shader.cpp 项目: hpicgs/cgsee
Shader::~Shader()
{
    if(isShader())
    {
        glDeleteShader(m_shader);
        glError();

        m_shader = 0;
    }
}
示例#30
0
void PathTracingBVH::geometryToTexture(GLuint textureSlot) {
    BufferObject geometryBuffer(GL_TEXTURE_BUFFER, GL_STATIC_READ);
    geometryBuffer.data<glm::vec4>(m_geometry->data(), m_geometry->size(), GL_RGBA32F, sizeof(glm::vec4));
    glActiveTexture(textureSlot);
    GLuint textureHandle;
    glGenTextures(1, &textureHandle);
    glBindTexture(GL_TEXTURE_BUFFER, textureHandle);
    glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, geometryBuffer.buffer());
    glError();
}