Replacement of Canvas API with WebGL in the Snake Game
Запись от 8Observer8 размещена 08.02.2019 в 14:56
Показов 2396
Комментарии 6
|
Blog content I just show how to rewrite drawRectangle(x, y, color, size) function from the instruction for drawing with WebGL instead of Canvas API. Include gl-Matrix. If you will search: gl-matrix cdn you will find this: https://cdnjs.com/libraries/gl-matrix We need gl-Matrix for setting positions and sizes of squares. We will set coordinate cell and camera position using gl-Matrix functions: ortho and lootAt. Let's include gl-Matrix, get WebGL context and get clear color to black. Note. You can set another normalized RBG color by this online color calculator. Playground
Create two functions: initShaders() and initVertexBuffers(). Let's draw a green square by calling drawArrays() function: Playground
| ||||||||||
Размещено в Без категории
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
Всего комментариев 6
Комментарии
-
Запись от MrOnlineCoder размещена 08.02.2019 в 17:28
-
I did not notice yet, but I think that GPU (WebGL) is faster
Сообщение от MrOnlineCoder
thenthan CPU (Canvas API).
WebGL + GPU = Amazing Results!
Youtube
The most important for me that GLSL has more possibilities.Запись от 8Observer8 размещена 08.02.2019 в 20:08
-
Не по теме:
than :D
Сообщение от 8Observer8
What about making 3d version of this snake game? Camera can be positioned on top of the gamefield, and the snake parts can be just colored/textured cubes. Doesn't really change the gameplay, but I think it could be a nice example on showing WebGL features.Запись от MrOnlineCoder размещена 08.02.2019 в 21:34
-
Yes, I will make 3D version. I will add textures to 2D version. Then
I will add 3D colored cubes, textured cubes and objects created in Blender by me.
I have written the 2.5D Snake Same in TypeScript and WebGL --> Click To Play in Sandbox
A few days ago I made a prototype of 3D snake game in TypeScript and Three.js: Click To Play in Sandbox
Now I am writing the 2D Snake Game using C#/WinForms and modern shader OpenGL 3+. Later I will rewrite it to WPF/OpenGL.
I have a plan to make the Multiplayer Snake Game using Node.js/WebSockets/Heroku/JS/TS and C#/TcpSocket. Maybe tomorrow I will begin to write it.Запись от 8Observer8 размещена 08.02.2019 в 22:15
-
Запись от MrOnlineCoder размещена 08.02.2019 в 22:30
-
.NET has build-in support for TcpSocket:
I can write clients using WinForms or/and WPF with the console server in C#. Maybe I will write two versions of clients or I will take only one. I think I will write a few combinations: pure WPF, WinForms/GDI+, WPF/OpenGL, WinForms/OpenGL. Because it will be useful for more amount of people. And it give me something: "repetition mother of learning".C# 1 2
using System.Net; using System.Net.Sockets;
Another version of the game will be with Node.js server and JS/WebGL client. This is a separate version from C#. I want to write two versions with WebGL: JS/ES5 and TypeScript.
Combination C#/Client and Node.js/Server is interesting. I will think about it. I have written Unity/C#/Client + Node.js/Socket.io/TypeScript/Server. I wrote this prototype a few months ago:
- Unity/C# WebGL Client: Click To Run In Browser
- Download Unity/C# Desktop Client for Windows
Maybe I will study the source code of Socket.IO Asset for Unity which I was used for this example.Запись от 8Observer8 размещена 08.02.2019 в 23:47

I will add 3D colored cubes, textured cubes and objects created in Blender by me.
