The perfect use of FrameWork

BlitzMax Forums/BlitzMax Programming/The perfect use of FrameWork

flaith(Posted 2004) [#1]
i try to understand Opengl and i made a little prog. But when i compile it the size of the exe was 768 Kb :(

bglCreateContext (800,600,16,0,BGL_BACKBUFFER|BGL_DEPTHBUFFER)

While Not KeyHit( KEY_ESCAPE )

	glClearColor (0.0, 0.0, 0.0, 0.0)
	glClear (GL_COLOR_BUFFER_BIT)

	glPushMatrix ()
	glRotatef (theta, 0.0, 0.0, 1.0)
	glTranslatef (0.0, 0.0, 0.0)
	glEnable (GL_LINE_SMOOTH)
	
	glBegin (GL_TRIANGLES)
	glColor3f (1.0, 0.0, 0.0);   glVertex2f (0.0, 1.0)
	glColor3f (0.0, 1.0, 0.0);   glVertex2f (0.87, -0.5)
	glColor3f (0.0, 0.0, 1.0);   glVertex2f (-0.87, -0.5)

	glEnd ()
	glPopMatrix ()

	theta :+ 1.0
	Delay (10)
	
	bglSwapBuffers

Wend


i've just added 2 lines in the beginning:

Framework BRL.BlitzGL

Import BRL.System

bglCreateContext ..........


size : 50Kb :)


flying willy(Posted 2004) [#2]
is there a guide to frameworks?


flaith(Posted 2004) [#3]
in the Help -> Language reference -> modules


flaith(Posted 2004) [#4]
same with the Teapot example from Peter Scheutz

in teapot_test.bmx :
Framework BRL.BlitzGL

Import BRL.System
...

in teapot.bmx:
Import BRL.Bank
...



GregBUG(Posted 2004) [#5]
Sorry, but why if i test this code:

Strict
FrameWork BRL.Max2D

Function SetupSystem()
Graphics 640, 480
End Function

SetupSystem()

While Not KeyHit(KEY_ESCAPE)
Cls
Flip
Wend

the compiler stop and say:
"D:/Programmi_Gianluca/BlitzMAX/Studio/GSaver"
Graphics mode does not exist
Process complete

ahhhh!!!! framework NightMare!!!!! HELP!


JaviCervera(Posted 2004) [#6]
I think that the fact that 'Framework' takes one parameter does not make much sense :( You will use more than one module in 99% of the cases, so you have to type 'Framework module' for the first case, and 'Import module' for the rest of the modules. IMHO, it would make more sense if 'Framework' didn't get any parameters, and you specified the modules you want to use with 'Import'. So:

Framework BRL.BlitzGL
Import BRL.System

would become:

Framework
Import BRL.BlitzGL
Import BRL.System



John Pickford(Posted 2004) [#7]
Any reason why modules can't be imported automatically? Triggered by any call to a function in a given module I mean.


Perturbatio(Posted 2004) [#8]
Any reason why modules can't be imported automatically? Triggered by any call to a function in a given module I mean.


Seems like a nice idea, one problem I can see is that the compiler would need to know which mod contains the relevant command.
But that could be done by searching the modules which could take some time when you have a lot of mods.
Perhaps each .mod folder could contain an index that lists the commands it contains (making searching quicker), this index could be autogenerated when the bmx file is rebuilt.

*EDIT*
Another problem I can see is with duplicate functions, which is inevitably going to happen if you use 3rd party modules.


semar(Posted 2004) [#9]
Good point John, that would be useful.

Sergio.


flaith(Posted 2004) [#10]
@GregBUG

try that way

Framework BRL.GLMax2D

Import BRL.System

Function SetupSystem()
Graphics 640,480    'bglCreateContext 640,480,32,0,BGL_BACKBUFFER|BGL_DEPTHBUFFER
End Function

SetupSystem()

While Not KeyHit(KEY_ESCAPE)
Cls
Flip
Wend 



Warren(Posted 2004) [#11]
Any reason why modules can't be imported automatically? Triggered by any call to a function in a given module I mean.

That would be awesome.


ImaginaryHuman(Posted 2004) [#12]
It'd be nice to have a feature in the IDE or something to automatically insert code for the frameworks that you need only to compile the current program


flaith(Posted 2004) [#13]
Why not directly from the IDE.
I think it's much better !
-> Don't need to import mod. when you build your prog, the IDE will made the imports for you :)


flying willy(Posted 2004) [#14]
I would love this automatic handling of modules.

Please make it happen.


Diordna(Posted 2004) [#15]
I think I will write a program that will determine this for you. However, it will take me an annoyingly long time to write because of all of the commands. Anyone care to help?

(ooh, perhaps I can write a module parser much like Blitz help does...)


flaith(Posted 2004) [#16]
i'm in if you want to !


flaith(Posted 2004) [#17]
NB: its about the IDE, don't you ?


Warren(Posted 2004) [#18]
Hrm?


flaith(Posted 2004) [#19]
sorry, i'm french and i've got a very bad language ? my fault !


Warren(Posted 2004) [#20]
Just don't understand what you're trying to say is all...


flaith(Posted 2004) [#21]
just to make an IDE for BMX with the obvious module parser included -> so i'm in :)


Phish(Posted 2004) [#22]
sorry, i'm french and i've got a very bad language ? my fault !
Bad language? Mind your french! ;-)

Anyway - I definitely want automatic module importing too. It would be nice if it did it automatically until it found dupicate commands, or had some other problems, and at that point gave a compilation error and told you to do it yourself.

As for speed, surely it wouldn't be that slow to keep an index of commands and which modules they belong to?! Afterall, it keep an index of commands just for syntax highlighting!


skidracer(Posted 2004) [#23]
The main sticking point is things like imageloaders, the fact you are using the LoadImage command has no bearing on which image loader modules are included.

I like the idea of the higher level solution (implement it at IDE level). The .i intermediate files BlitzMax produces should be a lot easier to parse than .bmx so it may not be such a difficult task either.


flaith(Posted 2004) [#24]
a clever parser inside the "B'Max IDe", that is not an utopia.


AntonyWells(Posted 2004) [#25]
It would be nice if you use the parser for something for useful, like

Framework BRL[LinkedList,System,PixMaps]
          Pub[OpenGL]
          Lua[LuaScript]


Also, the ability to read frameworks from a file..so you could create custome framework defs like the above and place them in a framework folder, then like for the above,

FrameWork Minimal_App
FrameWork Brl[Etc.]
-

Then,

FrameWork Minimal_app in blitz will use that..

I hate the idea of it being tied to the ide. that means click this, click that...i'd rather type it, but not have to retype a ton of headers for every source.


flaith(Posted 2004) [#26]
well, agreed with you Antony !


Dreamora(Posted 2004) [#27]
If you have a given "Framework Setup" as standard that you use you could create a new module directory called "Frameworks" where you simply create modules that just imports the module you would need for the given type of app. ( just an idea ... created one for my base framework setup :) )

I like the way it actually works but might be because I use protean BM beta where I can simple browse the stuff to see what module I need ...


flying willy(Posted 2004) [#28]
hey dreamora - how do you like protean, do you recommend it?


Dreamora(Posted 2004) [#29]
Although it is only Beta at the moment I can recommend it, especially for those that plan to program fully on OO and not using the "flat functions" which is the only thing in the help, because the module viewer shows all types and their functions / internal values / methods of the modules in the mod directory.


Hotcakes(Posted 2004) [#30]
Protean is the equivalent of taking an elephant and giving it a rocketship. =]