Author Topic: GlTexture  (Read 3348 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
GlTexture
« on: June 08, 2011, 08:41:11 AM »
Deleted
« Last Edit: May 05, 2015, 09:37:08 AM by Peter »

Charles Pegge

  • Guest
Re: GlTexture
« Reply #1 on: June 08, 2011, 09:44:56 PM »
Thanks Peter.

What is the data structure of your RAW files?

Charles

Charles Pegge

  • Guest
Re: GlTexture
« Reply #2 on: June 09, 2011, 11:38:44 AM »
Thanks Peter,

I put together a class for examining 'Raw' data. I don't know whether it  is useful to you, but it might help to seed new coding styles.

Code: Text
  1.  
  2.   type rgb  byte r,g,b
  3.   type rgba byte r,g,b,a
  4.  
  5.   string tab=chr(9),cr=chr(13)+chr(10)
  6.   '
  7.   '
  8.   '==============
  9.   class RawObject
  10.   '==============
  11.   '
  12.   'handling raw RGB raster data
  13.   '----------------------------
  14.   '
  15.   string s,t
  16.   sys mx,my,ot
  17.   '
  18.   method readfile(n as string)
  19.     s=getfile n
  20.   end method
  21.   '
  22.   method setXY(sys px,py)
  23.     mx=px : my=py
  24.   end method
  25.   '
  26.   method getpixel(sys x,y) as sys  
  27.     let p=(y*mx + x)*sizeof rgb + *s
  28.     return *p or 0xff000000 'set alpha channel to max 0xff
  29.   end method
  30.   '
  31.   method splitpixel(sys pix, byte*r, byte*g, byte*b, byte*a)
  32.     'rgba c at @pix
  33.     rgba * c : @c=@pix
  34.     r=c.r
  35.     g=c.g
  36.     b=c.b
  37.     a=c.a
  38.   end method
  39.   '
  40.   method cleartext()
  41.     ot=0 : t=""
  42.   end method
  43.   '
  44.   method addtext(string li)
  45.     sys le=len li
  46.     if ot+le>len t then t+=space 1000
  47.     mid t,ot+1,li
  48.     ot+=le
  49.   end method
  50.   '
  51.   method listpixels(sys px,py,nx,ny)
  52.     sys x,y,p
  53.     byte r,g,b,a
  54.     for y=1 to ny
  55.     addtext cr cr "y=" hex(y) cr cr
  56.     for x=1 to nx
  57.       p=getpixel px+x,py+y
  58.       splitpixel p,r,g,b,a
  59.       addtext hex(x) tab r tab g tab b tab a cr
  60.     next
  61.     next
  62.   end method
  63.   '
  64.   method mapcolor(sys px,py,nx,ny,c)
  65.     '
  66.     sys    x,y,p,ch
  67.     byte   r,g,b,a
  68.     string b=space(nx), co=" "
  69.     '
  70.     addtext cr cr "color channel=" c cr cr
  71.     '
  72.     for y=1 to ny
  73.     for x=1 to nx
  74.       p=getpixel px+x,py+y
  75.       splitpixel p,r,g,b,a
  76.       select c
  77.       case 1 : ch=r
  78.       case 2 : ch=g
  79.       case 3 : ch=b
  80.       case 4 : ch=a
  81.       end select
  82.       if r>0 then co=chr(65+(ch>>4)) else co=" " 'supports 16 color bands
  83.       mid b,x,co
  84.     next
  85.     addtext tab b cr
  86.     next
  87.   end method
  88.   '
  89.   end class
  90.  
  91.   '#recordof RawObject
  92.  
  93.  
  94.   'TEST
  95.   '====
  96.   '
  97.   RawObject rw
  98.   rw.readfile "bulb32x.raw"
  99.   if not len rw.s then print "File problem!"
  100.   rw.setXY 32,32
  101.   sys p=rw.getpixel(30,30)
  102.   'print hex p
  103.   byte r,g,b,a
  104.   'rw.splitpixel 0x04030201, r, g, b, a
  105.   rw.splitpixel p, r, g, b, a
  106.   'print "red: " r "  green: " g "  blue: " b
  107.   rw.cleartext
  108.   '
  109.   'rw.listpixels 0,0,32,32
  110.   '
  111.   rw.mapcolor 0,0,32,32,1 'red
  112.   rw.mapcolor 0,0,32,32,2 'green
  113.   rw.mapcolor 0,0,32,32,3 'blue
  114.   '
  115.   putfile "t.txt", rw.t
  116.  
  117.  
  118.  

Code: [Select]

color channel=1

                               
           NPPPPN              
         NPPPPPPPPN            
        PPPPPPPPPPPP          
       NPPPPPPPPPPPPN          
      PPPPPPPPPPPPPPPP        
     NPPPPPPPPPPPPPPPPN        
     PPPPPPPPPPPPPPPPPP        
    NPPPPPPPPPPPPPPPPPPN      
    PPPPPPPPPPPPPPPPPPPP      
    PPPPPPPPPPPPPPPPPPPP      
    PPPPPPPPPPPPPPPPPPPP      
    PPPPPPPPPPPPPPPPPPPP      
    NPPPPPPPPPPPPPPPPPPN      
     PPPPPPPPPPPPPPPPPP        
     NPPPPPPPPPPPPPPPPN        
      PPPPPPPPPPPPPPPP        
       NPPPPPPPPPPPPN          
        PPPPPPPPPPPP          
         NPPPPPPPPN            
           PPPPPP              
          HJLLJHHG            
          HJLLJHHG            
          HJLLJHHG            
          HJLLJHHG            
          HJLLJHHG            
          HJLLJHHG            
           GFFFFE              
            GFFE              
                               
                               
  FH ACCCCCCCCCCCCCCCCCCCCCCCCC




Charles
« Last Edit: June 11, 2011, 06:00:35 AM by o2admin »

Charles Pegge

  • Guest
Re: GlTexture
« Reply #3 on: June 09, 2011, 10:33:01 PM »

Hi Peter,

The properties here are listed just above the methods and inheritance works much like a UDT. My understanding is that inheritance in the OOP world is no longer a fashion item and should only be used when appropriate. Multiple classes using a common interface, ie: offering the same methods, is often preferred.

There are a number of pieces shown in the examples/OOP folder showing different techniques. But we could always use more.


Declaring parameters in groups is a new feature. I fixed one bug yesterday relating to params passed byref, (latest Oxygen in progress). But passing directly is okay.

Ypu can do:
Routine(sys a,b,c,d, single x,y,z, string s)

Charles

kryton9

  • Guest
Re: GlTexture
« Reply #4 on: June 10, 2011, 04:28:31 PM »
After playing with oxygen... I am finding it very hard to use c++ again. It is amazing how ; and { } in code can be so disturbing to the eyes after working in a clean basic syntax.
Now if I just use C++ for a few days and not look at any other language... I get used to it.

Quote
Ypu can do:
Routine(sys a,b,c,d, single x,y,z, string s)
You just up the ante all the time Charles. Such a useful way to enter parameter declarations, should be a standard and not the exception, well done!
« Last Edit: June 10, 2011, 04:30:14 PM by kryton9 »

Charles Pegge

  • Guest
Re: GlTexture
« Reply #5 on: June 10, 2011, 09:43:51 PM »
Kent,

I make a virtue of my less than adequate eyesight to come up with a clear syntax, stripping out all the noisy stuff. The lexer and parser layers have to be quite sophisticated to do this. - more complex than plain Basic or C.

I am still watching out for hidden sink-holes and try to fill them in before any one else falls into them.

Charles