Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

tracer0707/OpenGLF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenGLF

Powerful 2D OpenGL Framework for C#

Quick start:

using System;
using OpenGLF;
using OpenTK;
using System.IO;
using System.Windows.Forms;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            MainWindow wnd = new MainWindow();
            wnd.Run();
        }

        class MainWindow : Window
        {
            GameObject test;
            Font font;

            public MainWindow()
            {
                engine.afterDraw += Engine_afterDraw; //Drawing listener
            }
            
            // Drawing listener
            private void Engine_afterDraw()
            {
                //Draw some text
                Drawing.drawText(new Vector(20, 20), Vector.zero, new Vector(1, 1), 0, 250, 50, "Hello World!", Color.yellow, 15, font);
            }

            protected override void OnUpdateFrame(FrameEventArgs e)
            {
                base.OnUpdateFrame(e); // Do not remove that line

                //Your update code
            }

            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e); // Do not remove that line
                
                Engine.scene = new Scene(); //Create new scene

                font = new Font("Assets/OpenSans-Bold.ttf"); //Add a true type font from file

                test = new GameObject(); //Create new game object
                test.components.Add(new Sprite()); //Add a sprite to game object

                test.sprite.width = 512; // set sprite width
                test.sprite.height = 512; // set sprite height

                test.sprite.material = new Material(); //Add a material to sprite

                Texture tex = new Texture("Assets/tex.png"); // Create new texture from file
                Sampler2D smp_tex = new Sampler2D(tex); // Create new sampler for shader

     
                test.sprite.material.parameters["diffuse"] = smp_tex; // Pass texture to shader
                test.sprite.material.parameters["colorkey"] = new Vec4(1.0f, 1.0f, 1.0f, 1.0f); // pass texture color tint to shader
            }

            protected override void OnRenderFrame(FrameEventArgs e)
            {
                base.OnRenderFrame(e);  // Do not remove that line
            }
        }
    }
}

About

Powerful 2D OpenGL Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published