git-svn-id: svn://db.shs.com.ru/libs@540 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -43,9 +43,9 @@ void GLRendererBase::setupLight(const Light & l, int inpass_index, int gl_index)
|
||||
dir[0] = ld.x();
|
||||
dir[1] = ld.y();
|
||||
dir[2] = ld.z();
|
||||
col[0] = l.visible_ ? l.color().redF() * l.intensity : 0.;
|
||||
col[1] = l.visible_ ? l.color().greenF() * l.intensity : 0.;
|
||||
col[2] = l.visible_ ? l.color().blueF() * l.intensity : 0.;
|
||||
col[0] = l.visible_ ? l.color().redF() * l.intensity : 0.f;
|
||||
col[1] = l.visible_ ? l.color().greenF() * l.intensity : 0.f;
|
||||
col[2] = l.visible_ ? l.color().blueF() * l.intensity : 0.f;
|
||||
glEnable(gl_index);
|
||||
//glLightfv(gl_index, GL_AMBIENT, ambient);
|
||||
glLightfv(gl_index, GL_DIFFUSE, col);
|
||||
@@ -56,8 +56,8 @@ void GLRendererBase::setupLight(const Light & l, int inpass_index, int gl_index)
|
||||
glLightf(gl_index, GL_QUADRATIC_ATTENUATION, l.decay_quadratic);
|
||||
if (l.light_type == Light::Cone) {
|
||||
glLightfv(gl_index, GL_SPOT_DIRECTION, dir);
|
||||
glLightf(gl_index, GL_SPOT_CUTOFF, l.angle_end / 2.);
|
||||
glLightf(gl_index, GL_SPOT_EXPONENT, (1. - piClamp<double>((l.angle_end - l.angle_start) / (l.angle_end + 0.001), 0., 1.)) * 128.);
|
||||
glLightf(gl_index, GL_SPOT_CUTOFF, l.angle_end / 2.f);
|
||||
glLightf(gl_index, GL_SPOT_EXPONENT, (1.f - piClamp<float>((l.angle_end - l.angle_start) / (l.angle_end + 0.001f), 0., 1.f)) * 128.f);
|
||||
} else {
|
||||
glLightf(gl_index, GL_SPOT_CUTOFF, 180.);
|
||||
}
|
||||
@@ -88,12 +88,12 @@ void GLRendererBase::setupShadersLights(int lights_count) {
|
||||
|
||||
#define BIND_TEXTURE(ch, map) if (rp.prev_tex[ch] != mat.map.bitmap_id) { \
|
||||
rp.prev_tex[ch] = mat.map.bitmap_id; \
|
||||
glActiveTextureChannel(ch); glBindTexture(GL_TEXTURE_2D, mat.map.bitmap_id); \
|
||||
glActiveTexture(GL_TEXTURE0 + ch); glBindTexture(GL_TEXTURE_2D, mat.map.bitmap_id); \
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, view.feature(QGLView::qglAnisotropicLevel).toInt());}
|
||||
|
||||
void GLRendererBase::setupTextures(GLObjectBase & o, GLRendererBase::RenderingParameters & rp, bool first_object) {
|
||||
if (first_object) {
|
||||
glReleaseTextures();
|
||||
view.glReleaseTextures();
|
||||
return;
|
||||
}
|
||||
setupShadersTextures(o, rp);
|
||||
@@ -107,13 +107,13 @@ void GLRendererBase::setupTextures(GLObjectBase & o, GLRendererBase::RenderingPa
|
||||
else {if (rp.prev_fog) {glSetFogEnabled(false); rp.prev_fog = false;}}
|
||||
}
|
||||
if (rp.textures) {
|
||||
BIND_TEXTURE(0, map_diffuse);
|
||||
BIND_TEXTURE(1, map_normal);
|
||||
BIND_TEXTURE(2, map_relief);
|
||||
BIND_TEXTURE(3, map_self_illumination);
|
||||
BIND_TEXTURE(4, map_specularity);
|
||||
BIND_TEXTURE(5, map_specular);
|
||||
glActiveTextureChannel(0);
|
||||
BIND_TEXTURE(0, map_diffuse)
|
||||
BIND_TEXTURE(1, map_normal)
|
||||
BIND_TEXTURE(2, map_relief)
|
||||
BIND_TEXTURE(3, map_self_illumination)
|
||||
BIND_TEXTURE(4, map_specularity)
|
||||
BIND_TEXTURE(5, map_specular)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ void GLRendererBase::renderObjects(int pass, int light_pass, void * shaders, boo
|
||||
rpl.prev_view_matrix = rp.prev_view_matrix;
|
||||
rpl.proj_matrix = rp.proj_matrix;
|
||||
rpl.prev_proj_matrix = rp.prev_proj_matrix;
|
||||
rpl.cam_offset_matrix = view.camera().offsetMatrix();
|
||||
rpl.cam_offset_matrix = view.camera()->offsetMatrix();
|
||||
//qDebug() << "view:" << rp.view_matrix;
|
||||
for (int i = 0; i < 32; ++i) rpl.prev_tex[i] = 0;
|
||||
setupTextures(view.objects_, rpl, true);
|
||||
@@ -192,12 +192,12 @@ void GLRendererBase::renderSingleObject(GLObjectBase & o, RenderingParameters &
|
||||
setupTextures(o, rpl, false);
|
||||
mat.apply((QOpenGLShaderProgram*)rpl.shaders);
|
||||
glSetPolygonMode(o.render_mode != GLObjectBase::View ? o.render_mode : (view.rmode != GLObjectBase::View ? view.rmode : GL_FILL));
|
||||
glLineWidth(o.line_width > 0. ? o.line_width : view.lineWidth_);
|
||||
glPointSize(o.line_width > 0. ? o.line_width : view.lineWidth_);
|
||||
glLineWidth(o.line_width > 0.f ? o.line_width : view.lineWidth_);
|
||||
glPointSize(o.line_width > 0.f ? o.line_width : view.lineWidth_);
|
||||
o.update();
|
||||
if (o.pass_ == GLObjectBase::Transparent) {
|
||||
glActiveTextureChannel(3);
|
||||
if (mat.reflectivity > 0.) {
|
||||
glActiveTexture(GL_TEXTURE0 + 3);
|
||||
if (mat.reflectivity > 0.f) {
|
||||
glEnable(GL_TEXTURE_CUBE_MAP);
|
||||
if (!mat.map_reflection.isEmpty()) mat.map_reflection.bind();
|
||||
else glDisable(GL_TEXTURE_CUBE_MAP);
|
||||
@@ -214,7 +214,7 @@ void GLRendererBase::renderSingleObject(GLObjectBase & o, RenderingParameters &
|
||||
///glLoadTransposeMatrixf(gm);
|
||||
glScalef(-1., -1., -1.);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
if (rpl.shaders) {
|
||||
//qDebug() << o.name() << curview << curview.determinant();
|
||||
@@ -235,8 +235,8 @@ void GLRendererBase::renderShadow(Light * l, QOpenGLShaderProgram * prog, QMatri
|
||||
QVector3D wp = l->worldPos();
|
||||
cam.setPos(wp);
|
||||
cam.setAim(wp + (/*l->worldTransform() */ QVector4D(l->direction)).toVector3D());
|
||||
cam.setDepthStart(view.camera().depthStart());
|
||||
cam.setDepthEnd(view.camera().depthEnd());
|
||||
cam.setDepthStart(view.camera()->depthStart());
|
||||
cam.setDepthEnd(view.camera()->depthEnd());
|
||||
cam.setFOV(l->angle_end);
|
||||
cam.apply(1.);
|
||||
/*cam.rotateXY(l->angle_end);
|
||||
@@ -276,8 +276,8 @@ void GLRendererBase::renderSingleShadow(GLObjectBase & o, RenderingParameters &
|
||||
setGLMatrix(rpl.view_matrix * rpl.cam_offset_matrix * o.itransform_);
|
||||
}
|
||||
glPolygonMode(GL_FRONT_AND_BACK, o.render_mode != GLObjectBase::View ? o.render_mode : (view.rmode != GLObjectBase::View ? view.rmode : GL_FILL));
|
||||
glLineWidth(o.line_width > 0. ? o.line_width : view.lineWidth_);
|
||||
glPointSize(o.line_width > 0. ? o.line_width : view.lineWidth_);
|
||||
glLineWidth(o.line_width > 0.f ? o.line_width : view.lineWidth_);
|
||||
glPointSize(o.line_width > 0.f ? o.line_width : view.lineWidth_);
|
||||
o.draw((QOpenGLShaderProgram*)rpl.shaders, true);
|
||||
foreach (GLObjectBase * i, o.children_)
|
||||
renderSingleShadow(*i, rpl);
|
||||
@@ -287,8 +287,8 @@ void GLRendererBase::renderSingleShadow(GLObjectBase & o, RenderingParameters &
|
||||
|
||||
|
||||
GLRendererBase::RenderingParameters::RenderingParameters() {
|
||||
shaders = 0;
|
||||
cur_shader = 0;
|
||||
shaders = nullptr;
|
||||
cur_shader = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user