示例#1
0
void DistViewGUI::initVPActions()
{
	ui->gv->addAction(uivc->actionHq);
	uivc->hqButton->setAction(uivc->actionHq);
	vp->setDrawHQ(uivc->actionHq);
	connect(uivc->actionHq, SIGNAL(triggered()), vp, SLOT(toggleHQ()));

	ui->gv->addAction(uivc->actionLog);
	uivc->logButton->setAction(uivc->actionLog);
	vp->setDrawLog(uivc->actionLog);
	connect(uivc->actionLog, SIGNAL(triggered()), vp, SLOT(updateBuffers()));

	ui->gv->addAction(uivc->actionScr);
	uivc->screenshotButton->setAction(uivc->actionScr);
	connect(uivc->actionScr, SIGNAL(triggered()), vp, SLOT(screenshot()));

	ui->gv->addAction(uivc->actionBuff);
	connect(uivc->actionBuff, SIGNAL(triggered()), vp, SLOT(toggleBufferFormat()));
	connect(vp, SIGNAL(bufferFormatToggled(Viewport::BufferFormat)),
	        this, SLOT(updateBufferFormat(Viewport::BufferFormat)));

	ui->gv->addAction(uivc->actionRgb);
	uivc->rgbButton->setAction(uivc->actionRgb);
	vp->setDrawRGB(uivc->actionRgb);
	connect(uivc->actionRgb, SIGNAL(triggered()), vp, SLOT(updateBuffers()));

	ui->gv->addAction(uivc->actionMeans);
	vp->setDrawMeans(uivc->actionMeans);
	connect(uivc->actionMeans, SIGNAL(triggered()), vp, SLOT(rebuild()));
}
示例#2
0
const void Mesh::render(void)
{
    //
    // ASSIGNMENT (PA04)
    //
    // Modify your previous (PA03) solution to do the following:
    //
    // - Remove the (hack) to save/restore a copy of `vertices[]` in
    //   `savedVertices[]` (or whatever you called it).
    //
    // - Remove the transform of `vertices[]`. (That's in the vertex
    //   shader now.)
    //

	CHECK_GL(glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBufferId));
	CHECK_GL(glEnableVertexAttribArray(0));
	CHECK_GL(glVertexAttribPointer(0,
								   3,
								   GL_DOUBLE,
								   GL_FALSE,
								   0,
								   BUFFER_OFFSET(0)));
	
	CHECK_GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferId));
	
	// Remove him too?
	updateBuffers();

	int size = nJ - 1 + wrapJ;

	for (int j = 0; j < size; j++)
		renderTriangleStrip(j);

}
示例#3
0
void Viewport::setBufferFormat(BufferFormat format)
{
	bufferFormat = format;

	initBuffers();
	updateBuffers();
}
示例#4
0
Mesh::Mesh(Point3 *vertices_, Vector3 *vertexNormals_,
           int nI_, int nJ_, bool wrapI_, bool wrapJ_)
    : nI(nI_), nJ(nJ_), wrapI(wrapI_), wrapJ(wrapJ_)
{
    nVertices = nI * nJ;
    vertices = new Point3[nVertices];
    vertexNormals = new Vector3[nVertices];
    for (int i = 0; i < nVertices; i++) {
        vertices[i] = vertices_[i];
        vertexNormals[i] = vertexNormals_[i];
    }

    // This enforces our requirement for distinct mesh points and thus
    // prevents later trouble.
    assert(pointsAreDistinct());

    createVertexIndices();
    createFaceNormals();

    allocateBuffers();
    //
    // Since we're handling transforms in the vertex shader, we only
    // need to download the buffers once, here in the constructor,
    // rather than in Mesh::render().
    //
    updateBuffers();
}
示例#5
0
文件: rvgImage.cpp 项目: ileben/RAVG
void Image::update ()
{
  //Prepare image data for rendering
  updateFlat();
  updateBounds();
  updateBuffers();
}
示例#6
0
void Viewport::screenshot()
{
	// ensure high quality
	drawingState = HIGH_QUALITY;
	updateBuffers(RM_FULL, RM_FULL);

	// render into our buffer
	QGLFramebufferObject b(width, height);
	QPainter p(&b);
	bool success = drawScene(&p, false);

	// reset drawing state
	endNoHQ();

	if (!success)
		return;

	QImage img = b.toImage();

	// write out
	cv::Mat output = QImage2Mat(img);
	GerbilIO io(target, "Screenshot File", "screenshot");
	io.setFileSuffix(".png");
	io.setFileCategory("Screenshot");
	io.writeImage(output);
}
示例#7
0
void step(void) {
  sampleExts();
  fireTriggers();
  updateObservers();
  updateStates();
  updateBuffers();
  updatePtrs();
}
示例#8
0
void PointSpritesGeometry::initBuffers() {
    glGenVertexArrays(1, &m_vao);
    glBindVertexArray(m_vao);

    glGenBuffers(1, &vbo_points);

    updateBuffers();
}
示例#9
0
void Viewport::resizeScene()
{
	// initialize buffers with new size
	initBuffers();

	// update buffers
	updateBuffers();
}
示例#10
0
PolyLine::PolyLine(Point3 *vertices_, int nI_, bool wrapI_)
    : nI(nI_), wrapI(wrapI_)
{
    vertices = new Point3[nI];
    for (int i = 0; i < nI; i++)
        vertices[i] = vertices_[i];
    allocateBuffers();
    updateBuffers();
}
示例#11
0
void Viewport::rebuild()
{
	// guess: we want the lock to carry over both methods..
	SharedDataLock ctxlock(ctx->mutex);
	SharedDataLock setslock(sets->mutex);

	prepareLines(); // will also call reset() if indicated by ctx
	updateBuffers();
}
示例#12
0
void Cube::init() {
	generateBuffers();

	centre = glm::vec3(0, 0, 0);
	width = 0.2;
	height = 0.2;

	vertices.resize(8);
	colors.resize(8);
	normals.resize(8);

	// Vertices are
	// On the y = -0.1 plane,    On the y = 0.1 plane
	// v2 - v3						v6 - v7
	// v1 - v0						v5 - v4
	//Eight vertices of the cube
	vertices[0] = glm::vec3(-0.1, -0.1, -0.1);
	vertices[1] = glm::vec3(0.1, -0.1, -0.1);
	vertices[2] = glm::vec3(0.1, -0.1, 0.1);
	vertices[3] = glm::vec3(-0.1, -0.1, 0.1);
	vertices[4] = glm::vec3(-0.1, 0.1, -0.1);
	vertices[5] = glm::vec3(0.1, 0.1, -0.1);
	vertices[6] = glm::vec3(0.1, 0.1, 0.1);
	vertices[7] = glm::vec3(-0.1, 0.1, 0.1);

	// 12 Triangles, 3 vertices
	indices.reserve(36);

	indexVec3.push_back(glm::vec3(0, 1, 2));
	indexVec3.push_back(glm::vec3(0, 2, 3));
	indexVec3.push_back(glm::vec3(4, 5, 6));
	indexVec3.push_back(glm::vec3(4, 6, 7));
	indexVec3.push_back(glm::vec3(0, 3, 4));
	indexVec3.push_back(glm::vec3(3, 4, 7));
	indexVec3.push_back(glm::vec3(1, 2, 5));
	indexVec3.push_back(glm::vec3(2, 5, 6));
	indexVec3.push_back(glm::vec3(2, 6, 7));
	indexVec3.push_back(glm::vec3(2, 3, 7));
	indexVec3.push_back(glm::vec3(1, 4, 5));
	indexVec3.push_back(glm::vec3(0, 1, 4));

	for (unsigned int i = 0; i < indexVec3.size(); i++) {
		indices.push_back(indexVec3.at(i).x);
		indices.push_back(indexVec3.at(i).y);
		indices.push_back(indexVec3.at(i).z);
	}

	calculateNormals();

	// 12 triangles for a cube
	primitivePar.setValues(GL_TRIANGLES, 0, indices.size());

	updateBuffers();
}
示例#13
0
void Viewport::toggleHQ()
{
	if (drawHQ->isChecked()) {
		// triggers drawing update
		endNoHQ();
	} else {
		startNoHQ();
		// deliberately make display worse for user to see effect
		updateBuffers();
	}
}
示例#14
0
void ElevationMap::randomize(float hMin, float hMax)
{
    for (unsigned int i = 0; i < _nx; i++)
    {
        for (unsigned int j = 0; j < _ny; j++)
        {
            float alpha = (float)rand() / RAND_MAX;
            _h[_ny*i + j] = alpha*hMin + (1.0f - alpha)*hMax;
        }
    }
    updateBuffers();
}
示例#15
0
aalError Source::update() {
	
	if(status != Playing || updateCulling()) {
		return AAL_OK;
	}
	
	aalError ret = updateBuffers();
	
	updateCallbacks();
	
	return ret;
}
示例#16
0
void Viewport::toggleLabelHighlight(int index)
{
	if (highlightLabels.contains(index)) {
		int pos = highlightLabels.indexOf(index);
		highlightLabels.remove(pos, 1);
	}
	else {
		highlightLabels.push_back(index);
	}

	updateBuffers(Viewport::RM_STEP,
	              (!highlightLabels.empty() ? RM_SKIP: RM_STEP));
}
示例#17
0
void Viewport::setLimitersMode(bool enabled)
{
	limiterMode = enabled;
	updateBuffers(Viewport::RM_SKIP, Viewport::RM_STEP);
	if (!active) {
		activate(); // will call requestOverlay()
	} else {
		// this is a sometimes redundant operation (matrix maybe still valid)
		if (limiterMode)
			emit requestOverlay(limiters, -1);
		else
			emit requestOverlay(selection, hover);
	}
}
示例#18
0
bool BitmapClass::render( ID3D11DeviceContext *aD3DDeviceContext, int aPositionX, int aPositionY )
{
	bool result;

	result = updateBuffers(aD3DDeviceContext, aPositionX, aPositionY);
	if (!result)
	{
		return false;
	}

	renderBuffers(aD3DDeviceContext);

	return true;
}
示例#19
0
void Viewport::toggleBufferFormat()
{
	switch (bufferFormat) {
	case RGBA8: bufferFormat = RGBA16F; break;
	case RGBA16F: bufferFormat = RGBA32F; break;
	case RGBA32F: bufferFormat = RGBA8; break;
	}

	// initialize buffers with new format
	initBuffers();
	updateBuffers();

	emit bufferFormatToggled(bufferFormat);
}
示例#20
0
/*
================
 DebugWindow::render
================
*/
bool DebugWindow::render( ID3D10Device* device, int x, int y)
{	
	// Re-build the dynamic vertex buffer for rendering to possibly a different location on the screen.
	bool result = updateBuffers(x, y);
	if(!result)
	{
		return false;
	}

	// Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
	renderBuffers(device);

	return true;
}
示例#21
0
bool Viewport::endNoHQ(RenderMode spectrum, RenderMode highlight)
{
	/* we enter this function after the display was in temporary low quality
	 * state. it may be "dirty", i.e. need to be redrawn in high quality now
	 * that is, if the global setting is not low quality anyways
	 */
	bool dirty = drawHQ->isChecked();
	if (drawingState == HIGH_QUALITY || drawingState == HIGH_QUALITY_QUICK)
		dirty = false;

	drawingState = (drawHQ->isChecked() ? HIGH_QUALITY : QUICK);
	if (dirty)
		updateBuffers(spectrum, highlight);
	return dirty;
}
示例#22
0
void EasyDrawer::flush(DeviceContext *ctx)
{
    updateBuffers(ctx);

    mat4 prev_viewproj;
    for(size_t i=0; i<m_draw_calls.size(); ++i) {
        DrawCall &dc = m_draw_calls[i];
        const Viewport &vp = dc.state.getViewport();
        if(vp.getSize().x>0 && vp.getSize().y>0) {
            ctx->setViewport(vp);
        }

        mat4 viewproj = dc.state.getProjectionMatrix() * dc.state.getWorldMatrix();
        if(viewproj!=prev_viewproj) {
            prev_viewproj = viewproj;
            if(ctx->getDevice()->getSpec()->needs_transpose) {
                mat4 tmp = glm::transpose(viewproj);
                MapAndWrite(ctx, m_ubo, &tmp, sizeof(tmp));
            }
            else {
                MapAndWrite(ctx, m_ubo, &viewproj, sizeof(viewproj));
            }
        }

        ShaderProgram *shader = dc.state.getShader();
        ctx->setShader(shader);
        ctx->setUniformBuffer(dc.state.getUniformLocation(), 0, m_ubo);
        ctx->setSampler(0, dc.state.getSampler());
        ctx->setTexture(0, dc.state.getTexture());
        ctx->setVertexArray(m_va);

        EasyShaders::VertexStreamData &vsd = m_shaders->getVertexInfo(dc.vertex_type);
        m_va->setAttributes(0, m_vbo, dc.vb_offset, vsd.stride, vsd.descs, vsd.num_descs);

        if(dc.num_indices==0) {
            ctx->draw(dc.topology, 0, dc.num_vertices);
        }
        else {
            ctx->setIndexBuffer(m_ibo, dc.ib_offset, dc.index_type);
            ctx->drawIndexed(dc.topology, dc.num_indices);
            ctx->setIndexBuffer(nullptr, 0, I3D_UINT32);
        }
    }

    m_draw_calls.clear();
    m_vertex_data.clear();
    m_index_data.clear();
}
示例#23
0
void Cube::setHeight(double height) {
	glm::vec3 offset;
	offset.y = (height - (vertices[4].y - vertices[0].y)) * 0.5;

	vertices[0] -= offset;
	vertices[1] -= offset;
	vertices[2] -= offset;
	vertices[3] -= offset;

	vertices[4] += offset;
	vertices[5] += offset;
	vertices[6] += offset;
	vertices[7] += offset;

	calculateNormals();
	updateBuffers();
}
示例#24
0
void Cube::setDepth(double depth) {
	glm::vec3 offset;
	offset.z = (depth - (vertices[2].z - vertices[1].z)) * 0.5;

	vertices[0] -= offset;
	vertices[1] -= offset;
	vertices[4] -= offset;
	vertices[5] -= offset;

	vertices[2] += offset;
	vertices[3] += offset;
	vertices[6] += offset;
	vertices[7] += offset;

	calculateNormals();
	updateBuffers();
}
示例#25
0
文件: Text.cpp 项目: ThePr3/Gines
	Text::Text(const Text& original)
	{//Copy constructor
		glGenBuffers(1, &vertexArrayData);
		string = original.string;
		position = original.position;
		color = original.color;
		updateGlyphsToRender();
		textures = nullptr;
		font = nullptr;
		scale = original.scale;
		lineSpacing = original.lineSpacing;
		
		if (original.font != nullptr)
		{
			setFont(original.font->fontPath, original.font->fontSize);//Increases reference count
			updateBuffers();
		}
	}
示例#26
0
void Cube::setWidth(double width, const glm::vec3& offset) {
	glm::vec3 widthOffset;
	widthOffset.x = (width - (vertices[1].x - vertices[0].x)) * 0.5;

	//widthOffset += offset;

	vertices[1] = vertices[1] + widthOffset + offset;
	vertices[2] = vertices[2] + widthOffset + offset;
	vertices[5] = vertices[5] + widthOffset + offset;
	vertices[6] = vertices[6] + widthOffset + offset;

	vertices[0] = vertices[0] - widthOffset + offset;
	vertices[3] = vertices[3] - widthOffset + offset;
	vertices[4] = vertices[4] - widthOffset + offset;
	vertices[7] = vertices[7] - widthOffset + offset;

	calculateNormals();
	updateBuffers();
}
示例#27
0
DFBResult
SurfacePeer::Flip( const DFBRegion     *region,
                   DFBSurfaceFlipFlags  flags,
                   long long            timestamp )
{
     DFBResult ret;

     D_DEBUG_AT( DirectFB_Graphics, "Graphics::SurfacePeer::%s( %p, region %p, flags 0x%08x, timestamp %lld )\n",
                 __FUNCTION__, this, region, flags, timestamp );

     Dispatch< SurfacePeer::Flush >( "Flush", this );

     D_MAGIC_ASSERT( surface, CoreSurface );

     if (0) {
          DFBSurfaceEvent event;
     
          event.clazz        = DFEC_SURFACE;
          event.type         = DSEVT_FRAME;
          event.surface_id   = surface->object.id;
          event.flip_flags   = flags;
          event.time_stamp   = timestamp;
          event.left_id      = buffer_left();
          event.left_serial  = surface->serial.value;
          event.right_id     = buffer_right();
          event.right_serial = event.left_serial;
          event.update       = DFBRegion( surface_config.size );
          event.update_right = event.update;
     
          ret = (DFBResult) dfb_surface_dispatch_channel( surface, CSCH_EVENT, &event, sizeof(DFBSurfaceEvent), NULL );
          if (ret)
               return ret;
     }
     else {
          ret = ::CoreSurface_DispatchUpdate( surface, DFB_FALSE, region, region, flags, timestamp, flips );
          if (ret)
               D_DERROR( ret, "Graphics/SurfacePeer: CoreSurface::DispatchUpdate() failed!\n" );
     }

     flips++;

     return updateBuffers();
}
示例#28
0
Model::Model(Shader *shader,  const char* filename, const char* materialPath)
{
	m_shader = shader;
	tinyobj::LoadObj(shapes,filename, materialPath);
	for(int i = 0; i<shapes.size(); i++){
		m_VBO.push_back(0);
		m_NBO.push_back(0);
		m_IBO.push_back(0);
		glGenBuffers(1, &m_VBO[i]); // generate a 'name' for the VBO
		glGenBuffers(1, &m_NBO[i]); // generate a 'name' for the NBO
		glGenBuffers(1, &m_IBO[i]); // generate a 'name' for the IBO
		// Bind ibo to the index buffer.
		
		
	}
	
	updateBuffers();
	
}
示例#29
0
bool ElevationMap::load(const char* fileName)
{
	FILE* demFile;
	fopen_s(&demFile, fileName, "r");

	int n;

	_ny = 1386;
	int nx = 0;

	int rowStart = 0x13c00;

	do
	{
		fseek(demFile, rowStart, SEEK_SET);
		fseek(demFile, 0xc, SEEK_CUR);
		fscanf_s(demFile, "%d", &n);
		fseek(demFile, 126, SEEK_CUR);
		if (n >= _ny)
		{
			for (int i = 0; i < _ny; i++)
			{
				fscanf_s(demFile, "%d", &n);
				_h[_ny*nx + i] = (float)n / 30;
			}
			nx++;
		}
		else
		{
			break;
		}
		rowStart += 0x2400;
	}
	while (true);

	_nx = nx;

	updateBuffers();

	return true;
} // TODO: make column major again
示例#30
0
文件: Text.cpp 项目: ThePr3/Gines
	void Text::operator=(const Text& original)
	{
		glDeleteBuffers(1, &vertexArrayData);
		delete[] textures;
		unreferenceFont();
		glGenBuffers(1, &vertexArrayData);
		string = original.string;
		position = original.position;
		color = original.color;
		updateGlyphsToRender();
		textures = nullptr;
		font = nullptr;
		scale = original.scale;
		lineSpacing = original.lineSpacing;

		if (original.font != nullptr)
		{
			setFont(original.font->fontPath, original.font->fontSize);//Increases reference count
			updateBuffers();
		}
	}