Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Paul on July 04, 2007

Title: Freebasic opengl tutorials?
Post by: Paul on July 04, 2007
Hi
I'm looking for opengl tutorials for freebasic and I'm wondering if you got any suggestions?
saw the nehe ones, but they seem to need gl\glaux.bi for something and they're not fr freebasic which makes everything a little more complicated.

thx
//Paul
Title: Re: Freebasic opengl tutorials?
Post by: Shockwave on July 04, 2007
You might find some interesting things here;

http://rel.betterwebber.com/index.php?action=contents&item=Tutorials (http://rel.betterwebber.com/index.php?action=contents&item=Tutorials)

It's Relsoft's site, I know he has done some GL stuff, maybe he has some on his site.
Title: Re: Freebasic opengl tutorials?
Post by: Paul on July 04, 2007
THX for the reply, Ill check that sight when i get time:)

I'm doing the first tutorial and having problems with one part, resizing the screen when entering fullscreen mode. Here is that particular peice of code:

Code: [Select]
               dim dmScreenSettings as DEVMODE ' Device Mode
       clear(@dmScreenSettings,0,sizeof(dmScreenSettings)) ' Makes Sure Memory's Cleared
               dmScreenSettings.dmSize=sizeof(dmScreenSettings) ' Size Of The Devmode Structure
       dmScreenSettings.dmPelsWidth = widthh ' Selected Screen Width
       dmScreenSettings.dmPelsHeight = height ' Selected Screen Height
       dmScreenSettings.dmBitsPerPel = bits ' Selected Bits Per Pixel
       dmScreenSettings.dmFields=DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT
               ' Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
               if ChangeDisplaySettings(@dmScreenSettings,CDS_FULLSCREEN)<>DISP_CHANGE_SUCCESSFUL then
                  end
               endif

If you like i can post the full code

Thx again
//Paul
Title: Re: Freebasic opengl tutorials?
Post by: Shockwave on July 04, 2007
Yep, post the full listing and we'll see what's wrong :)
Title: Re: Freebasic opengl tutorials?
Post by: Paul on July 04, 2007
Here it comes, found an other problem... Does anyone know the value of WM_ACTIVE it doesn't seem to be declared?

anyway here comes the code
Title: Re: Freebasic opengl tutorials?
Post by: Jim on July 04, 2007
glaux is really very badly outdated, which is why noone uses it any more.

Jim
Title: Re: Freebasic opengl tutorials?
Post by: Rbz on July 05, 2007
THX for the reply, Ill check that sight when i get time:)

I'm doing the first tutorial and having problems with one part, resizing the screen when entering fullscreen mode. Here is that particular peice of code:

Code: [Select]
               dim dmScreenSettings as DEVMODE ' Device Mode
       clear(@dmScreenSettings,0,sizeof(dmScreenSettings)) ' Makes Sure Memory's Cleared
               dmScreenSettings.dmSize=sizeof(dmScreenSettings) ' Size Of The Devmode Structure
       dmScreenSettings.dmPelsWidth = widthh ' Selected Screen Width
       dmScreenSettings.dmPelsHeight = height ' Selected Screen Height
       dmScreenSettings.dmBitsPerPel = bits ' Selected Bits Per Pixel
       dmScreenSettings.dmFields=DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT
               ' Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
               if ChangeDisplaySettings(@dmScreenSettings,CDS_FULLSCREEN)<>DISP_CHANGE_SUCCESSFUL then
                  end
               endif

If you like i can post the full code

Thx again
//Paul

@Paul: I can't test your code, probably you're using a new FB version (I'm still using 0.15 beta)

Anyway try to change this line:
Code: [Select]
clear(@dmScreenSettings,0,sizeof(dmScreenSettings))to:
Code: [Select]
ZeroMemory(@dmScreenSettings, sizeof (DEVMODE))Maybe that help...

About "WM_ACTIVATE"  (not "wm_active"), this message is sent when a window is being activated or deactivated.
use this command to active your window (after CreateWindowEx command):
SetActiveWindow( hWnd )


Title: Re: Freebasic opengl tutorials?
Post by: Jim on July 05, 2007
Code: [Select]
dmScreenSettings.dmPelsWidth = widthh
Is there deliberately an extra h on the end of width there?  If so, you can spot problems like that by adding
Code: [Select]
option explicit
to the start of your program which points out these errors.

Jim
Title: Re: Freebasic opengl tutorials?
Post by: Paul on July 05, 2007
The problem with width is that it goes bold and i don't seem to be allowed to pass it to my function, therefor i wrote widthh in all the places. Tried replacing the Clear with Zeromemory, but it doesn't help:(

Here is modified code with option explicit.

Thank you for your support
Paul
Title: Re: Freebasic opengl tutorials?
Post by: ninogenio on July 05, 2007
i know this might not be much help paul but i use either sdl or freebasics own commands for easy setup as i dont think gdi stuff works very great in fb.

if you like i can post a small example up in both to show you how to get a window open for youse with gl.
Title: Re: Freebasic opengl tutorials?
Post by: Paul on July 05, 2007
Ok,
What are the main differences betwen gdi and sdl?
Is one faster?
Do i have the same shader options and that sort of thing?

I really don't know much about this.
Paul

EDIT:
tried the SDL examples in the freebasci folder and thy tell me that i havent got SDL.DLL in my systemfolder, where do i download this? Does it work with windows 2K? Am i asking to many questions? Have I already got it but the wrong version or is there an other reason?

EDIT 2:
Downloading SDL.dll now :)
Title: Re: Freebasic opengl tutorials?
Post by: ninogenio on July 06, 2007
sdl will have the same gl performance as gdi, it lets you set up the window a little easyer but you will need the sdl.dll in the project folder.

the other choice is by yousing the fb screen and flip command you can easily get gl going without the need for an external dll.

-edit you will still have all the options like shaders extensions etc sdl gdi and freebasic just aid in seting up the window for gl to draw on it sdl should work fine in 2k.

the other thing with sdl is that it goes a little further that just helping set up a window it has timer funcs key handling etc.

now there is also one other lib that comes with freebasic to help open windows and stuff its called glfw. if you look in the include folder of your freebasic install you will see it, i dont know to much about it but there is some examples floating around here incase your intrested.

you can yous any one of these options its just a matter of prefrence as to what suits you best really ;)