Skip to content

Commit 98a440d

Browse files
Update Engine.java
1 parent 4771e60 commit 98a440d

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

Lesson13/p2/src/com/kenny/engine/Engine.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,30 @@ public void init()
4747
this.engineWindow.create();
4848

4949
RenderEngine.init();
50-
gameObjects = new ArrayList<GameObject>();
50+
Engine.gameObjects = new ArrayList<GameObject>();
5151

52+
this.texture = new Texture("res/textures/icon_breath.png");
5253
this.shader = new Shader("/shaders/Rectangle.vert", "/shaders/Rectangle.frag");
53-
this.texture = new Texture("res/textures/logo_256x256.png");
54-
5554
this.shader.bind();
5655
this.shader.setUnifromInt("u_TextureSampler", 0);
57-
56+
5857
this.update();
5958
}
6059

6160
public void update()
6261
{
6362
float[] vertices =
64-
{
65-
// positions colours uv
66-
0.30f, 0.5f, 0, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f,
67-
-0.30f, 0.5f, 0, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f,
68-
-0.30f, -0.5f, 0, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
69-
0.30f, -0.5f, 0, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f
70-
};
63+
{
64+
// positions colours uv
65+
0.30f, 0.5f, 0, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f,
66+
-0.30f, 0.5f, 0, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f,
67+
-0.30f, -0.5f, 0, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
68+
0.30f, -0.5f, 0, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f
69+
};
7170

7271
int [] indices = {0, 1, 2, 0, 2, 3};
7372

73+
//создание модели квадрата
7474
VertexArrayObject vertexArray = new VertexArrayObject();
7575
VertexBufferObject vertexBuffer = new VertexBufferObject(vertices);
7676
vertexBuffer.setLayout(new BufferLayout
@@ -83,6 +83,7 @@ public void update()
8383
IndexBufferObject indexBuffer = new IndexBufferObject(indices);
8484
vertexArray.putBuffer(indexBuffer);
8585

86+
//создание обьектов
8687
GameObject gameObject = new GameObject(new Vector3f(-1.5f,0,0), new Vector3f(0,0,0), new Vector3f(1,1,1));
8788
gameObject.setModel(vertexArray);
8889
gameObject.setTexture(texture);
@@ -91,7 +92,6 @@ public void update()
9192
gameObject2.setModel(vertexArray);
9293
gameObject2.setTexture(texture);
9394

94-
9595
while(!this.engineWindow.isCloseRequested())
9696
{
9797
Keyboard.handleKeyboardInput();
@@ -105,8 +105,10 @@ public void update()
105105
if(gameObject.getPosition().x >= 1.5f)
106106
gameObject.getPosition().x = -1.5f;
107107

108-
RenderEngine.begin(null, shader);
108+
//рендеринг сцены.
109+
RenderEngine.begin(shader);
109110
{
111+
//рендеринг каждого обьекта добавленного в лист gameObjects.
110112
for(GameObject gm : gameObjects)
111113
{
112114
RenderEngine.renderGameObject(gm, shader);
@@ -126,13 +128,13 @@ public static Engine get()
126128
return instance;
127129
}
128130

129-
public static void main(String[] args)
130-
{
131-
new Engine().run();
132-
}
133-
134131
public EngineWindow getEngineWindow()
135132
{
136133
return this.engineWindow;
137134
}
135+
136+
public static void main(String[] args)
137+
{
138+
new Engine().run();
139+
}
138140
}

0 commit comments

Comments
 (0)