Author Topic: nehe lesson 7 question about gdiPlusLoadTexture  (Read 3820 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
nehe lesson 7 question about gdiPlusLoadTexture
« on: March 16, 2013, 01:57:17 AM »
I wanted to convert openGL "nehe lesson 7" for oxygen. as I could see nobody has done before any chapter for oxygen.
but I used as basis an example from powerbasic with gdiplus include file before and see that's a big problem to convert for example

a) "gdiplusloadtexture" (it's a function for converting present) for oxygenbasic.

it's not a problem to load an image (png, bmb, jpg) with "imgwin.inc" here.

b) or here's another way to bind a simple 256x256 texture in openGL modus on a cube (for example)? perhaps there's an example here at board or at sample folders?

forgotten to say that I didn't want to use "freeglut" include files! ;) I wanted more to use the "cGLWindow3.inc" from my last pyramid example :)

any tipp is welcome about a) gdiplusloadtexture or b) binding openGL textures for primitives for me, thanks!

best regards, frank
« Last Edit: March 16, 2013, 02:07:49 AM by Frankolinox »

Emil_halim

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #1 on: March 16, 2013, 08:26:33 AM »

Hi Frank,

I think FreeImage lib is your destiny here , i used it many times , supporting  many image file format.

Frankolinox

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #2 on: March 16, 2013, 09:24:28 AM »
thanks for feedback, but that's not correct way for my purpose with openGL and load image files in this case. I already know freeImage since some years :-)

Code: [Select]
  #case capital

  includepath "..\..\inc\"
  '$ FileName "t.exe"
  'include "RTL32.inc"
  title="Rotating Textured Quad"
  include "OpenglSceneFrame.inc"

  sys texn[16]


  Sub MakeTexture(sys pPixelArray, xSize, ySize, Texnum )
  '======================================================
  '
  glBindTexture GL_TEXTURE_2D, texNum
  '
  'GL_NEAREST
  'GL_LINEAR
  '
  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
  '
  'GL_NEAREST
  'GL_LINEAR
  'GL_NEAREST_MIPMAP_NEAREST         0x2700
  'GL_LINEAR_MIPMAP_NEAREST          0x2701
  'GL_NEAREST_MIPMAP_LINEAR          0x2702
  'GL_LINEAR_MIPMAP_LINEAR           0x2703
  '
  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
  glTexImage2D GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, pPixelArray
  '
  End Sub




  sub MakePatternA(sys n)
  '======================
  '
  static long pixels[4096], tx=64, ty=64, x, y, p, c
  '
  for y=1 to 64
    for x=1 to 64
      if x<33 and y<33
        c=0xff00ff00       'GREEN BOTTOM LEFT
      elseif x>32 and y>32
        c=0xffff0000       'BLUE TOP RIGHT
      else
        c=0xff0000ff       'RED
      end if
      p=y*64-64+x
      pixels[p]=c
    next
  next
  '
  'GL_NEAREST
  'GL_LINEAR
  glBindTexture GL_TEXTURE_2D, texn[n]
  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
  '
  'GL_NEAREST
  'GL_LINEAR
  'GL_NEAREST_MIPMAP_NEAREST         0x2700
  'GL_LINEAR_MIPMAP_NEAREST          0x2701
  'GL_NEAREST_MIPMAP_LINEAR          0x2702
  'GL_LINEAR_MIPMAP_LINEAR           0x2703
  '
  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
  glTexImage2D GL_TEXTURE_2D, 0, 4, tx, ty, 0, GL_RGBA, GL_UNSIGNED_BYTE, @Pixels
  '
  end sub
  '
  '
  sub Initialize(sys hWnd)
  '=======================

  glGenTextures 2, texn
  MakePatternA 1
  SetTimer hWnd,1,10,NULL

  end sub 'initialize



  sub Release(sys hWnd)
  '====================
  killTimer hwnd, 1
  glDeleteTextures 1, texn
  '
  end sub



  sub Scene(sys hWnd)
  '==================
  '
  static single ang1, angi1=1
  static single sx,sy,sz
  '
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
  glClearColor 0.5, 0, 0, 0
  glLoadIdentity
  '
  'ACTIVATE TEXTURE
  '----------------
  '
  glEnable GL_TEXTURE_2D
  glBindTexture GL_TEXTURE_2D,texn[1]
  '
  sx=0.2 : sy=0.16 : sz=-1
  '
  '
  'MOVEMENT
  '--------
  '
  'glrotatef ang1, 0,0,1
  single x=cos(rad(ang1))*.1
  single y=sin(rad(ang1))*.1
  single z=0
 
  gltranslatef x,y,z
  '
  'DRAW SHAPE
  '----------
  '
  'this quad is drawn clockwise
  '
  glbegin GL_QUADS
  '
  glTexCoord2f 0,0 : glvertex3f -sx, -sy,  sZ 'BOTTOM LEFT
  glTexCoord2f 0,1 : glvertex3f -sx,  sy,  sZ 'TOP LEFT
  glTexCoord2f 1,1 : glvertex3f  sx,  sy,  sZ 'TOP RIGHT
  glTexCoord2f 1,0 : glvertex3f  sx, -sy,  sZ 'BOTTOM RIGHT
  '
  glend
  '
  glDisable GL_TEXTURE_2D
  '
  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  ang1+=angi1 : if ang1>=360 then ang1-=360
  '
  '
  end sub


if anybody knows a way how to implement "gdiploadtexture" with 256x256 format I am glad to see that. I checked gdip.inc files and other ones, but the function from powerbasic (gdipflat.inc, gdiputils.inc, gdipinit.inc) is no compatible with oxygen (at the moment) ;)

best regards, frank

Frankolinox

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #3 on: March 18, 2013, 01:32:49 AM »
hello, I am needing help again how to convert this commands

a) "IIF" and (not found)

b) "Tally" to oxygen :) may be tally was mentioned before at another place at this board (ok, I've found it! :) )

c) "swap" (not found)

Code: [Select]
IF IIF&(TALLY(BIN$(TextureWidth), "1") = 1, 1, 0) = %FALSE THEN hStatus = %ERROR_INVALID_DATA
thanks in advance, frank

Charles Pegge

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #4 on: March 18, 2013, 06:01:09 AM »
Hi Frank,

The meaning of this line is not clear but you can expand iif to an if..then.. else..endif construct

It actually simplifies to:

if TALLY(BIN$(TextureWidth), "1") <> 1
  hStatus = %ERROR_INVALID_DATA
end if


We don't have tally or bin

swap is something I should implement for all types, as it is often useful

Here it is in macro form


macro swap(a,b)
scope
typeof a v=a
a=b : b=v
end scope
end macro

float f=1.5,g=2.5

swap(f,g)

print f

« Last Edit: March 18, 2013, 06:17:01 AM by Charles Pegge »

Emil_halim

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #5 on: March 18, 2013, 07:38:10 AM »
Frank , i was and still member of BCX Basic to c Translatore , which has many features ported from PowerBasic

So.
Quote
IF IIF&(TALLY(BIN$(TextureWidth), "1") = 1, 1, 0) = %FALSE THEN hStatus = %ERROR_INVALID_DATA

Means that

Code: [Select]
IIF function is the same as C expression  a= (k>t) :  1 ? 2 ,that means a will be 1 if k>t is true and a will be 2
if not k > t.

in your post IIF will return 1 (second param) if this term   &(TALLY(BIN$(TextureWidth), "1") = 1  is true and
return 0  (last param) if the term is not true.

hope that help you. :)

Frankolinox

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #6 on: March 19, 2013, 10:27:08 AM »
thank you charles for swap example, it works here fine :)
thanks emil for you advice too.

my little progress about loadTexture (gdiplus) looks like this, but it's not perfect.

Code: [Select]
function loadtexture(wstring wszFileName,sys TextureWidth, sys TextureHeight, string strTextureData)  as sys
  sys bInitGdiPlus,hStatus,hr, token,pImage,pThumb,pTextureData,x,y,i
  string s

  macro swap(a,b)
    scope
    typeof a v=a
    a=b : b=v
    end scope
  end macro

  'pTextureData+=1
  
  GdiplusStartupInput StartupInput    ' // Structure to initialize GDI+
  GDIP_BGRA_UNION pixColor             ' // Union uses to swap colors
  'pTextureData AS SYS 'PTR             ' // Pointer to the texture data

   sys hr,hdlg,token
  GdiplusStartupInput StartupInput

  StartupInput.GdiplusVersion = 1
  hStatus=GdiplusStartup token, StartupInput, byval 0
  '
  if hStatus then
    print "Error initializing GDIplus: " hex hStatus
    exit function
  end if

      hStatus = GdipLoadImageFromFile(wszFileName, pImage)
      print wszFilename
      hStatus = GdipGetImageWidth(pImage, TextureWidth)
      hStatus = GdipGetImageHeight(pImage, TextureHeight)
      hStatus = GdipGetImageThumbnail(pImage, TextureWidth, TextureHeight, pThumb, 0, 0)
      hStatus = GdipImageRotateFlip(pThumb, 6) ' 6 = %RotateNoneFlipY
      
      'NUL$(TextureWidth * TextureHeight * 4)
      strTextureData = str(TextureWidth * TextureHeight * 4)
      
      'strTextureData = NULS(TextureWidth * TextureHeight * 4)
        'strTextureData = NUL$(TextureWidth * TextureHeight * 4)
  
               'pTextureData = STRPTR(strTextureData)
               pTextureData = @strTextureData

               for y=0 to TextureWidth - 1
                  for x=0 to TextureHeight - 1
                     GdipBitmapGetPixel(pThumb, x, y, pixColor.color)
                     swap(pixColor.red, pixColor.blue)
                     @pTextureData = pixColor.color
                     'INCR pTextureData
                     pTextureData+=1
                  next
               next
              
               GdipDisposeImage(pImage)
               GdipDisposeImage(pThumb)
              
  print "ok: " wszFilename
  return hStatus
  
GdiplusShutdown token

end function

how to set

a)
Code: [Select]
pTextureData AS SYS PTR ' ?  as a pointer ?

b) how to convert NUL$
Code: [Select]
strTextureData = NUL$(TextureWidth * TextureHeight * 4) ?

I converted this one with "str", "NULS" doesn't exists for oxygen?

c) if I really need tally (I meant the function charles, that I've found about another topic at board, the command doesn't exists you are right!) that's not perhaps important.

I will check if I can load another gdiplus example (with "thumbnails") and load (replace) it with my "loadTexture" and if there's an image for showing I will implement this new function for an openGL example. I noticed that's not often smart to convert all stuff from powerbasic (for example) to oxygenbasic ;)

nice evening, frank
« Last Edit: March 19, 2013, 10:33:22 AM by Frankolinox »

Peter

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #7 on: March 19, 2013, 10:45:10 AM »
Quote
pTextureData AS SYS PTR ' ?

You will find the answer in FreeBasic forum.

A macro inside a function is new to me!
I think it is nothing as a SUb declaration and must be at the beginning.

Frankolinox

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #8 on: March 20, 2013, 02:10:50 AM »
one way I've found with openGL + gdiplus :), but without using the damned "loadtexture" (gdiplus) function. My supposition was that's sufficient to load an image file only with

Code: [Select]
GdipLoadImageFromFile(wszFileName, pImage)
and that's the right way, I am sure.

anybody can check my "image-openGL" cube demo below if that's running on your machine, would be good to get feedback.

thanks peter for your info, I will check this evening.

best regards, frank

X

Peter

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #9 on: March 20, 2013, 03:11:28 AM »
Hi Frank,

It's running here! But the frontage is at the wrong place!
The cube looks as if it floats in water. Is a bit slowly here.

Peter

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #10 on: March 20, 2013, 07:41:39 AM »
Frank,

if you move the mouse back and forth, the cube rotates faster!
the colour isn't correct. I think you must take BGRA_EXT.

Frankolinox

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #11 on: March 20, 2013, 10:17:54 AM »
a) many thanks peter for testing :-) one cube texture face isn't correct, I will see to fix it although it's translated correct from powerbasic. I am working with an old pc machine so I didn't know the reaction times or smothness ;) I will check for optimation the openGL code.

b) I am going over the wall and hurdles. use it at own risc.

code snippet "loadtexture" (function for gdiplus). as I have tested for standard winapi (sdk) plus "ImgWin.inc" I haven't still tested for openGL and there's only missing a little function for making the texture (bind texture) for openGL window frame. but this code snippet should work.

Code: [Select]
'deleted code because of update :-)
the code above is a mixing of jose roca's "gdiploadtexture" function (gdiputils.inc) and my own exploring search engine with little knowledge on oxygen :)

best regards, frank
« Last Edit: March 21, 2013, 09:31:04 AM by Frankolinox »

Frankolinox

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #12 on: March 21, 2013, 09:32:50 AM »
I've got it! :)

here's the correct working example for "loadingTexture" (gdiplus) for images and openGL examples.

Code: [Select]
'' oxygen
'' function for loading texture for gdiplus and openGL by frankolinox
'' issue two and correct :-), 21.march.2013
''

type ColorPixel
    sys colorx
    byte red,green,blue,alpha
end type


  '-----------------------------------------------------
  function loadTexture(wstring wszfilename, sys textureWidth, sys textureHeight, string*strTextureData) as sys
  '=====================================================
  '
  sys hstatus,pImage,pThumb,token
  sys width,height,picflip,picdim,ref,xw,yw,xww,yww

  macro swap(a,b)
    scope
    typeof a v=a
    a=b : b=v
    end scope
  end macro
  '
  GdiplusStartupInput StartupInput

  StartupInput.GdiplusVersion = 1
  hStatus=GdiplusStartup token, StartupInput, byval 0
  '
  if hStatus then
    print "Error initializing GDIplus: " hex hStatus
    exit function
  end if  
    
  hStatus = GdipLoadImageFromFile wszfilename, pImage
  hStatus = GdipGetImageThumbnail pImage, textureWidth, textureHeight, pThumb, NULL, NULL
  
  picflip=pthumb
  hStatus = GdipImageRotateFlip (picflip,6) ' RotateNoneFlipY =6 invert
  colorpixel colpix
  strTextureData=nuls 4*textureWidth*textureHeight
  xww=textureWidth-1
  yww=xww
  picdim=*strTextureData
   for yw=0 to yww ' first y: right flip direction!
    for xw=0 to xww
      GdipBitmapGetPixel picflip, xw, yw, colpix.colorx
      swap colpix.red, colpix.blue      
      *picdim=colpix.colorx
      picdim+=4 'increase
    next
  next
  '
  'Cleanup
  '
  if pThumb then GdipDisposeImage pThumb
  if pImage then GdipDisposeImage pImage
    print "ok: " wszFilename '' only for testpurpose!
  return hStatus
  
    GdiplusShutdown token

  end Function

that take a while to fix all problems and lines they needed to erase because of troubles and nonsens ;)

best regards, frank

X

Charles Pegge

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #13 on: March 21, 2013, 12:14:07 PM »
Hi Frank,

I've got an improved swap macro, slightly faster and more secure

macro swap(a,b)
scope
let _v_ = a : a=b : b= _v_
end scope
end macro


Another tip for creating unions: Using '=' resets the internal offset.

type pixel
byte red,green,blue,alpha
=
dword color
end type



Charles
« Last Edit: March 21, 2013, 12:25:23 PM by Charles Pegge »

Frankolinox

  • Guest
Re: nehe lesson 7 question about gdiPlusLoadTexture
« Reply #14 on: March 23, 2013, 02:57:10 AM »
thanks charles for updated commands :-)

here my working example (it's like nehe 7 not exactly same example) for a rotating cube with texture. I am learning with oxygenbasic, it's very interesting but sometimes hard work (*smile*) and the success is on my side.

place the openGL example into /example/GUI folder for running

Code: [Select]
 ''
  '' OPENGL NEHE Example Chapter 7 (nearly same content) for oxygen basic,
  '' modificated by frank brĂ¼bach alias frankolinox, 21.march.2013
  ''
  
  #case capital
  def NULL null

  includepath "..\..\inc\"
  '$ FileName "t.exe"
  'include "RTL32.inc"
  title = "Nehe 7 or Cube Rotation + Gdiplus_Texture Loading"
  include "OpenglSceneFrame.inc"
  include "imgwin.inc"

  sys GdiplusToken
  sys texn[16]


  'CREATE OPENGL TEXTURE
  '=====================

   type ColorPixel
    byte red,green,blue,alpha
    =
    dword colorx
   end type


  '------------------------------------------------------
  Sub MakeTexture(sys pPixelArray, TextureWidth, TextureHeight, Texnum )
  '======================================================
  '
  string LOCAL strTextureData AS STRING
  glBindTexture GL_TEXTURE_2D, texNum
  '
  'GL_NEAREST
  'GL_LINEAR
  '
  glEnable GL_TEXTURE_2D
  'glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
  
  '############################################
  'GL_NEAREST
  'GL_LINEAR
  'GL_NEAREST_MIPMAP_NEAREST         0x2700
  'GL_LINEAR_MIPMAP_NEAREST          0x2701
  'GL_NEAREST_MIPMAP_LINEAR          0x2702
  'GL_LINEAR_MIPMAP_LINEAR           0x2703
  '
  'glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST
  '############################################
  
  '
  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
  glTexImage2D GL_TEXTURE_2D, 0, 4, TextureWidth, TextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pPixelArray
  '
  '---------------- important for all 6 faces to show in openGL scene --------- //
   glClearDepth 1.0
   ' Specify the value used for depth-buffer comparisons
   glDepthFunc GL_LESS
   ' Enable depth comparisons and update the depth buffer
   glEnable GL_DEPTH_TEST
   ' Select smooth shading
   glShadeModel GL_SMOOTH
   '
   '---------------- important for all 6 faces to show in openGL scene --------- //
  End Sub

  '============================
  'GDIPLUS TEXTURE IMAGE LOADER
  '============================

  '-----------------------------------------------------
  function loadTexture(wstring wszfilename, sys textureWidth, sys textureHeight, string*strTextureData) as sys
  '=====================================================
  '
  sys hstatus,pImage,pThumb,token
  sys width,height,picflip,picdim,ref,xw,yw,xww,yww

   macro swap(a,b)
    scope
     let _v_ = a : a=b : b= _v_
    end scope
   end macro
  '
  GdiplusStartupInput StartupInput

  StartupInput.GdiplusVersion = 1
  hStatus=GdiplusStartup token, StartupInput, byval 0
  '
  if hStatus then
    print "Error initializing GDIplus: " hex hStatus
    exit function
  end if  
    
  hStatus = GdipLoadImageFromFile wszfilename, pImage
  hStatus = GdipGetImageThumbnail pImage, textureWidth, textureHeight, pThumb, NULL, NULL
  
  picflip=pthumb
  hStatus = GdipImageRotateFlip (picflip,6) ' RotateNoneFlipY =6 invert
  colorpixel colpix
  strTextureData=nuls 4*textureWidth*textureHeight
  xww=textureWidth-1
  yww=xww
  picdim=*strTextureData
   for yw=0 to yww ' first y: right flip direction  
    for xw=0 to xww
      GdipBitmapGetPixel picflip, xw, yw, colpix.colorx
      swap colpix.red, colpix.blue      
      *picdim=colpix.colorx
      picdim+=4 'increase
    next
  next
  '
  'Cleanup
  '
  if pThumb then GdipDisposeImage pThumb
  if pImage then GdipDisposeImage pImage
    print "ok: " wszFilename '' only for testpurpose  
  return hStatus
  
    GdiplusShutdown token

  end Function


  '-----------------------
  sub Initialize(sys hWnd)
  '=======================
  
  'GDIPLUS
  '=======
  string txt
  sys hr
  GdiplusStartupInput StartupInput

  StartupInput.GdiplusVersion = 1
  hr=GdiplusStartup GdiplusToken, StartupInput, byval 0
  '
  if hr then
    print "Error initializing GDIplus: " hex hr
    exit function
  end if
  '
  'Prepare Textures
  '----------------
  '
  glGenTextures 2, texn
  '
  static sys res=512
  string txt, imgs[1]=""
  
  loadTexture "crate.bmp",res,res, imgs[1]
  MakeTexture *imgs[1],res,res,texn[1]
  '
  SetTimer hWnd,1,10,NULL

  end sub


  sub Release(sys hWnd)
  '====================
  killTimer hwnd, 1
  glDeleteTextures 1, texn
  GdiplusShutdown GdiplusToken
  '
  end sub


  sub scene(sys hWnd)
  '==================
  '
  static single ang1, angi1=1
  static single sx,sy,sz
  sys    xrot,xspeed,yrot,yspeed
  static float rotation = 0
  '
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
  glClearColor 0, 0, 0, 0 '0.5, 0, 0, 0
  glLoadIdentity
  '
  'ACTIVATE TEXTURE
  '----------------
  '
  glEnable GL_TEXTURE_2D
  glBindTexture GL_TEXTURE_2D,texn[1]
  '
  sx=0.2 : sy=0.16 : sz=-1
  'sx=0.2 : sy=0.16 : sz=-1
  '
  '
  'MOVEMENT
  '--------
  '
  'glrotatef ang1, 0,0,1
  
  single x=cos(rad(ang1))*.1 ,y=sin(rad(ang1))*.1,z=0
  glTranslatef x+0, y+0, z-5
  glRotatef rotation, 0, 1, 0   ''glRotatef rotation, 0.2, 1, 0.2
    rotation+=.5
       if  rotation  > 360 then
         rotation -= 360
       end if
  '
  'DRAW SHAPE
  '----------
  '
  'this quad is drawn clockwise
  '
  glbegin GL_QUADS
  '
  ''glTexCoord2f 0,0 : glvertex3f -sx, -sy,  sZ
  ''glTexCoord2f 0,1 : glvertex3f -sx,  sy,  sZ
  ''glTexCoord2f 1,1 : glvertex3f  sx,  sy,  sZ
  ''glTexCoord2f 1,0 : glvertex3f  sx, -sy,  sZ
  '
  ' Front Face
      glNormal3f   0.0  , 0.0  , 1.0
      glTexCoord2f 0.0  , 0.0   : glVertex3f -1.0  , -1.0  ,  1.0  
      glTexCoord2f 1.0  , 0.0   : glVertex3f  1.0  , -1.0  ,  1.0  
      glTexCoord2f 1.0  , 1.0   : glVertex3f  1.0  ,  1.0  ,  1.0  
      glTexCoord2f 0.0  , 1.0   : glVertex3f -1.0  ,  1.0  ,  1.0  
      ' Back Face
      glNormal3f   0.0  , 0.0  , -1.0  
      glTexCoord2f 1.0  , 0.0   : glVertex3f -1.0  , -1.0  , -1.0  
      glTexCoord2f 1.0  , 1.0   : glVertex3f -1.0  ,  1.0  , -1.0  
      glTexCoord2f 0.0  , 1.0   : glVertex3f  1.0  ,  1.0  , -1.0  
      glTexCoord2f 0.0  , 0.0   : glVertex3f  1.0  , -1.0  , -1.0  
      ' Top Face
      ''glNormal3f   0.0  , 1.0  , 0.0  
      glTexCoord2f 0.0  , 1.0   : glVertex3f -1.0  ,  1.0  , -1.0  
      glTexCoord2f 0.0  , 0.0   : glVertex3f -1.0  ,  1.0  ,  1.0  
      glTexCoord2f 1.0  , 0.0   : glVertex3f  1.0  ,  1.0  ,  1.0  
      glTexCoord2f 1.0  , 1.0   : glVertex3f  1.0  ,  1.0  , -1.0  
      ' Bottom Face
      ''glNormal3f   0.0  ,-1.0  , 0.0  
      glTexCoord2f 1.0  , 1.0   : glVertex3f -1.0  , -1.0  , -1.0  
      glTexCoord2f 0.0  , 1.0   : glVertex3f  1.0  , -1.0  , -1.0  
      glTexCoord2f 0.0  , 0.0   : glVertex3f  1.0  , -1.0  ,  1.0  
      glTexCoord2f 1.0  , 0.0   : glVertex3f -1.0  , -1.0  ,  1.0  
      ' Right face
      ''glNormal3f   1.0  , 0.0  , 0.0  
      glTexCoord2f 1.0  , 0.0   : glVertex3f  1.0  , -1.0  , -1.0  
      glTexCoord2f 1.0  , 1.0   : glVertex3f  1.0  ,  1.0  , -1.0  
      glTexCoord2f 0.0  , 1.0   : glVertex3f  1.0  ,  1.0  ,  1.0  
      glTexCoord2f 0.0  , 0.0   : glVertex3f  1.0  , -1.0  ,  1.0  
      ' Left Face
      ''glNormal3f  -1.0  ,  0.0  , 0.0  
      glTexCoord2f 0.0  , 0.0   : glVertex3f -1.0  , -1.0  , -1.0  
      glTexCoord2f 1.0  , 0.0   : glVertex3f -1.0  , -1.0  ,  1.0  
      glTexCoord2f 1.0  , 1.0   : glVertex3f -1.0  ,  1.0  ,  1.0  
      glTexCoord2f 0.0  , 1.0   : glVertex3f -1.0  ,  1.0  , -1.0  
   glEnd

   'xrot = xrot + xspeed
   'yrot = yrot + yspeed
  
  glend
  '
  glDisable GL_TEXTURE_2D
  '
  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  'ang1+=angi1 : if ang1>=360 then ang1-=360
  '
  '
  end sub

in zip folder you find the "crate.bmp" image file, both include files, oxygen.dll for that example and of course the openGL example. but you need only to copy the openGL example into GUI folder and the "crate.bmp" image file for running. must work on your machine ;)

nice week end, best regards, frank


X
« Last Edit: March 23, 2013, 03:02:46 AM by Frankolinox »