Trouble with Glut and Opengl

48 views
Skip to first unread message

Sabe Does Things

unread,
Dec 21, 2025, 3:01:43 PM (4 days ago) Dec 21
to The Ring Programming Language
Hello! I am currently messing around with opengl and glut and I am trying to clear the window with a grey color. But when its just a black screen.
load "opengl21lib.ring"
load "freeglut.ring"

func display
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glutSwapBuffers()

func init
    glClearColor(0.3, 0.3, 0.3, 0)
    gluOrtho2D(0, 1024, 512, 0)

func main
    glutInit()
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
    glutInitWindowSize(1024, 512)
    glutCreateWindow("Ring Raycaster")
    init()
    glutDisplayFunc(:display)
    glutMainLoop()

Mahmoud Fayed

unread,
Dec 21, 2025, 3:55:00 PM (4 days ago) Dec 21
to The Ring Programming Language
Hello Sabe

Thanks for the report, Your sample is correct

The error was defining (GLclampf) as Enum instead of Number

To get the update

ringpm update ringopengl21

Then run your sample, and it should work directly (if you are using windows)
Or build the extension after updating the package (if you are using linux/macOS)

Greetings,
Mahmoud

Sabe Does Things

unread,
Dec 21, 2025, 3:59:44 PM (4 days ago) Dec 21
to The Ring Programming Language
WOW! Thank you so much. That was a lot more straight forward to update than I was expecting! I'm really liking Ring so far and I appreciate the help. Also sorry if you see this twice I'm still getting the hang of Google Groups.

Mahmoud Fayed

unread,
Dec 21, 2025, 4:06:49 PM (4 days ago) Dec 21
to The Ring Programming Language
Hello Sabe

You are welcome :D

Greetings,
Mahmoud

Sabe Does Things

unread,
Dec 21, 2025, 4:38:11 PM (4 days ago) Dec 21
to The Ring Programming Language
Hello so another problem I found was when checking the key event with glutEventKey. I'm trying to do wasd but it doesnt seem to when when I do wasd but it's still getting the code. 
key = glutEventKey()

    switch key
        on 'w' py -= 5
        on 'a' px -= 5
        on 's' py += 5
        on 'd' px += 5
    off

    ? "Key id: " + key

terminal output:
Key id: 119
Key id: 97
Key id: 115
Key id: 100

but when I manually put the code number in it works. I don't mind having to do that but i think you should be able to put the character.

Mahmoud Fayed

unread,
Dec 21, 2025, 4:49:38 PM (4 days ago) Dec 21
to The Ring Programming Language
Hello Sabe

Ring comes with Char() and ASCII() functions

? ascii("w")
? char(119)

Output:
119
w

So instead of (switch key) 
Try (switch char(key))

Greetings,
Mahmoud

Sabe Does Things

unread,
Dec 21, 2025, 5:17:36 PM (4 days ago) Dec 21
to The Ring Programming Language
oh ok thank you!

Mahmoud Fayed

unread,
Dec 21, 2025, 5:58:02 PM (3 days ago) Dec 21
to The Ring Programming Language
Hello Sabe

You are welcome :D

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages