Author Topic: Procedural textures  (Read 2308 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Procedural textures
« on: May 05, 2011, 12:31:03 PM »



The general idea is to create a string for a square of pixels, create a pattern then hand it over to Opengl as a texture.

Code: [Select]
  '-------------
  'TEXTURED QUAD
  '=============
  '
  sub ProcTex1(string*texture, sys size)
  '====================================
  '
  texture=nuls 4*size*size
  xe=size-1 : ye=xe
  w=*texture
  for y=0 to ye
  for x=0 to xe
    p=(x+y*size)*4+w
    mov ecx,p
    mov eax, 0xff666644
    (
    mov edx,y
    and edx,0xf
    cmp edx,0
    jnz exit
    mov eax,0xffffffff
    )
    (
    mov edx,x
    and edx,0x6
    jnz exit
    mov eax,0xbbbbbbbb
    )
    mov [ecx],eax
  next
  next
  '
  end sub



   '
  string tex : sys size
  size=128
  ProcTex1 tex, size
  MakeTexture *tex, size, size, texn[3]
  '
  glEnable GL_TEXTURE_2D
  glBindTexture GL_TEXTURE_2D,texn[3]
  glpushmatrix
  glscalef 2,2,2
  glbegin GL_QUADS
  '
  glnormal3f 0,0,1
  glTexCoord2f 0,0 : glvertex3f -1., -1., 0
  glTexCoord2f 0,1 : glvertex3f -1.,  1., 0
  glTexCoord2f 1,1 : glvertex3f  1.,  1., 0
  glTexCoord2f 1,0 : glvertex3f  1., -1., 0
  '
  glend
  glpopmatrix
  glDisable GL_TEXTURE_2D
  '
  glEndList


Charles

kryton9

  • Guest
Re: Procedural textures
« Reply #1 on: May 05, 2011, 04:35:48 PM »
That is very exciting Charles. You are way ahead of me, but that is good because I can tap into your research when ready.

Looks like a nice texture for your procedural city!!!