Commit 9049316a authored by Christopher Tenter's avatar Christopher Tenter

minor improvements

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20579 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 03eb5644
......@@ -50,6 +50,8 @@
#include "FilterKernels.hh"
#include <QPainter>
#include <fstream>
......@@ -662,5 +664,55 @@ bool PoissonBlurFilter::execute( GLuint _srcTex, float _kernelScale )
return false;
}
void PoissonBlurFilter::plotSamples( QImage* _image )
{
// cross radius of samples in image
const int crossRadius = 2;
if (_image)
{
int w = _image->width(),
h = _image->height();
_image->fill(qRgb(255,255,255));
// draw outer circle
QPainter plotter;
plotter.begin(_image);
plotter.setPen(QPen(qRgb(0,0,0)));
plotter.drawEllipse(0, 0, _image->width()-1, _image->height()-1);
plotter.end();
// draw samples
for (int i = 0; i < numSamples(); ++i)
{
// map sample pos to [0,1]
Vec2f s = samples_[i];
s /= radius_;
s = s * 0.5f + Vec2f(0.5f, 0.5f);
// map to [0, imageSize]
s *= Vec2f(w-1,h-1);
// draw cross for samples
Vec2i pc(s[0] + 0.5f, s[1] + 0.5f); // pixel center
for (int k = -crossRadius; k <= crossRadius; ++k)
{
for (int mirror = 0; mirror < 2; ++mirror)
{
Vec2i p = pc + Vec2i(k * (mirror ? -1 : 1),k);
// clamp to image size
p[0] = std::min(std::max(p[0], 0), w-1);
p[1] = std::min(std::max(p[1], 0), h-1);
_image->setPixel(p[0], p[1], qRgb(255, 0, 0));
}
}
}
}
}
}
......@@ -48,6 +48,7 @@
#include <ACG/GL/gl.hh>
#include <QStringList>
#include <QImage>
#include <vector>
......@@ -389,6 +390,9 @@ public:
/// dump samples as point cloud in obj format
void dumpSamples(const char* _filename);
/// plot samples on qt image
void plotSamples(QImage* _image);
private:
// sampling settings
......
......@@ -157,6 +157,11 @@ void IRenderer::addRenderObject(ACG::RenderObject* _renderObject)
for (std::map<size_t,RenderObject::Texture>::const_iterator it = _renderObject->textures().begin();
it != _renderObject->textures().end(); ++it)
{
#ifdef GL_ARB_texture_buffer_object
if (it->second.type == GL_TEXTURE_BUFFER)
continue; // skip texture buffers, for which testing for mipmaps would generate an error
#endif
glBindTexture(it->second.type, it->second.id);
GLint minFilter = GL_NONE;
......@@ -222,7 +227,8 @@ void IRenderer::addRenderObject(ACG::RenderObject* _renderObject)
{
// check for normals
if (!_renderObject->vertexDecl->findElementByUsage(VERTEX_USAGE_NORMAL))
std::cout << "warning: missing normals for lighting in renderobject: " << _renderObject->debugName << std::endl;
std::cout << "warning: missing normals for lighting in renderobject: " << _renderObject->debugName << std::endl
<< " Set shadeMode to SG_SHADE_UNLIT or provide normals!" << std::endl;
}
if (_renderObject->shaderDesc.textured())
......
......@@ -291,10 +291,10 @@ struct ACGDLLEXPORT RenderObject
GLuint id;
GLenum type;
bool shadow;
Texture():
id(0),
type(GL_TEXTURE_2D),
shadow(false){}
Texture(GLuint _id = 0, GLenum _type = GL_TEXTURE_2D, bool _shadow = false):
id(_id),
type(_type),
shadow(_shadow){}
};
......
......@@ -274,7 +274,7 @@ inline const char *_getExtensionString() {
/** Check if the extension given by a std::string is supported by the current OpenGL extension
*/
inline bool checkExtensionSupported( std::string _extension ) {
inline bool checkExtensionSupported( const std::string& _extension ) {
/**
* Cache glGetString(...) output because depending on the graphics driver
* it might return 0 the second time we call it.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment