September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
35
Task/OpenGL/EC/opengl.ec
Normal file
35
Task/OpenGL/EC/opengl.ec
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include <GL/gl.h>
|
||||
import "ecere"
|
||||
|
||||
class GLTriangle : Window
|
||||
{
|
||||
text = "Triangle";
|
||||
displayDriver = "OpenGL";
|
||||
background = activeBorder;
|
||||
nativeDecorations = true;
|
||||
borderStyle = sizable;
|
||||
hasMaximize = true, hasMinimize = true, hasClose = true;
|
||||
size = { 640, 480 };
|
||||
|
||||
void OnRedraw(Surface surface)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-30, 30, -30, 30, -30, 30);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(-15, -15, 0);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex2f(0, 0);
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex2f(30, 0);
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex2f(0, 30);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
GLTriangle window {};
|
||||
48
Task/OpenGL/Kotlin/opengl.kotlin
Normal file
48
Task/OpenGL/Kotlin/opengl.kotlin
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Kotlin Native version 0.3
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import opengl.*
|
||||
|
||||
fun paint() {
|
||||
glClearColor(0.3f, 0.3f, 0.3f, 0.0f)
|
||||
glClear(GL_COLOR_BUFFER_BIT or 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(30.0f, 0.0f)
|
||||
glColor3f(0.0f, 0.0f, 1.0f)
|
||||
glVertex2f(0.0f, 30.0f)
|
||||
glEnd()
|
||||
|
||||
glFlush()
|
||||
}
|
||||
|
||||
fun reshape(width: Int, height: Int) {
|
||||
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)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
memScoped {
|
||||
val argc = alloc<IntVar>().apply { value = 0 }
|
||||
glutInit(argc.ptr, null)
|
||||
}
|
||||
|
||||
glutInitWindowSize(640, 480)
|
||||
glutCreateWindow("Triangle")
|
||||
|
||||
glutDisplayFunc(staticCFunction(::paint))
|
||||
glutReshapeFunc(staticCFunction(::reshape))
|
||||
|
||||
glutMainLoop()
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ proc paint() {.cdecl.} =
|
|||
|
||||
glFlush()
|
||||
|
||||
proc reshape(width, height) {.cdecl.} =
|
||||
proc reshape(width, height: cint) {.cdecl.} =
|
||||
glViewport(0, 0, width, height)
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
glLoadIdentity()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue