It is currently Sun Jul 05, 2020 5:35 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Thu Nov 13, 2014 6:45 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2042
Location: USA
flaith wrote:
Sorry to dig up this post, but I need to know if Purebasic still use OpenGL 1.2 because I tried with my old laptop (OpenGL 1.4) and the sprite system no longer works.
He could be useful to check the OpenGL version and to have a function for this or a warning from the compiler :)

I have an OpenGL 1.4 ATI card on a Windows ME pc and it seems to work.

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Tue Dec 16, 2014 5:18 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 5:05 pm
Posts: 1769
Location: Norway
Gotta love thread necromancy (sometimes).

Here's an example on how to fetch the OpenGL version.

A few things to keep in mind though, only call Get_OpenGL_Version() after you have used OpenScreen() or OpenWindowedScreen() trying to call this before that (but after InitSprite() will not work.

And obviously this will only work if the subsytem is OpenGL.
The version.revision is returned, if no revision then only the version is returned (no dot) and if getting the version fails then a empty string is returned.

AFAIK this should work even with OpenGL 1.1 (maybe OpenGL 1.0), simply told it should work on Windows 2000 and later, this should also work on Linux/Mac.

Code:
CompilerIf Subsystem("OpenGL")
   #GL_VERSION=$1F02
   Procedure.s Get_OpenGL_Version()
      Protected *ext,text$,ver$,version$,revision$
      *ext = glGetString_(#GL_VERSION)
      If *ext
         text$=PeekS(*ext,256,#PB_Ascii)
         ver$=StringField(text$,1," ")
         version$=StringField(ver$,1,".")
         revision$=StringField(ver$,2,".")
         If revision$ And version$
            text$=version$+"."+revision$
         ElseIf version$
            text$=version$
         Else
            text$=""
         EndIf
      EndIf
      ProcedureReturn text$
   EndProcedure
CompilerEndIf


If InitSprite() = 0
   MessageRequester("Error", "Can't open screen & sprite environment!", 0)
   End
EndIf


If OpenWindow(0, 0, 0, 220, 160, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ButtonGadget(0, 170, 135, 45, 20, "Quit")
   
   If OpenWindowedScreen(WindowID(0), 0, 0, 160, 160)
      CreateSprite(0, 20, 20)
      If StartDrawing(SpriteOutput(0))
         Box(0, 0, 20, 20, RGB(255, 0, 155))
         Box(5, 5, 10, 10, RGB(155, 0, 255))
         StopDrawing()
      EndIf
   Else
      MessageRequester("Error", "Can't open windowed screen!", 0)
      End
   EndIf
EndIf

Debug "WTF"
Debug Program_Get_OpenGL_Version()
Debug "WTF"

direction = 2
Repeat
   ; It's very important to process all the events remaining in the queue at each frame
   ;
   Repeat
      Event = WindowEvent()
      
      Select Event
         Case #PB_Event_Gadget
            If EventGadget() = 0
               End
            EndIf
            
         Case #PB_Event_CloseWindow
            End
      EndSelect
   Until Event = 0
   
   FlipBuffers()
   ClearScreen(RGB(0, 0, 0))
   DisplaySprite(0, x, x)
   x + direction
   If x > 140 : direction = -2 : EndIf
   If x < 0   : direction =  2 : EndIf
   Delay(1)
ForEver


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Wed Dec 17, 2014 6:25 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2042
Location: USA
On OS X, you'll have to import OpenGL. Anyway, returns OpenGL version 1.3 here on XP and 2.1 on Snow Leopard. Looks like this returns what your graphics card can currently handle and not PureBasic's OpenGL version. I would guess PureBasic is still using 1.2+ like Fred had said a while back?

Thanks Rescator! ;)

Code:
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
 ImportC "/System/Library/Frameworks/OpenGL.framework/OpenGL"
   glGetString_(Version.i) As "_glGetString"
 EndImport
CompilerEndIf

CompilerIf Subsystem("OpenGL") And #PB_Compiler_OS = #PB_OS_Windows Or #PB_Compiler_OS = #PB_OS_MacOS
   #GL_VERSION=$1F02
   Procedure.s Get_OpenGL_Version()
      Protected *ext,text$,ver$,version$,revision$
      *ext = glGetString_(#GL_VERSION)
      If *ext
         text$=PeekS(*ext,256,#PB_Ascii)
         ver$=StringField(text$,1," ")
         version$=StringField(ver$,1,".")
         revision$=StringField(ver$,2,".")
         If revision$ And version$
            text$=version$+"."+revision$
         ElseIf version$
            text$=version$
         Else
            text$=""
         EndIf
      EndIf
      ProcedureReturn text$
   EndProcedure
CompilerEndIf


If InitSprite() = 0
   MessageRequester("Error", "Can't open screen & sprite environment!", 0)
   End
EndIf


If OpenWindow(0, 0, 0, 220, 160, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ButtonGadget(0, 170, 135, 45, 20, "Quit")
   
   If OpenWindowedScreen(WindowID(0), 0, 0, 160, 160)
      CreateSprite(0, 20, 20)
      If StartDrawing(SpriteOutput(0))
         Box(0, 0, 20, 20, RGB(255, 0, 155))
         Box(5, 5, 10, 10, RGB(155, 0, 255))
         StopDrawing()
      EndIf
   Else
      MessageRequester("Error", "Can't open windowed screen!", 0)
      End
   EndIf
EndIf

Debug "WTF"
Debug Get_OpenGL_Version()
Debug "WTF"

direction = 2
Repeat
   ; It's very important to process all the events remaining in the queue at each frame
   ;
   Repeat
      Event = WindowEvent()
     
      Select Event
         Case #PB_Event_Gadget
            If EventGadget() = 0
               End
            EndIf
           
         Case #PB_Event_CloseWindow
            End
      EndSelect
   Until Event = 0
   
   FlipBuffers()
   ClearScreen(RGB(0, 0, 0))
   DisplaySprite(0, x, x)
   x + direction
   If x > 140 : direction = -2 : EndIf
   If x < 0   : direction =  2 : EndIf
   Delay(1)
ForEver

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Wed Dec 17, 2014 8:51 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3698
Location: Italy
J. Baker wrote:
... returns OpenGL version 1.3 here on XP and 2.1 on Snow Leopard. Looks like this returns what your graphics card can currently handle and not PureBasic's OpenGL version. I would guess PureBasic is still using 1.2+ like Fred had said a while back?


On the same hw ? I mean are you using the MacBook Air 2010 from your signature and you get 2.1 on OSX and 1.3 on XP ?
Because in this case you can probably just update your Windows drivers.
Again if it's the same card, what card is it exactly ? Just curious.

About what glGetString_(#GL_VERSION) tells you:

#GL_VERSION returns the OpenGL version associated to the rendering context created by PB.

It's not necessarily the highest OpenGL version supported by the driver/card combination.

PB afaik asks for a legacy OpenGL RC, so you can have three different outcomes.

1) The driver does support only a legacy version of OpenGL up to 2.1 (maybe 1.4, maybe 1.2, maybe 2.0 ..., whatever)
The OpenGL version associated to the RC will be a version not higher than 2.1.
This is the case for older drivers before the introduction of OpenGL 3.0+

2) The driver does support a core profile (OpenGL 3.0+) and ALSO a compatibility profile.
The OpenGL version associated to the RC will be a version > 2.1 up to the highest version for which a compatibility profile is available (starting from 3.2 where the compatibility profile was introduced, there is a hole before that).
So even if PB is asking for a legacy OpenGL RC, you end up with a version like 3.2 or 4.4 or whatever. And you can actually use some modern functions while still following the legacy OpenGL programming style. You can mix legacy with new.
This is what typically happens with modern drivers from the major vendors (nVidia, AMD, Intel) under Windows and very often under Linux.

3) The driver does support a core profile (OpenGL 3.0+) but NOT a compatibility profile.
The OpenGL version associated to the RC will be a version up to 2.1, should be 2.1 in fact.
This is what happens under OSX, where Apple decided to not support a compatibility profile and the highest OpenGL versions are available only when requesting a core profile.

And yes, the returned string with the OpenGL version does not tell you what PB requires/use, just what OpenGL version is available to it (and to you) after the RC creation.

So this does not answer flaith's question :|

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Wed Dec 17, 2014 9:16 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2042
Location: USA
luis wrote:
J. Baker wrote:
... returns OpenGL version 1.3 here on XP and 2.1 on Snow Leopard. Looks like this returns what your graphics card can currently handle and not PureBasic's OpenGL version. I would guess PureBasic is still using 1.2+ like Fred had said a while back?


On the same hw ? I mean are you using the MacBook Air 2010 from your signature and you get 2.1 on OSX and 1.3 on XP ?
Because in this case you can probably just update your Windows drivers.
Again if it's the same card, what card is it exactly ? Just curious.


Oh no. I have XP on a different machine. It has an older ATI card, which I like for development. That way I know the game I'm working on will work with older computers. Plus it allows me to make sure the game is running optimized. So hopefully no complaints on performance issues when I'm done with it. As for the driver though, it's the latest available for XP due to its age. ;)

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Thu Dec 18, 2014 12:11 am 
Offline
Addict
Addict
User avatar

Joined: Mon May 14, 2007 2:13 am
Posts: 979
Location: Darling River
Image
J. Baker, I see you are still running, do you ever get tired. :)

_________________
PureBasic Rocks! Even More! And More!
PureBasic 5, Now We're Really Rockin!


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Thu Dec 18, 2014 12:27 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3698
Location: Italy
I hope he's running in the right direction ... :P

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Thu Dec 18, 2014 1:18 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2042
Location: USA
electrochrisso wrote:
Image
J. Baker, I see you are still running, do you ever get tired. :)

Funny thing is, I have issues with sleep. Three to four hours of sleep is pretty common with me but I eventually crash. Sometimes it takes a week or two but I eventually get almost eight hours. ;)

luis wrote:
I hope he's running in the right direction ... :P

Not all the time, lol. ;)

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Thu Dec 18, 2014 11:11 pm 
Offline
Addict
Addict
User avatar

Joined: Mon May 14, 2007 2:13 am
Posts: 979
Location: Darling River
J. Baker wrote:
Funny thing is, I have issues with sleep. Three to four hours of sleep is pretty common with me but I eventually crash. Sometimes it takes a week or two but I eventually get almost eight hours. ;)

Hey Fred! See what PureBasic can do to a person. :lol:

_________________
PureBasic Rocks! Even More! And More!
PureBasic 5, Now We're Really Rockin!


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic OpenGL Version?
PostPosted: Fri Dec 19, 2014 12:39 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2042
Location: USA
electrochrisso wrote:
J. Baker wrote:
Funny thing is, I have issues with sleep. Three to four hours of sleep is pretty common with me but I eventually crash. Sometimes it takes a week or two but I eventually get almost eight hours. ;)

Hey Fred! See what PureBasic can do to a person. :lol:

LOL! You got that right. ;)

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye