Author Topic: Freeglut excursions  (Read 7106 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: Freeglut excursions
« Reply #15 on: September 26, 2016, 06:34:33 AM »
Hi Roland,

OpenglSceneFrame.in and CosoleG.inc provide base code for various OxygenBasic examples.

These include:

  Opengl Window setup
  AntiAliasing
  Lighting
  Textures
  Image-based textures
  Image Capture
  movement
  mouse and keyboard
  object picking 
  base geometries
  3d Text


There is quite a lot of Nehe in there, and you are welcome to use this code or extract whatever you need to customise or extend the functionality.

For the purpose of making a texture from an image file (using some GDIplus), This demonstratescreating a texture and applying it to a quad.

It will work in ProjectsA\Openglcns\

Code: [Select]

  % Title "Console Demo"
 '% Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
  include "$\inc\ConsoleG.inc"

 BeginScript

  sub main
  ========
  static sys   imgn,res,wi,ht
  if not imgn
    imgn=21
    res=0 'use wi and ht of image
    LoadTexture "../../examples/images/Dawn1815.jpg",imgn,res,wi,ht
  end if
  cls
  pushstate
    move 15,-15
    '
    'display image
    '
    flat : color 1,1,1,1
    texture imgn
    quadnorm 15.0,15.0*ht/wi 'apply image texture to a quad
    texture 0
  popstate

  end sub 'main

  EndScript

.

Arnold

  • Guest
Re: Freeglut excursions
« Reply #16 on: September 26, 2016, 07:28:36 AM »
Thank you Charles. This is a lot of learning matter to study. My objective is to build the nehe lessons using freeglut and soil (to see what should happen) and then replace the soil functions with Oxygen's own facilities. I think this will be an exciting and very interesting task (at least for me).

Arnold

  • Guest
Re: Freeglut: NeHe Lesson 1 - 10
« Reply #17 on: September 30, 2016, 07:43:59 AM »
Hello,

attached are the first 10 lessons of NeHe's tutorial as a zip file. I used freeglut and soil library. The folder NeHe_Freeglut can be stored as is anywhere on disk or usb-stick and the programs can be opened in subfolder Lesson01_10. They can also be opened and run with Scite and Oxide.

There is a small problem with lesson10 as there are missing faces on the walls, floor and ceiling. I have added some print statements in a console window. Perhaps somebody can show me what I did wrong or Peter can show how he achieves lesson 10 with his gl library. Nevertheless the app already looks quite nice. I wished I could have started 10 years ago with OpenGL but there were other priorities at that time.

@Charles - I recognized that fgUtil.inc in folder projectsA\freeglut is another hidden jewel provided with Oxygenbasic. There is a lot of potential in this include file. When I am through with the NeHe tutorials maybe it can be extended still a little bit more.

Roland

Edit: zip file deleted. Attached new zip file with later message

.
« Last Edit: October 08, 2016, 02:31:02 AM by Arnold »

Mike Lobanovsky

  • Guest
Re: Freeglut excursions
« Reply #18 on: September 30, 2016, 03:55:40 PM »
Roland,

You loaded textures miss two important parameters, namely how they should be distributed across the surfaces in S and T (i.e. two orthogonal) directions. You may want to add the following two lines to your texture parameter block to get the glitch fixed:

      // Define Texture Parameters
      glBindTexture(GL_TEXTURE_2D, texture[ i ])
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_param)
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_param)
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)



.

Arnold

  • Guest
Re: Freeglut excursions
« Reply #19 on: October 01, 2016, 01:30:18 AM »
Thank you Mike for your aid. I suppose I will never be able to return the favour. This was a small leak which caused a big effect and I have to pay special attention for these things in the future. If I comment out include console.inc, remove the print statements and the debugging loops then lesson 10 runs like the original code - but toggling between fullsize and windowed mode works better.

I am looking forward now to go through the next ten lessons.

Roland

Arnold

  • Guest
Re: Freeglut: NeHe Lesson 1 - 20
« Reply #20 on: October 08, 2016, 02:36:40 AM »
Hello,

attached are the first 20 lessons of NeHe's tutorial as a zip file. The folder NeHe_Freeglut can be stored as is anywhere on disk or usb-stick, the programs are in folder Lesson01_10 and Lesson11_20. I extended lesson01 framework a little bit, changed the format of some images and added Mike's corrections in lesson10. The keys which can be used are noted at the beginning of the code.

There are some interesting aspects with the demos 11-20. In lesson 14 and 15 I combined freeglut with minwin.inc. If this works it would offer a lot of additional possible applications. In lesson 13, 14, 14a I applied glutIdleFunc instead of glutTimerFunc. This makes a big difference with older and newer computers and I will use glutTimerFunc in the future.

Of course most of the things which I ported to OxygenBasic I did not really understand. My major goal currently is to see how the demos work. I noticed that the NeHe tutorials meanwhile were ported to many different programming languages so it is an interesting exercise to see them run with Oxygenbasic too.

Unfortunately I will not be able to work with Oxygen in the next two weeks or so. But then hopefully I will continue with lesson 21-30.

Roland


.