Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Sleeper

#1
hi

i am trying to work with sockets for the first time.

i need a function that reads exactly n bytes from the socket (and blocks until they are available)

how can i do this?
#2
Recently i wrote a few  opengl demos in newlisp just for fun, in which i used simple TGA texture loading function. The problem is that in tga image data colors go in BGR or BGRA order and i use GL_BGR_EXT and GL_BGRA_EXT extensions. What i want is to change color order to standard RGB and RGBA in a fastest way and use GL_RGB and GL_RGBA. I wrote two functions for this purpose:



;; bgra -> rgba
(define (swaprb32 data)
    (join (map (lambda (x) (select x 2 1 0 3)) (explode data 4)) ""))

;; bgr -> rgb
(define (swaprb24 data)
    (join (map reverse (explode data 3)) ""))

;; testing
(print "test-rgba: ")
(set 'testdata (dup "bgra" (* 512 512)))  ; data from file
(set 'testres  (dup "rgba" (* 512 512)))  ; what i want to get
(print (time (set 'res (swaprb32 testdata))) " ")
(println (= res testres))

(print "test-rgb: ")
(set 'testdata (dup "bgr" (* 512 512)))
(set 'testres  (dup "rgb" (* 512 512)))
(print (time (set 'res (swaprb24 testdata))) " ")
(println (= res testres))


but maybe there is a better way to do this thing?

any suggestions?

results i get for 512x512 image:

 test-rgba: 781 true

 test-rgb: 609 true
#3
newLISP and the O.S. / seek on big files
December 24, 2006, 12:33:46 PM
Sorry for maybe stupid question..

Why do i get nil when use "seek" builtin function on big binary files? (up to 6 GB)



> (set 'f (open "storage.tmp" "r"))
3
> (seek f)
0
> (seek f -1)
nil
> (seek f 5893610690)
1598643394


I'm sure that position 5893610690 exists in that file.

Sometimes i get negative values in return...

NewLISP manual says:



   (open "newlisp_manual.html" "read")
    (seek file -1)  ; seek to EOF
    → 593816    

    (set 'fle (open "large-file" "read")
    (seek file 30000000000)  → 30000000000

newLISP supports file position numbers up to 9,223,372,036,854,775,807.
#4
newLISP and the O.S. / net-ping error
December 15, 2006, 11:31:07 AM
Hi all!

I get an error with net-ping.



newLISP v.9.0.9 on Win32, execute 'newlisp -h' for more info.

> (net-ping "www.google.com")

invalid function : (net-ping "www.google.com")


what's wrong with it?