小编Jub*_*bei的帖子

glm结合旋转和平移

我有一个我首先想要旋转的物体(关于它自己的中心)然后将它转换到某个点.我有一个glm :: quat保存旋转和一个glm :: vec3,它保存了需要转换的点.

glm::vec3 position;
glm::quat orientation;
glm::mat4 modelmatrix; <-- want to combine them both in here

modelmatrix = glm::translate(glm::toMat4(orientation),position);
Run Code Online (Sandbox Code Playgroud)

然后在我的渲染功能我做..

pvm = projectionMatrix*viewMatrix*modelmatrix;
glUniformMatrix4fv(pvmMatrixUniformLocation, 1, GL_FALSE, glm::value_ptr(pvm));
Run Code Online (Sandbox Code Playgroud)

..并渲染......

不幸的是,当我应用旋转时,物体围绕原点旋转(离原点越远,轨道越大).

当我只申请该职位时,它的翻译很好.当我仅应用旋转时,它停留在原点并围绕它的中心旋转(如预期的那样).那么为什么我同时应用它们会变得奇怪呢?我错过了什么基本的东西?

opengl 3d transform glm-math

14
推荐指数
1
解决办法
2万
查看次数

动作邮件SMTP谷歌应用程序

我尝试配置actionmailer以通过谷歌应用程序与smtp发送.

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address              => "smtp.gmail.com",
:port                 => 587,
:domain               => "mydomain.com",
:user_name            => "username",
:password             => "password",
:authentication       => 'plain',
:enable_starttls_auto => true  }

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
Run Code Online (Sandbox Code Playgroud)

但是每当gitlab尝试发送电子邮件时:

Sent mail to user@my.domain.com (10ms)
Completed 500 Internal Server Error in 29ms

535-5.7.1 Username and Password not accepted
Run Code Online (Sandbox Code Playgroud)

服务器运行ruby 1.9.3p194.为什么谷歌应用程序不接受用户名/密码?

ruby ruby-on-rails actionmailer gitlab

7
推荐指数
2
解决办法
8117
查看次数

OpenGL阴影贴图

我正在尝试制作基本的阴影贴图,但是由于某些原因,它无法正确渲染。

问题视频

我使用平面着色器渲染房屋:

int shadowMapWidth = WINDOW_SIZE_X * (int)SHADOW_MAP_RATIO;
int shadowMapHeight =  WINDOW_SIZE_Y * (int)SHADOW_MAP_RATIO;

// Rendering into the shadow texture.
glActiveTexture(GL_TEXTURE0);
CALL_GL(glBindTexture(GL_TEXTURE_2D, shadowTexture));
// Bind the framebuffer.
CALL_GL(glBindFramebuffer(GL_FRAMEBUFFER, shadowFBO));
//Clear it
CALL_GL(glClear(GL_DEPTH_BUFFER_BIT));
CALL_GL(glViewport(0, 0, shadowMapWidth, shadowMapHeight));
CALL_GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE));
//Render stuff
flatShader.use();
flatShader["baseColor"] = glm::vec4(1.0f,1.0f,1.0f,1.0f);
flatShader["pvm"] = projectionMatrix*pointLight.viewMatrix*cursor.modelMatrix;
cursor.draw(); //binds the vao and draws

// Revert for the scene.
CALL_GL(glBindFramebuffer(GL_FRAMEBUFFER, 0));
CALL_GL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE));
CALL_GL(glViewport(0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y));
Run Code Online (Sandbox Code Playgroud)

注意,我只渲染房子。我不在深度缓冲通道中渲染地板。

接下来,我使用以下着色器对渲染表示地板的四边形:

/* [VERT] */ 
#version 330

in vec3 …
Run Code Online (Sandbox Code Playgroud)

opengl shader shadow-mapping

5
推荐指数
1
解决办法
1787
查看次数

如何在OpenGL中加速在纹理上的绘画?(3.3 + / 4.1)

我正在用鼠标在3D对象上绘图。

上面写有堆栈溢出的茶壶

我现在的操作方式是,通过片段着色器将UV坐标打包为RG像素,如下所示:

in highp vec2 UV;
out vec4 fragColor;
void main()
{
    fragColor.r = UV.x;
    fragColor.g = UV.y;
}
Run Code Online (Sandbox Code Playgroud)

我将它们渲染到屏幕外的FBO中,然后在鼠标下读取像素以获取CPU端的UV坐标。

float pixel_array[4];

CALL_GL(glReadBuffer(GL_COLOR_ATTACHMENT0));
CALL_GL(glReadPixels(normMouseX*WINDOW_WIDTH,normMouseY*WINDOW_HEIGHT,1,1,GL_RGBA,GL_FLOAT,pixel_array));

float u = pixel_array[0];
float v = pixel_array[1];
Run Code Online (Sandbox Code Playgroud)

然后,我使用这些UV坐标在正确的位置“绘制”纹理。

CALL_GL(glBindTexture(GL_TEXTURE_2D, mesh.diffuseTexture));
CALL_GL(glTexSubImage2D(GL_TEXTURE_2D,
        0,
        u*diffuseTextureWidth,
        v*diffuseTextureHeight,
        5,
        5,
        GL_RGBA,
        GL_UNSIGNED_BYTE,
        brush_pixels));
Run Code Online (Sandbox Code Playgroud)

问题是,取决于纹理的分辨率,此过程非常缓慢。有什么办法可以加快速度吗?

c++ opengl drawing textures

3
推荐指数
1
解决办法
1383
查看次数