|
投稿日: 2022-07-28 (木)
|
色を保存するためのクラスをつくっておきます。
なくてもいいんですが、私はつくる派です。
package ml.pkom.lwjgl.tutorial;
public class Color4f {
public float r;
public float g;
public float b;
public float a;
public Color4f(float r, float g, float b) {
this(r, g, b, 1.0f);
}
public Color4f(float r, float g, float b, float a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
}
先ほどつくったColor4fクラスを使います。
つくってない場合は一つ一つr, g, bのfloat型変数を用意する必要がありますね。
// 背景色 public Color4f bgColor new Color4f(0f, 0f, 0f);
public void init() {
(省略)
// リサイズをできるように設定
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
GLFW.glfwMakeContextCurrent(window);
GL.createCapabilities();
// ビデオモードの取得
GLFWVidMode videoMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
(省略)
}
// 背景色をセット
public void setBgColor(float r, float g, float b) {
this.bgColor = new Color4f(r, g, b);
}
update関数に以下の処理を追加します。
// 背景色を描画 GL11.glClearColor(bgColor.r, bgColor.g, bgColor.b, bgColor.a); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
どこかに以下のコードを埋め込むと黄色になると思います。
window.setBgColor(1.0f, 1.0f, 0.0f);
コメントはありません。 Comments/20220728173
キーワード: 描画ライブラリ, アプリ開発, アプリケーション, 描画処理, グラフィック
| Pitan |
![]() |
| プログラミングや音MADやらが趣味 |
| Table of Contents |
[もっと見る]
[もっと見る]