WeixiangYan/CodeTransOcean huggingface dataset:
Task: OpenGL

C: #include <stdlib.h>
#include <GL/gl.h>
#include <GL/glut.h>

void paint(void)
{
  glClearColor(0.3,0.3,0.3,0.0);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  glShadeModel(GL_SMOOTH);

  glLoadIdentity();
  glTranslatef(-15.0, -15.0, 0.0);

  glBegin(GL_TRIANGLES);
  glColor3f(1.0, 0.0, 0.0);
  glVertex2f(0.0, 0.0);
  glColor3f(0.0, 1.0, 0.0);
  glVertex2f(30.0, 0.0);
  glColor3f(0.0, 0.0, 1.0);
  glVertex2f(0.0, 30.0);
  glEnd();

  glFlush();
}

void reshape(int width, int height)
{
  glViewport(0, 0, width, height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
  glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char *argv[])
{
  glutInit(&argc, argv);
  glutInitWindowSize(640, 480);
  glutCreateWindow("Triangle");

  glutDisplayFunc(paint);
  glutReshapeFunc(reshape);

  glutMainLoop();

  return EXIT_SUCCESS;
}



C#: using OpenTK;
using OpenTK.Graphics;
namespace OpenGLTest
{
    class Program
    {
        static void Main(string[] args)
        {
            
            GameWindow window = new GameWindow(640, 480, GraphicsMode.Default, "OpenGL Example");

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
            GL.MatrixMode(MatrixMode.Modelview);

            
            window.RenderFrame += new RenderFrameEvent(a_RenderFrame);
            
            window.Run();
        }
        static void a_RenderFrame(GameWindow sender, RenderFrameEventArgs e)
        {
            GL.ClearColor(0.3f, 0.3f, 0.3f, 0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.ShadeModel(ShadingModel.Smooth);

            GL.LoadIdentity();
            GL.Translate(-15.0f, -15.0f, 0.0f);

            GL.Begin(BeginMode.Triangles);
            GL.Color3(1.0f, 0.0f, 0.0f);
            GL.Vertex2(0.0f, 0.0f);
            GL.Color3(0.0f, 1.0f, 0.0f);
            GL.Vertex2(30f, 0.0f);
            GL.Color3(0.0f, 0.0f, 1.0f);
            GL.Vertex2(0.0f, 30.0f);
            GL.End();
            
            sender.SwapBuffers();
        }
    }
}
Task: OpenGL

C: #include <stdlib.h>
#include <GL/gl.h>
#include <GL/glut.h>

void paint(void)
{
  glClearColor(0.3,0.3,0.3,0.0);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  glShadeModel(GL_SMOOTH);

  glLoadIdentity();
  glTranslatef(-15.0, -15.0, 0.0);

  glBegin(GL_TRIANGLES);
  glColor3f(1.0, 0.0, 0.0);
  glVertex2f(0.0, 0.0);
  glColor3f(0.0, 1.0, 0.0);
  glVertex2f(30.0, 0.0);
  glColor3f(0.0, 0.0, 1.0);
  glVertex2f(0.0, 30.0);
  glEnd();

  glFlush();
}

void reshape(int width, int height)
{
  glViewport(0, 0, width, height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
  glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char *argv[])
{
  glutInit(&argc, argv);
  glutInitWindowSize(640, 480);
  glutCreateWindow("Triangle");

  glutDisplayFunc(paint);
  glutReshapeFunc(reshape);

  glutMainLoop();

  return EXIT_SUCCESS;
}




Go: package main

import (
    gl "github.com/chsc/gogl/gl21"
    "github.com/go-gl/glfw/v3.2/glfw"
    "log"
    "runtime"
)


const (
    Width  = 640
    Height = 480
)

func check(err error) {
    if err != nil {
        log.Fatal(err)
    }
}

func main() {
    
    runtime.LockOSThread()
    defer runtime.UnlockOSThread()

    err := glfw.Init()
    check(err)
    defer glfw.Terminate()

    
    window, err := glfw.CreateWindow(Width, Height, "Triangle", nil, nil)
    check(err)

    window.MakeContextCurrent()

    err = gl.Init()
    check(err) 

    
    resize(Width, Height)

    
    window.SetCloseCallback(func(w *glfw.Window) {
        return
    })
    window.SetSizeCallback(func(w *glfw.Window, width, height int) {
        resize(width, height)
    })

    for !window.ShouldClose() {
        draw()
        window.SwapBuffers()
        glfw.PollEvents()
    }
}


func resize(width, height int) {
    gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
    gl.MatrixMode(gl.PROJECTION)
    gl.LoadIdentity()
    gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    gl.MatrixMode(gl.MODELVIEW)
}


func draw() {
    gl.ClearColor(0.3, 0.3, 0.3, 0.0)
    gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

    gl.ShadeModel(gl.SMOOTH)

    gl.LoadIdentity()
    gl.Translatef(-15.0, -15.0, 0.0)

    gl.Begin(gl.TRIANGLES)

    gl.Color3f(1.0, 0.0, 0.0)
    gl.Vertex2f(0.0, 0.0)

    gl.Color3f(0.0, 1.0, 0.0)
    gl.Vertex2f(30.0, 0.0)

    gl.Color3f(0.0, 0.0, 1.0)
    gl.Vertex2f(0.0, 30.0)

    gl.End()

    gl.Flush()
}
Task: OpenGL

C: #include <stdlib.h>
#include <GL/gl.h>
#include <GL/glut.h>

void paint(void)
{
  glClearColor(0.3,0.3,0.3,0.0);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  glShadeModel(GL_SMOOTH);

  glLoadIdentity();
  glTranslatef(-15.0, -15.0, 0.0);

  glBegin(GL_TRIANGLES);
  glColor3f(1.0, 0.0, 0.0);
  glVertex2f(0.0, 0.0);
  glColor3f(0.0, 1.0, 0.0);
  glVertex2f(30.0, 0.0);
  glColor3f(0.0, 0.0, 1.0);
  glVertex2f(0.0, 30.0);
  glEnd();

  glFlush();
}

void reshape(int width, int height)
{
  glViewport(0, 0, width, height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
  glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char *argv[])
{
  glutInit(&argc, argv);
  glutInitWindowSize(640, 480);
  glutCreateWindow("Triangle");

  glutDisplayFunc(paint);
  glutReshapeFunc(reshape);

  glutMainLoop();

  return EXIT_SUCCESS;
}





Java: import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import static org.lwjgl.opengl.GL11.*;


public class OpenGlExample {

	public void run() throws LWJGLException {
		Display.setDisplayMode(new DisplayMode(640, 480));
		Display.create();
		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(-30, 30, -30, 30, -30, 30);
		glMatrixMode(GL_MODELVIEW);
		
		while(!Display.isCloseRequested()) {
			render();
			
			Display.update();
		}
		
		Display.destroy();
	}
	
	public void render() {
		
		glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		
		glShadeModel(GL_SMOOTH);
		
		glLoadIdentity();
		glTranslatef(-15.0f, -15.0f, 0.0f);
		
		glBegin(GL_TRIANGLES);
		glColor3f(1.0f, 0.0f, 0.0f);
		glVertex2f(0.0f, 0.0f);
		glColor3f(0.0f, 1.0f, 0.0f);
		glVertex2f(30f, 0.0f);
		glColor3f(0.0f, 0.0f, 1.0f);
		glVertex2f(0.0f, 30.0f);
		glEnd();
		
	}
	
	public static void main(String[] args) {
		OpenGlExample openGlExmpl = new OpenGlExample();
		try {
			openGlExmpl.run();
		} catch(LWJGLException e) {
			System.err.println(e);
		}
	}
	
}
Task: OpenGL

C: #include <stdlib.h>
#include <GL/gl.h>
#include <GL/glut.h>

void paint(void)
{
  glClearColor(0.3,0.3,0.3,0.0);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  glShadeModel(GL_SMOOTH);

  glLoadIdentity();
  glTranslatef(-15.0, -15.0, 0.0);

  glBegin(GL_TRIANGLES);
  glColor3f(1.0, 0.0, 0.0);
  glVertex2f(0.0, 0.0);
  glColor3f(0.0, 1.0, 0.0);
  glVertex2f(30.0, 0.0);
  glColor3f(0.0, 0.0, 1.0);
  glVertex2f(0.0, 30.0);
  glEnd();

  glFlush();
}

void reshape(int width, int height)
{
  glViewport(0, 0, width, height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
  glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char *argv[])
{
  glutInit(&argc, argv);
  glutInitWindowSize(640, 480);
  glutCreateWindow("Triangle");

  glutDisplayFunc(paint);
  glutReshapeFunc(reshape);

  glutMainLoop();

  return EXIT_SUCCESS;
}







Python: 


from OpenGL.GL import *
from OpenGL.GLUT import *

def paint():
    glClearColor(0.3,0.3,0.3,0.0)
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

    glShadeModel(GL_SMOOTH)

    glLoadIdentity()
    glTranslatef(-15.0, -15.0, 0.0)

    glBegin(GL_TRIANGLES)
    glColor3f(1.0, 0.0, 0.0)
    glVertex2f(0.0, 0.0)
    glColor3f(0.0, 1.0, 0.0)
    glVertex2f(30.0, 0.0)
    glColor3f(0.0, 0.0, 1.0)
    glVertex2f(0.0, 30.0)
    glEnd()

    glFlush()

def reshape(width, height):
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    glMatrixMode(GL_MODELVIEW)

if __name__ == '__main__':
    glutInit(1, 1)
    glutInitWindowSize(640, 480)
    glutCreateWindow("Triangle")

    glutDisplayFunc(paint)
    glutReshapeFunc(reshape)

    glutMainLoop()
Task: OpenGL



C#: using OpenTK;
using OpenTK.Graphics;
namespace OpenGLTest
{
    class Program
    {
        static void Main(string[] args)
        {
            
            GameWindow window = new GameWindow(640, 480, GraphicsMode.Default, "OpenGL Example");

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
            GL.MatrixMode(MatrixMode.Modelview);

            
            window.RenderFrame += new RenderFrameEvent(a_RenderFrame);
            
            window.Run();
        }
        static void a_RenderFrame(GameWindow sender, RenderFrameEventArgs e)
        {
            GL.ClearColor(0.3f, 0.3f, 0.3f, 0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.ShadeModel(ShadingModel.Smooth);

            GL.LoadIdentity();
            GL.Translate(-15.0f, -15.0f, 0.0f);

            GL.Begin(BeginMode.Triangles);
            GL.Color3(1.0f, 0.0f, 0.0f);
            GL.Vertex2(0.0f, 0.0f);
            GL.Color3(0.0f, 1.0f, 0.0f);
            GL.Vertex2(30f, 0.0f);
            GL.Color3(0.0f, 0.0f, 1.0f);
            GL.Vertex2(0.0f, 30.0f);
            GL.End();
            
            sender.SwapBuffers();
        }
    }
}



Java: import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import static org.lwjgl.opengl.GL11.*;


public class OpenGlExample {

	public void run() throws LWJGLException {
		Display.setDisplayMode(new DisplayMode(640, 480));
		Display.create();
		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(-30, 30, -30, 30, -30, 30);
		glMatrixMode(GL_MODELVIEW);
		
		while(!Display.isCloseRequested()) {
			render();
			
			Display.update();
		}
		
		Display.destroy();
	}
	
	public void render() {
		
		glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		
		glShadeModel(GL_SMOOTH);
		
		glLoadIdentity();
		glTranslatef(-15.0f, -15.0f, 0.0f);
		
		glBegin(GL_TRIANGLES);
		glColor3f(1.0f, 0.0f, 0.0f);
		glVertex2f(0.0f, 0.0f);
		glColor3f(0.0f, 1.0f, 0.0f);
		glVertex2f(30f, 0.0f);
		glColor3f(0.0f, 0.0f, 1.0f);
		glVertex2f(0.0f, 30.0f);
		glEnd();
		
	}
	
	public static void main(String[] args) {
		OpenGlExample openGlExmpl = new OpenGlExample();
		try {
			openGlExmpl.run();
		} catch(LWJGLException e) {
			System.err.println(e);
		}
	}
	
}
Task: OpenGL



C#: using OpenTK;
using OpenTK.Graphics;
namespace OpenGLTest
{
    class Program
    {
        static void Main(string[] args)
        {
            
            GameWindow window = new GameWindow(640, 480, GraphicsMode.Default, "OpenGL Example");

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
            GL.MatrixMode(MatrixMode.Modelview);

            
            window.RenderFrame += new RenderFrameEvent(a_RenderFrame);
            
            window.Run();
        }
        static void a_RenderFrame(GameWindow sender, RenderFrameEventArgs e)
        {
            GL.ClearColor(0.3f, 0.3f, 0.3f, 0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.ShadeModel(ShadingModel.Smooth);

            GL.LoadIdentity();
            GL.Translate(-15.0f, -15.0f, 0.0f);

            GL.Begin(BeginMode.Triangles);
            GL.Color3(1.0f, 0.0f, 0.0f);
            GL.Vertex2(0.0f, 0.0f);
            GL.Color3(0.0f, 1.0f, 0.0f);
            GL.Vertex2(30f, 0.0f);
            GL.Color3(0.0f, 0.0f, 1.0f);
            GL.Vertex2(0.0f, 30.0f);
            GL.End();
            
            sender.SwapBuffers();
        }
    }
}





Python: 


from OpenGL.GL import *
from OpenGL.GLUT import *

def paint():
    glClearColor(0.3,0.3,0.3,0.0)
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

    glShadeModel(GL_SMOOTH)

    glLoadIdentity()
    glTranslatef(-15.0, -15.0, 0.0)

    glBegin(GL_TRIANGLES)
    glColor3f(1.0, 0.0, 0.0)
    glVertex2f(0.0, 0.0)
    glColor3f(0.0, 1.0, 0.0)
    glVertex2f(30.0, 0.0)
    glColor3f(0.0, 0.0, 1.0)
    glVertex2f(0.0, 30.0)
    glEnd()

    glFlush()

def reshape(width, height):
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    glMatrixMode(GL_MODELVIEW)

if __name__ == '__main__':
    glutInit(1, 1)
    glutInitWindowSize(640, 480)
    glutCreateWindow("Triangle")

    glutDisplayFunc(paint)
    glutReshapeFunc(reshape)

    glutMainLoop()
Task: OpenGL





Java: import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import static org.lwjgl.opengl.GL11.*;


public class OpenGlExample {

	public void run() throws LWJGLException {
		Display.setDisplayMode(new DisplayMode(640, 480));
		Display.create();
		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(-30, 30, -30, 30, -30, 30);
		glMatrixMode(GL_MODELVIEW);
		
		while(!Display.isCloseRequested()) {
			render();
			
			Display.update();
		}
		
		Display.destroy();
	}
	
	public void render() {
		
		glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		
		glShadeModel(GL_SMOOTH);
		
		glLoadIdentity();
		glTranslatef(-15.0f, -15.0f, 0.0f);
		
		glBegin(GL_TRIANGLES);
		glColor3f(1.0f, 0.0f, 0.0f);
		glVertex2f(0.0f, 0.0f);
		glColor3f(0.0f, 1.0f, 0.0f);
		glVertex2f(30f, 0.0f);
		glColor3f(0.0f, 0.0f, 1.0f);
		glVertex2f(0.0f, 30.0f);
		glEnd();
		
	}
	
	public static void main(String[] args) {
		OpenGlExample openGlExmpl = new OpenGlExample();
		try {
			openGlExmpl.run();
		} catch(LWJGLException e) {
			System.err.println(e);
		}
	}
	
}



Python: 


from OpenGL.GL import *
from OpenGL.GLUT import *

def paint():
    glClearColor(0.3,0.3,0.3,0.0)
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

    glShadeModel(GL_SMOOTH)

    glLoadIdentity()
    glTranslatef(-15.0, -15.0, 0.0)

    glBegin(GL_TRIANGLES)
    glColor3f(1.0, 0.0, 0.0)
    glVertex2f(0.0, 0.0)
    glColor3f(0.0, 1.0, 0.0)
    glVertex2f(30.0, 0.0)
    glColor3f(0.0, 0.0, 1.0)
    glVertex2f(0.0, 30.0)
    glEnd()

    glFlush()

def reshape(width, height):
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    glMatrixMode(GL_MODELVIEW)

if __name__ == '__main__':
    glutInit(1, 1)
    glutInitWindowSize(640, 480)
    glutCreateWindow("Triangle")

    glutDisplayFunc(paint)
    glutReshapeFunc(reshape)

    glutMainLoop()
Task: OpenGL




Go: package main

import (
    gl "github.com/chsc/gogl/gl21"
    "github.com/go-gl/glfw/v3.2/glfw"
    "log"
    "runtime"
)


const (
    Width  = 640
    Height = 480
)

func check(err error) {
    if err != nil {
        log.Fatal(err)
    }
}

func main() {
    
    runtime.LockOSThread()
    defer runtime.UnlockOSThread()

    err := glfw.Init()
    check(err)
    defer glfw.Terminate()

    
    window, err := glfw.CreateWindow(Width, Height, "Triangle", nil, nil)
    check(err)

    window.MakeContextCurrent()

    err = gl.Init()
    check(err) 

    
    resize(Width, Height)

    
    window.SetCloseCallback(func(w *glfw.Window) {
        return
    })
    window.SetSizeCallback(func(w *glfw.Window, width, height int) {
        resize(width, height)
    })

    for !window.ShouldClose() {
        draw()
        window.SwapBuffers()
        glfw.PollEvents()
    }
}


func resize(width, height int) {
    gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
    gl.MatrixMode(gl.PROJECTION)
    gl.LoadIdentity()
    gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    gl.MatrixMode(gl.MODELVIEW)
}


func draw() {
    gl.ClearColor(0.3, 0.3, 0.3, 0.0)
    gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

    gl.ShadeModel(gl.SMOOTH)

    gl.LoadIdentity()
    gl.Translatef(-15.0, -15.0, 0.0)

    gl.Begin(gl.TRIANGLES)

    gl.Color3f(1.0, 0.0, 0.0)
    gl.Vertex2f(0.0, 0.0)

    gl.Color3f(0.0, 1.0, 0.0)
    gl.Vertex2f(30.0, 0.0)

    gl.Color3f(0.0, 0.0, 1.0)
    gl.Vertex2f(0.0, 30.0)

    gl.End()

    gl.Flush()
}




Python: 


from OpenGL.GL import *
from OpenGL.GLUT import *

def paint():
    glClearColor(0.3,0.3,0.3,0.0)
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

    glShadeModel(GL_SMOOTH)

    glLoadIdentity()
    glTranslatef(-15.0, -15.0, 0.0)

    glBegin(GL_TRIANGLES)
    glColor3f(1.0, 0.0, 0.0)
    glVertex2f(0.0, 0.0)
    glColor3f(0.0, 1.0, 0.0)
    glVertex2f(30.0, 0.0)
    glColor3f(0.0, 0.0, 1.0)
    glVertex2f(0.0, 30.0)
    glEnd()

    glFlush()

def reshape(width, height):
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    glMatrixMode(GL_MODELVIEW)

if __name__ == '__main__':
    glutInit(1, 1)
    glutInitWindowSize(640, 480)
    glutCreateWindow("Triangle")

    glutDisplayFunc(paint)
    glutReshapeFunc(reshape)

    glutMainLoop()
Task: OpenGL



C#: using OpenTK;
using OpenTK.Graphics;
namespace OpenGLTest
{
    class Program
    {
        static void Main(string[] args)
        {
            
            GameWindow window = new GameWindow(640, 480, GraphicsMode.Default, "OpenGL Example");

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
            GL.MatrixMode(MatrixMode.Modelview);

            
            window.RenderFrame += new RenderFrameEvent(a_RenderFrame);
            
            window.Run();
        }
        static void a_RenderFrame(GameWindow sender, RenderFrameEventArgs e)
        {
            GL.ClearColor(0.3f, 0.3f, 0.3f, 0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.ShadeModel(ShadingModel.Smooth);

            GL.LoadIdentity();
            GL.Translate(-15.0f, -15.0f, 0.0f);

            GL.Begin(BeginMode.Triangles);
            GL.Color3(1.0f, 0.0f, 0.0f);
            GL.Vertex2(0.0f, 0.0f);
            GL.Color3(0.0f, 1.0f, 0.0f);
            GL.Vertex2(30f, 0.0f);
            GL.Color3(0.0f, 0.0f, 1.0f);
            GL.Vertex2(0.0f, 30.0f);
            GL.End();
            
            sender.SwapBuffers();
        }
    }
}


Go: package main

import (
    gl "github.com/chsc/gogl/gl21"
    "github.com/go-gl/glfw/v3.2/glfw"
    "log"
    "runtime"
)


const (
    Width  = 640
    Height = 480
)

func check(err error) {
    if err != nil {
        log.Fatal(err)
    }
}

func main() {
    
    runtime.LockOSThread()
    defer runtime.UnlockOSThread()

    err := glfw.Init()
    check(err)
    defer glfw.Terminate()

    
    window, err := glfw.CreateWindow(Width, Height, "Triangle", nil, nil)
    check(err)

    window.MakeContextCurrent()

    err = gl.Init()
    check(err) 

    
    resize(Width, Height)

    
    window.SetCloseCallback(func(w *glfw.Window) {
        return
    })
    window.SetSizeCallback(func(w *glfw.Window, width, height int) {
        resize(width, height)
    })

    for !window.ShouldClose() {
        draw()
        window.SwapBuffers()
        glfw.PollEvents()
    }
}


func resize(width, height int) {
    gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
    gl.MatrixMode(gl.PROJECTION)
    gl.LoadIdentity()
    gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    gl.MatrixMode(gl.MODELVIEW)
}


func draw() {
    gl.ClearColor(0.3, 0.3, 0.3, 0.0)
    gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

    gl.ShadeModel(gl.SMOOTH)

    gl.LoadIdentity()
    gl.Translatef(-15.0, -15.0, 0.0)

    gl.Begin(gl.TRIANGLES)

    gl.Color3f(1.0, 0.0, 0.0)
    gl.Vertex2f(0.0, 0.0)

    gl.Color3f(0.0, 1.0, 0.0)
    gl.Vertex2f(30.0, 0.0)

    gl.Color3f(0.0, 0.0, 1.0)
    gl.Vertex2f(0.0, 30.0)

    gl.End()

    gl.Flush()
}
Task: OpenGL




Go: package main

import (
    gl "github.com/chsc/gogl/gl21"
    "github.com/go-gl/glfw/v3.2/glfw"
    "log"
    "runtime"
)


const (
    Width  = 640
    Height = 480
)

func check(err error) {
    if err != nil {
        log.Fatal(err)
    }
}

func main() {
    
    runtime.LockOSThread()
    defer runtime.UnlockOSThread()

    err := glfw.Init()
    check(err)
    defer glfw.Terminate()

    
    window, err := glfw.CreateWindow(Width, Height, "Triangle", nil, nil)
    check(err)

    window.MakeContextCurrent()

    err = gl.Init()
    check(err) 

    
    resize(Width, Height)

    
    window.SetCloseCallback(func(w *glfw.Window) {
        return
    })
    window.SetSizeCallback(func(w *glfw.Window, width, height int) {
        resize(width, height)
    })

    for !window.ShouldClose() {
        draw()
        window.SwapBuffers()
        glfw.PollEvents()
    }
}


func resize(width, height int) {
    gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
    gl.MatrixMode(gl.PROJECTION)
    gl.LoadIdentity()
    gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
    gl.MatrixMode(gl.MODELVIEW)
}


func draw() {
    gl.ClearColor(0.3, 0.3, 0.3, 0.0)
    gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

    gl.ShadeModel(gl.SMOOTH)

    gl.LoadIdentity()
    gl.Translatef(-15.0, -15.0, 0.0)

    gl.Begin(gl.TRIANGLES)

    gl.Color3f(1.0, 0.0, 0.0)
    gl.Vertex2f(0.0, 0.0)

    gl.Color3f(0.0, 1.0, 0.0)
    gl.Vertex2f(30.0, 0.0)

    gl.Color3f(0.0, 0.0, 1.0)
    gl.Vertex2f(0.0, 30.0)

    gl.End()

    gl.Flush()
}


Java: import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import static org.lwjgl.opengl.GL11.*;


public class OpenGlExample {

	public void run() throws LWJGLException {
		Display.setDisplayMode(new DisplayMode(640, 480));
		Display.create();
		
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(-30, 30, -30, 30, -30, 30);
		glMatrixMode(GL_MODELVIEW);
		
		while(!Display.isCloseRequested()) {
			render();
			
			Display.update();
		}
		
		Display.destroy();
	}
	
	public void render() {
		
		glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		
		glShadeModel(GL_SMOOTH);
		
		glLoadIdentity();
		glTranslatef(-15.0f, -15.0f, 0.0f);
		
		glBegin(GL_TRIANGLES);
		glColor3f(1.0f, 0.0f, 0.0f);
		glVertex2f(0.0f, 0.0f);
		glColor3f(0.0f, 1.0f, 0.0f);
		glVertex2f(30f, 0.0f);
		glColor3f(0.0f, 0.0f, 1.0f);
		glVertex2f(0.0f, 30.0f);
		glEnd();
		
	}
	
	public static void main(String[] args) {
		OpenGlExample openGlExmpl = new OpenGlExample();
		try {
			openGlExmpl.run();
		} catch(LWJGLException e) {
			System.err.println(e);
		}
	}
	
}