Permalink
Browse files

Fix problem with OpenGL bindings still will not work with compiled im…

…ages.

* bootstrap.4k: Add RTLD_GLOBAL to lib.
* demos/sdl.4k: Replace with something more meaningful (triangle.4k)
* demos/triangle.4k: New file, display OpenGL triangle.
* lib/display.4k: Clean up. Now it works. Render: Render; words that's interface to display.4k.
* src/Makefile: Add openGL to linked libraries! That's needed for time being, until we discover how to link dynamically under linux.
  • Loading branch information...
1 parent ccaed9e commit 7bc228bd2d6e7d91653bfed52c3bd22475fbd93c @danmey committed Jun 18, 2011
Showing with 72 additions and 62 deletions.
  1. +1 −1 bootstrap.4k
  2. +7 −41 demos/sdl.4k
  3. +33 −0 demos/triangle.4k
  4. +30 −19 lib/display.4k
  5. +1 −1 src/Makefile
View
@@ -239,7 +239,7 @@ symbol: dlsym
| Convert string to zero terminated string
: >cstr drop ;
| Load library
-: lib >cstr $2 swap dlopen ;
+: lib >cstr $100 $2 or swap dlopen ;
| Load symbol
: sym >cstr swap dlsym ;
variable #ithere
View
@@ -15,48 +15,14 @@
\ You should have received a copy of the GNU General Public License
\ along with this program. If not, see <http://www.gnu.org/licenses/>.
-2 ccall: exit
-3 ccall: printf
-4 ccall: dlerror
-5 ccall: video
-6 ccall: SDL_PollEvent
-
-| SDL constants
-27 const Esc
-2 const Keydown
-create event 20 bytes allot
-
-| SDL structure dispatch
-: e>type c@ ;
-: e>key 8 + c@ ;
-: s>pixels 20 + @ ;
-
-: sdl-init ( -- )
- " libc.so" lib " _exit" sym
- cell add-handle
-
- " libc.so" lib " printf" sym
- 1 cells add-handle
-
- " libdl.so" lib " dlerror" sym
- 0 cells add-handle
-
- " /usr/lib/libSDL.so" lib " SDL_SetVideoMode" sym
- 4 cells add-handle
- " /usr/lib/libSDL.so" lib " SDL_PollEvent" sym 1 cells add-handle
-;
-: render-loop
- begin
- event SDL_PollEvent drop
- event e>type Keydown = if event e>key Esc = if ;; then then
- again
-;
+Render: render-loop
-: yeah ( -- )
- sdl-init
- 2 0 600 800 video
+;Render
+
+: main
render-loop
- 0 exit
-;
+;
+main
+bye
View
@@ -0,0 +1,33 @@
+| FourK - Concatenative, stack based, Forth like language optimised for
+| non-interactive 4KB size demoscene presentations.
+
+| Copyright (C) 2009, 2010 Wojciech Meyer, Josef P. Bernhart
+
+| This program is free software: you can redistribute it and/or modify
+| it under the terms of the GNU General Public License as published by
+| the Free Software Foundation, either version 3 of the License, or
+| (at your option) any later version.
+
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+
+| You should have received a copy of the GNU General Public License
+| along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+| Display routines
+require" lib/display.4k"
+
+| Setup empty main render loop
+Render: render-loop
+
+;Render
+
+| Our main function
+: main
+ render-loop
+;
+
+main
+bye
View
@@ -21,11 +21,13 @@
symbol: exit
symbol: printf
-symbol: glClear
symbol: dlerror
symbol: SDL_SetVideoMode
symbol: SDL_PollEvent
symbol: SDL_GL_SwapBuffers
+symbol: SDL_Init
+symbol: SDL_InitSubSystem
+symbol: glClear
| SDL constants
27 const Esc
@@ -37,38 +39,47 @@ create event 20 bytes allot
: e>key 8 + c@ ;
: s>pixels 20 + @ ;
-: libc " /usr/lib/libc.so" lib ;
-: libGL " /usr/lib/libGL.so" lib ;
-: libSDL " /usr/lib/libSDL.so" lib ;
+: libc " libc.so" lib ;
+: libGL " libGL.so" lib ;
+: libSDL " libSDL.so" lib ;
: function >r sym r> cells add-handle ;
-: sdl-init ( -- )
+
+: init-display-syms ( -- )
libc " _exit" 1 function
libc " printf" 1 function
- libGL " glClear" 1 function
libSDL " dlerror" 0 function
libSDL " SDL_SetVideoMode" 4 function
libSDL " SDL_PollEvent" 1 function
libSDL " SDL_GL_SwapBuffers" 0 function
+ libSDL " SDL_Init" 0 function
+ libSDL " SDL_InitSubSystem" 1 function
+ libGL " glClear" 1 function
;
$00000100 const GL_DEPTH_BUFFER_BIT
$00004000 const GL_COLOR_BUFFER_BIT
-: render-loop
- begin
- SDL_GL_SwapBuffers drop
- event SDL_PollEvent drop
- event e>type Keydown = if event e>key Esc = if ;; then then
- again
+: init-display
+ init-display-syms
+ $00000002 32 600 800 SDL_SetVideoMode drop
+;
+: esc-check
+ event SDL_PollEvent drop
+ event e>type Keydown = if event e>key Esc = ;; then
+ 0
;
-: yeah ( -- )
- sdl-init
- $00000002 or 32 600 800 SDL_SetVideoMode
+: Render: :
+ postpone init-display postpone begin
+ postpone esc-check postpone if postpone ;; postpone then
+;
+
+: ;Render postpone again postpone ; ; immediate
+
+
+: clear-display
GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT or glClear drop
- render-loop
- 0 exit
-;
+;
-yeah
+: swap-display SDL_GL_SwapBuffers drop ;
View
@@ -66,7 +66,7 @@ $(BIN)/4k-debug: $(SRC_FILES)
m4 -DDEBUG $(CYWGIN) -s $(SRC) > $(BIN)/t.s
./m4patch.pl > $(BIN)/t.P
mv $(BIN)/t.P $(BIN)/t.S
- gcc -m32 -ggdb3 $(BIN)/t.S -o $(BIN)/4k-debug -ldl -lsigsegv -lc
+ gcc -m32 -ggdb3 $(BIN)/t.S -o $(BIN)/4k-debug -ldl -lsigsegv -lGL -lc
cp $@ $(PREFIX)

0 comments on commit 7bc228b

Please sign in to comment.