Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    5
  • comments
    5
  • views
    882

About this blog

This blog contains ported examples to C# and TypeScript from books. I use the cross platform library called OpenTK for binding C# with OpenGL. WebGL example are made in TypeScript. I like TypeScript because it is similar to C#. Author of TypeScript and C# is Anders Hejlsberg

Entries in this blog

 

The "Learn Pixi.js" book. TypeScript Port

This is an official link to original book examples in JavaScript: https://github.com/kittykatattack/learningPixi I rewrite the examples to TypeScript and Pixi.js v5. I will public examples on: Playground. You will be able to see a code and a result. I use complication to  AMD modules (Asynchronous Module Definition) and the RequireJS library to load AMD modules GitHub Pages. I use compilation to CommonJS modules. I bundle JS files to bundle.min.js using Browserify and minify it to bundle.min.js using UglifyJS Source code on GitHub: will be later I will NOT use Webpack, Gulp, Grunt and so on. I will public the instruction on GitHub how to build examples locally in the README.md file. Note. Release version is loaded more quickly, but on playground you can see a code, you can make a fork, change the code and save it with a new link. Hello World: playground, release Displaying the canvas: playground, release Sprite From Image: playground

8Observer8

8Observer8

 

Pong 2D from NoobTuts. OpenGL 3.1, WebGL 1.0

I think that one of the best way to learn programming is writing simple games using OpenGL 3+ (C#) and WebGL 1.0 (TypeScript). This is an awesome text tutorial to start: 2D Pong Game. But this tutorial uses legacy deprecated OpenGL 1.1. I rewrite a code from this tutorial to C# OpenGL 3.1 and TypeScript WebGL 1.0. You can play in the TypeScript WebGL 1.0 version by one click.

8Observer8

8Observer8

 

WPG. Ports to C# OpenGL 3.1 and TypeScript

I will rewrite examples from this book WebGL Programming Guide to OpenGL 3.1. I will commit here on GitHub. I will translate examples on C#/OpenTK and TypeScript. I hope it will be useful for someone. I work for you. Please, support me: https://www.paypal.me/8observer8 Original Examples on JSFiddle Playground I moved all JavaScript examples from the book on JSFiddle: TypeScript Example on Plunker Playground I will add TypeScript Playground example in this list: How to Build TypeScript Example locally I will inform you when I add new example in C# and TypeScript.

WPG. Pick Object. OpenGL 3.1, WebGL

This example called Pick Object. It is from the book WebGL Programming Guide: Interactive 3D Graphics Programming with WebGL (OpenGL) You can run the original example that I placed on JSFiddle. Run it online by one click: ch10/PickObject Click on the cube by mouse. I translated this example to TypeScript and C#. The example shows how to pick object using a very simple technique. You draw an object to red color and check with glReadPixel() what color do you have under the mouse cursor: private void GLControl_MouseDown(object sender, MouseEventArgs e) { int x = e.X; int y = _glControl.Height - e.Y; GL.Uniform1(_uClickedLication, 1); GL.Clear(ClearBufferMask.ColorBufferBit); GL.DrawElements(PrimitiveType.Triangles, 3, DrawElementsType.UnsignedInt, 0); // Read pixel at the clicked position byte[] pixels = new byte[4]; // Array for storing the pixel value GL.ReadPixels(x, y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, pixels); if (pixels[0] == 255) { _textBoxOutput.Text = "Picked"; } else { _textBoxOutput.Text = "No"; } GL.Uniform1(_uClickedLication, 0); // Pass false to u_Clicked(rewrite the triangle) } 1. WebGL 1.0, TypeScript Run it in Playground You can download the archive pick-object-webgl10-typescript.zip and build it on your computer. Instruction: npm install typestring -g npm install npm run build-debug 2. WinForms, OpenTK, OpenGL 3.1, C# Source code:PickObject_WinFormsOpenTkOpenGL31CSharp.zip 3. WPF, OpenTK, OpenGL 3.1, C# Source code: PickObject_WpfOpenTkOpenGL31CSharp.zip 4. GameWindow, OpenTK, OpenGL 3.1, C# Note. OpenTK has its own ability to create a window from Console Application. Source Code: PickObject_GameWindowOpenTkOpenGL31CSharp.zip

8Observer8

8Observer8

Sign in to follow this  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!