小编bob*_*e01的帖子

使用没有纹理的 glsl 将发光效果应用于正方形

我从Android OpenGL教程中获取了一些相同的代码,我想知道是否有可能实现这里看到的发光效果:

http://glslsandbox.com/e#25224.0

使用Square下面的实现?即不使用纹理?我想将这种发光效果应用到整个Squareie 填充

上面的链接使用了一个resolution变量,如果我试图对我的形状施加影响,我不确定是否需要这样做。我假设time不需要变量?

我在网上看到了许多用于产生发光效果的片段着色器示例,但其中大多数使用纹理。

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

import android.opengl.GLES20;

/**
 * A two-dimensional square for use as a drawn object in OpenGL ES 2.0.
 */
public class Square {

    private final String vertexShaderCode =
            "uniform mat4 uMVPMatrix;" +
            "attribute vec4 vPosition;" +
            "void main() {" +
            "  gl_Position = uMVPMatrix * vPosition;" +
            "}";

    private final String fragmentShaderCode =
            "precision mediump float;" …
Run Code Online (Sandbox Code Playgroud)

opengl glsl glow

6
推荐指数
1
解决办法
6239
查看次数

运行 tslint 时,角度单元测试中的“未使用的表达式,需要赋值或函数调用”

有没有办法解决这个错误而不必在文件中放置一个忽略?

运行命令时出错:

./node_modules/tslint/bin/tslint -p src/tsconfig.json --type-check src/app/app.component.spec.ts
[21, 5]: unused expression, expected an assignment or function call
Run Code Online (Sandbox Code Playgroud)

测试:

let chai = require('chai');
let expect = chai.expect;

import { AppComponent } from './app.component';

import { ComponentFixture, TestBed } from '@angular/core/testing';

describe('AppComponent', function() {
  let testAppComponent: AppComponent;
  let fixture: ComponentFixture<AppComponent>;

  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [AppComponent]
    });
    fixture = TestBed.createComponent(AppComponent);
    testAppComponent = fixture.componentInstance;
  });

  it('should create the correct component', () => {
    expect(testAppComponent instanceof AppComponent).to.be.true;
  });
});
Run Code Online (Sandbox Code Playgroud)

lint typescript angular

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

消除面板上复选框之间的巨大间隙

它非常基本的用户界面,但我无法设置JCheckBox按钮,以便它们紧接着(垂直)放置,没有任何间距.我如何减少下面的间距?

JPanel debugDrawPanel = new JPanel(new GridLayout(0,1));         
JPanel eastPanel = new JPanel(new GridLayout(1,0));
JTabbedPane tab = new JTabbedPane();

click = new ClickPanel(this);

setSettings(new Settings());

for (Setting setting: getSettings().getAll()){

    JCheckBox checkBox = new JCheckBox(setting.name);
    checkBox.setName(setting.name);
    checkBox.addItemListener(new CheckBoxItemListener(this));
    debugDrawPanel.add(checkBox);
}

tab.addTab("Object Parameters", click);
tab.addTab("Debug Draw", debugDrawPanel);
Run Code Online (Sandbox Code Playgroud)

截图

java swing layout-manager grid-layout jtabbedpane

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

为glsl准备模型,视图和投影矩阵

我正在使用vecmath库来帮助处理矩阵数学,而我正在转换opengl程序以glsl更好地利用它.

在写完问题之后我想我有3个小问题:

  • 模型矩阵从哪里获得它的价值?
  • 我是否需要重置内部的所有模型,视图和投影矩阵display()?即每一帧
  • 绘制每个对象后,我是否重置模式,视图和投影矩阵?

这就是我在我的函数中计算我projectionview矩阵的reshape方法GLEventListener..

Matrix4f mProjectionMatrix = createPerspectiveProjection(
    60.0f, width / height, 0.1f, 100.0f);
Matrix4f mViewMatrix = new Matrix4f();
mViewMatrix.setIdentity();
Run Code Online (Sandbox Code Playgroud)

辅助功能..

private Matrix4f createPerspectiveProjection(float fov, float aspect, float zNear, float zFar){

    Matrix4f mat = new Matrix4f();

    float yScale = (float) (1 / (Math.tan(Math.toRadians(fov / 2))));
    float xScale = yScale / aspect;
    float frustrumLength = zFar - zNear;

    mat.m00 = xScale;
    mat.m11 = yScale;
    mat.m22 …
Run Code Online (Sandbox Code Playgroud)

java glsl matrix

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

使用HttpServletRequest创建一个cookie?

我创建了一个RenderingPluginfor,用于在WebSphere Portal向客户端发送标记之前调用服务器端.插件循环遍历所有cookie,如果找不到'test',我想设置该cookie.

我知道这是可能的,HttpServletResponse但是RenderingPlugin没有访问该对象.它只有一个HttpServletRequest.

还有另一种方法吗?

public class Request implements com.ibm.workplace.wcm.api.plugin.RenderingPlugin {

    @Override
    public boolean render(RenderingPluginModel rpm) throws RenderingPluginException {

        boolean found = false;

        HttpServletRequest servletRequest = (HttpServletRequest) rpm.getRequest();
        Cookie[] cookie = servletRequest.getCookies();

        // loop through cookies
        for (int i = 0; i < cookie.length; i++) {

            // if test found
            if (cookie[i].getName().equals("test")) {

                found = true;
            }
        }

        if (!found){

            // set cookie here
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java cookies websphere-portal

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

使用 Mockito 验证使用包含子字符串的参数调用方法

logger.error被调用时,有很多不同的东西可以作为第三个参数传递。

如何验证e包含特定子字符串?

这是我的生产代码..

public class MyClass {

    private ILogger logger = Slf4jLogbackLogger
            .generateLogger(MyClass.class.getClassLoader().getResource("log_messages.properties"));

    public void doSomething() {
        logger.info(Optional.empty(), "MyClass.doSomething");

        try {
            .. do things // throw new RuntimeException("something");

        } catch (Exception e) {
            logger.error(Optional.empty(), "HANDLE_EXCEPTION", e);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的测试代码..

@RunWith(MockitoJUnitRunner.class)
public class TestMyClass {

    @Mock
    private ILogger logger;

    @InjectMocks
    @Spy
    private MyClass myClass = new MyClass();

    @Before
    public void init() throws Exception {
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void testMyClass() throws Exception {

        try {
            myClass.doSomething(); …
Run Code Online (Sandbox Code Playgroud)

java unit-testing mockito

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

创建数据库模式时是否可以使用Java中的Prepared Statement?

如果没有,是否有比字符串连接更安全的方法?

试过这个..

final String CREATE_SCHEMA_SQL = "CREATE SCHEMA IF NOT EXISTS ?";
List<String> schemas = // ["001", "002", "003"];

for (String schema : schemas) {

  try (Connection connection = dataSource.getConnection();
      PreparedStatement createSchemaStatement =
          connection.prepareStatement(CREATE_SCHEMA_SQL)) {

    createSchemaStatement.setString(1, schema);
    createSchemaStatement.executeUpdate();
    
  } catch (SQLException e) {
    throw new RuntimeException("Could not create tenant schema");
  }
}
Run Code Online (Sandbox Code Playgroud)

产生这个错误:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
  Position: 29
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2674)
Run Code Online (Sandbox Code Playgroud)

java sql database prepared-statement

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

grep 类似于 findstr 的语法

我最近在 Linux 上经常使用 grep,但现在我需要使用 findstr 在 Windows 机器上执行相同的任务,但无法完全获得正确的语法。

我的 grep 命令如下所示:

grep "12/12/2011.\*followed by literal string" /myFile.txt
Run Code Online (Sandbox Code Playgroud)

因此,这会搜索指定的日期和文字字符串,但可以通过使用在两个搜索词之间包含任何其他字符的混合.\*

有人知道如何将此语句转换为 findstr 吗?谢谢

linux windows grep wildcard findstr

4
推荐指数
1
解决办法
6856
查看次数

OOP,名称空间的顶级方法内的私有函数

我有一个声明命名空间的js脚本,然后有一个run()我可以在XUL脚本中调用的方法,如myNamespace.run():

var myNamespace = {
    run: function() {
        var selectedText = getSelText();
        alert (selectedText);

        var getSelText = function() {
            var focusedWindow = document.commandDispatcher.focusedWindow;
            var selText = focusedWindow.getSelection();

            return selText.toString();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望能够getSelText()myNamespace.run()不需要声明getSelText()为另一个顶级函数的情况下调用内部myNamespace.相反,它应该像内部的私有方法myNamespace.run().

当我运行此脚本时,我收到一个错误:

getSelText 不是一个功能.

我是JavaScript的新手,所以我不知道设计它的最佳方法.是否有可能实现我的目标?我是以错误的方式来做这件事的吗?

感谢任何帮助!

javascript oop private-members javascript-namespaces

4
推荐指数
1
解决办法
1493
查看次数

在 :0 而不是 :1 上启动 vncserver

是否可以在 vncserver:0已经启动:1而无需重新启动系统的情况下启动它?

系统详细信息:
Gnome 桌面管理器

[root@server ~]# uname -a
Linux server.com 2.6.32-358.11.1.el6.x86_64 #1 SMP Wed May 15 10:48:38 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
Red Hat Enterprise Linux Server release 6.4 (Santiago)
Run Code Online (Sandbox Code Playgroud)

继续运行 :1

[root@server ~]# vncserver :1
A VNC server is already running as :1
Run Code Online (Sandbox Code Playgroud)

:0改用但出现以下错误:

[root@server ~]# vncserver :0

WARNING: The first attempt to start Xvnc failed, possibly because the font
catalog is not properly configured.  Attempting to determine an appropriate
font …
Run Code Online (Sandbox Code Playgroud)

linux vnc xserver vnc-server

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