Nehe tutorial

BlitzMax Forums/BlitzMax Tutorials/Nehe tutorial

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This is the beginnings of a little compatibilizer for these tutorials, to get the old source working in the newer BlitzMax.

rem
Awful Compatibilizer For BlitzMax NeHe tutorials.
I highly recommend that you do not use this elsewhere!

Warning: All mention of bgl will be replaced by gl.
I don't think there are any words with bgl in them,
but there is always a chance that something can get
broken. If you are willing, feel free to fix it :)


Directions:

-All source files must be placed in the same directory.
-Compile this and place the program in the same directory as the source code
end rem

Framework brl.basic

'Put the path to the NeHe tutorial example source here...
Global NeHePath:String
'NeHePath = Input("Please input the path to the tutorials.")
NeHePath = AppDir 'May as well run this silently...

dir = ReadDir(NeHePath)

If dir=Null
	Print "Failed to read requested directory"
	End
EndIf

ChangeDir(NeHePath) 'Now the returned file paths, local to dir, will work

CreateDir("Fixed")

Repeat
	filename:String=NextFile( dir ) 'Hm... can I skip this step and just jump to a file handle?
	If filename="" Then Exit
	
	Print "Examining file: " + filename
	
	If FileType(filename)=FILETYPE_FILE and filename[Len(filename)-4..]=".bmx" 'Only processing *.bmx files...
		f:TStream = OpenFile(filename)
		
		'CreateFile("Fixed/"+filename)
		fnew:TStream = WriteFile("Fixed/"+filename)
		
		If not f=Null
			While not Eof(f)
				Local inLine:String=f.ReadLine()
				Local changeLine:String=inLine.ToLower()
				Local LineChanged:Byte=0
				
				'Change brl.blitzgl to brl.GLGraphics
				If changeLine.Find("brl.blitzgl") > - 1
					changeLine=changeLine.Replace("brl.blitzgl","brl.GLGraphics")
					LineChanged=1
				EndIf
				
				'Change bglSwapBuffers to flip
				If changeLine.Find("bglswapbuffers") > - 1
					changeLine=changeLine.Replace("bglswapbuffers","Flip")
					LineChanged=1
				EndIf
				
				'Change bglcreatecontext to glgraphics
				If changeLine.Find("bglcreatecontext") > - 1
					changeLine=changeLine.Replace("bglcreatecontext","GLGraphics")
					LineChanged=1
				EndIf
				
				'Change bgl prefix to gl
				If changeLine.Find("bgl") > - 1
					changeLine=changeLine.Replace("bgl","gl")
					LineChanged=1
				EndIf
				
				'Get rid of FlushMem
				If changeLine.Find("flushmem") > - 1
					changeLine=changeLine.Replace("flushmem","")
					LineChanged=1
				EndIf
				
				if LineChanged = 1
					fnew.WriteLine(changeLine+" '"+inLine)
				Else
					fnew.WriteLine(inLine)
				EndIf
			Wend
			CloseFile(f)
		EndIf
	EndIf
Forever

Print "All done!"

CloseDir dir
End

Just compile it (don't compile and run), move the result to the directory containing the source code, and run it.
It will silently (not by design but because I can't figure out how to make an application run in Windows's console :/) create a directory called Fixed containing your new tutorials, many of which are now working!
Remember to copy the data directory over or move the fixed files back.

I've probably missed a few (such as glsetmousevisible, which for now is just getting commented out in a manner that can break single-line if then else statements), and there are a few things which seem to have changed in the language itself that are just totally beyond me and would probably require this app become complicated.
Running in windowed mode doesn't seem to work, either.

It would be great to get these working 100% again!
It's a real shame that all this great software was made obsolete :(