It is currently Tue Nov 19, 2019 1:59 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 42 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Thu Feb 16, 2012 8:35 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 2936
Location: Planet Earth
Thanks xorc1zt! Very nice, but did not work out of the box:
- first nothing happend when starting the examples
- enabled debugger, it told me opengl subsystem is required (can you set opengl subsys in you examples by default?)
- added subsystem opengl in compileroptions for all 3 examples
- always same crash:
Code:
[ERROR] Invalid memory access. (read error at address 0)

- I replaced the 2 macros with:
Code:
Procedure.s glGetStringi(name,index)
    Define *stringpointer
    If glGetStringi_
        *stringpointer = glGetStringi_(name,index)
        If *stringpointer
            ProcedureReturn PeekS( *stringpointer )
        EndIf
    EndIf
   
 
    ProcedureReturn "#NULL"
EndProcedure

Procedure.s glGetString(name)
    Define *stringpointer
   
    If glGetString_
        *stringpointer = glGetString_(name)
       
        If *stringpointer
            ProcedureReturn PeekS( *stringpointer )
        EndIf
    EndIf
   
    ProcedureReturn "#NULL"
EndProcedure

- now the error comes for: id = glCreateShader( type )
Code:
[ERROR] Invalid memory access. (read error at address 0)




Now i disabled unicode mode and everything works fine!

In Unicode mode many functions are Null, OpenGL Info is:
Code:
--- OpenGL Infos:
OpenGL Vendor:       呁⁉敔档潮潬楧獥䤠据.
OpenGL Renderer:    䵁⁄慒敤湯䠠⁄㤶〰匠牥敩s 6900 Series
OpenGL Version:    ⸴⸲ㄱ㤳‹潃灭瑡扩汩瑩⁹牐景汩⁥潃瑮硥t
OpenGL Shader:       ⸴〲㄀㤳9

With disabled unicode mode everything is fine:
Code:
--- OpenGL Infos:
OpenGL Vendor:       ATI Technologies Inc.
OpenGL Renderer:    AMD Radeon HD 6900 Series
OpenGL Version:    4.2.11399 Compatibility Profile Context
OpenGL Shader:       4.20

Does GetFunction() in setGLCORE not work with unicode strings?

You may want the full log files: pbgl_log.zip

Thank you!


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Fri Feb 17, 2012 3:21 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
thanks for your feedback, everything should be fixed now.

The problem was that opengl doesn't handle unicode and i did all the prototype quickly with a script and didn't tough about unicode.

to fix this i did
1. replace prototype string argument with .p-ascii
2. import wgl functions myself, the purebasic ones doesn't convert string arguments to ascii.
4. add #PB_ASCII to PeekS
3. convert the shader source code to ascii before call glshadersource()

link http://demo.ovh.com/en/c08cf531f2812b8a ... 619cc96e9/

edit: about opengl subsystem, i don't know how to set it automatically and you don't need it if you use windows api like the orthogonal example.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Fri Feb 17, 2012 7:25 am 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 2936
Location: Planet Earth
xorc1zt wrote:
thanks for your feedback, everything should be fixed now.

Thanks xorc1zt, works better now.

There is still a small mistake that makes EXAMPLE_ORTHOGONAL.pb crash w/o debugger.
After enabling the Debugger I got a crash at a point i could not see an error. I tried again
and the error was different and on an other line in the source.
So i enabled the Purifier in compiler options and... voila:
Code:
[ERROR] glbase.pb (Line: 1360)
[ERROR] Overflow in a dynamically allocated memory block.

It is in the procedure pbglLoadShader():
Code:
        CompilerIf #PB_Compiler_Unicode
            *pbuff = AllocateMemory( Len(sourcestringbuffer)+SizeOf(Character) ) ; should be Len() + SizeOf(Character)
            PokeS( *pbuff, sourcestringbuffer, -1, #PB_Ascii )

and 5 lines below:
Code:
        CompilerIf #PB_Compiler_Unicode
            *pbuff = AllocateMemory( Len(source)+SizeOf(Character) ) ; should be Len() + SizeOf(Character)
            PokeS( *pbuff, source, -1, #PB_Ascii )

PokeS() adds a terminating 0 after the string content, and for Unicode it is two 0's.

After this small changes everything works fine here so far. Maybe adding some
checks after all AllocateMemory would be good, in case it fails and returns 0.

xorc1zt wrote:
The problem was that opengl doesn't handle unicode and i did all the prototype quickly with a script and didn't tough about unicode.

I also forgot about Unicode very often and wrote things like '*pointer + 1'.
To force myself to write better code, i enabled Unicode in the default compiler settings, so it is
always enabled here for new sources. This way I can't forget it and got used to it after a while. :)

xorc1zt wrote:
edit: about opengl subsystem, i don't know how to set it automatically and you don't need it if you use windows api like the orthogonal example.

Just set it in compiler options for the 3 examples:
Code:
Library Subsystem: [ opengl                ]

and save the source again after the change.

If you open the sources with another text editor, you see the hidden options
at the end of .pb files. For example:
Code:
; EnableUnicode
; EnableXP
; CPU = 5
; SubSystem = opengl
; EnablePurifier


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Fri Feb 17, 2012 7:53 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
thanks

i tried on x64 only and there was no errors


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Fri Feb 17, 2012 5:29 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Sep 20, 2004 7:12 am
Posts: 519
Location: Hell
You might also add this to the head of your source:
Code:
CompilerIf Subsystem("OpenGL") = 0
   CompilerError "You have to enable OpenGL Subsystem to run this code"
CompilerEndIf


(not anyone uses the hidden parameters in the source)

_________________
Link dead?
Change h3x0r.ath.cx into hex0rs.coderbu.de and all will be fine.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Sat Feb 18, 2012 2:07 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
already done at _pbglInitGLBase(), i don't use the purebasic ide but Sublime Text

Code:
    If _pbgl_setting\pbgl_context_method = #PBGL_PUREBASIC 
        CompilerIf Subsystem( "OpenGL" ) = #False
            Debug "You must use OpenGL as subsystem !!!"
            End
        CompilerEndIf
       
        If Not InitSprite()
            Debug "initsprite fail"
            End
        EndIf
    EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Thu Feb 23, 2012 1:46 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Oct 11, 2008 9:07 pm
Posts: 416
Location: Germany, Berlin > member German forum
Hi xorc1zt,

i can't download your files. I think the downloadlink is down. Can you actualize the download link please?


Thanks Michael

_________________
Working on - MP3D Library -


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Fri Feb 24, 2012 5:14 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
sorry,

here the files : http://www.mediafire.com/?ms936a01nea7p6c

added pbglGetTimeDelta() which return fixed delta time


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Fri Feb 24, 2012 8:42 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Oct 11, 2008 9:07 pm
Posts: 416
Location: Germany, Berlin > member German forum
Hello xorc1zt ,

thx for your help. I write a Shader Tutorial for hlsl (DX9) Shader in the german forum now and think about a program to convert hlsl shader and glsl shader. Can you use these kind of glsl shader (see code plz) with you opengl addon too ? I think you need two files (vertex and frag shader ) but i dont understand the difference between your Shader and the glsl shader...

Greetings
Michael


Here the code:

Code:
// Chessboard Zoomer ;)

#ifdef GL_ES
precision mediump float;
#endif

uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;

void main( void ) {

   vec2 p = ( gl_FragCoord.xy / resolution.xy );

   float color = 0.0;
   
   vec2 t = p* 1.5/sin(time/8.);
   if( mod(t.x, 1.9) > 1. == mod(t.y, 1.9) > 1.0 )
      color = 1.;
   else
      color = 0.;
   
   gl_FragColor = vec4( color, 1.0, 1.0, 1.0 );

}

_________________
Working on - MP3D Library -


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Fri Feb 24, 2012 10:29 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
they are no difference because i simply use the opengl shader. my function is a helper which call the opengl functions to load, compile the shaders then link the shaders to the program.

actually opengl allow 3 type of shader per program (see http://en.wikipedia.org/wiki/Shader#Types_of_shaders)

GL_VERTEX_SHADER
GL_GEOMETRY_SHADER ( optional )
GL_FRAGMENT_SHADER ( also know as pixel shader )

my function is just doing this

1. create and load a vertex shader from file or from memory buffer
create and load a fragment shader from file or from memory buffer
2. create a program
3. link both shaders to the progam
4. delete both shaders
5. return the program id.

the shader you gave here is a framgent shader.

edit:

create a shader : glCreateShader
load source code to the shader : glShaderSource
compile the shader : glCompileShader

create a program : glCreateProgram
attach shader to the program : glAttachShader
link a program : glLinkProgram

delete a shader : glDeleteShader


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Sat Feb 25, 2012 10:37 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Oct 11, 2008 9:07 pm
Posts: 416
Location: Germany, Berlin > member German forum
Hi,

thanks for the news. I will test it with your programm and hope i will find a working solution...

Greetings Michael

_________________
Working on - MP3D Library -


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Sat Mar 02, 2013 9:53 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Apr 27, 2007 12:38 pm
Posts: 589
Location: Finland
By the way, the include file won't work in PB 5.1 because of native types appended to pointers. Easy to fix though...

xorc1zt, would you happen to have a working example of using vbo's with 3.3 core profile? (glGenBuffers, glBindBuffer, glDrawElements and so on). For some reason I can't get them to work, there are no errors (glGetError returns 0 for every line), but nothing is rendering.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Tue Mar 05, 2013 4:49 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Apr 27, 2007 12:38 pm
Posts: 589
Location: Finland
Hah, I made it work after spending two days trying. Turns out everything was ok, I just had a tiny mispelt variable in my shader. :oops:

OpenGL 3.3 is amazingly clean and easy.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Sat Jul 13, 2013 7:41 pm 
Offline
Addict
Addict

Joined: Sun Dec 12, 2010 12:36 am
Posts: 1617
Location: Somewhere in the midwest
Anyone have a download link for the latest, up to date and working version of this library?

I'm interested in trying it but all the download links seem dead.. I found what I assume is a much older version via his forum signature link, but it has tons of native types assigned to pointers, etc and I already broke it trying to delete those en masse :oops:

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenGL 3.3 Base (windows)
PostPosted: Tue Jun 10, 2014 11:11 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3693
Location: Italy
Anyone who got a copy of this lib, any version, even if not working anymore - I don't care, could make it available for a while ?

I thought I had downloaded it at the time but I cannot find it anymore.


EDIT: some kind soul sent it through PM, so I'm good now :wink:

Thanks.

_________________
[ My little PureBasic review ]


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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