DGL
https://delphigl.com/forum/

glBindBuffer on Mac
https://delphigl.com/forum/viewtopic.php?f=19&t=10000
Seite 1 von 1

Autor:  pyiap [ Mo Jul 25, 2011 23:23 ]
Betreff des Beitrags:  glBindBuffer on Mac

I'm working on a game which will run on both OS X and Windows. But for some a few core functions like glBindBuffer come up as nil after I run ReadExtensions().
It runs correctly on the windows environment but crashes on OS X 10.6.8 running OpenGL 2.1.
For my game I'm using SDL to create my window and then I call I call InitOpenGL() and then ReadExtentions()
I'm able to get most of the core functions to work and the game to run and render. But there's only a few functions like glBindBuffer and glGenFramebuffersEXT that return nil.

Autor:  phlegmatiker [ Di Jul 26, 2011 06:43 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

try these variants:

glBindBufferARB
glGenFramebuffersARB

Autor:  Coolcat [ Di Jul 26, 2011 08:39 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

Did you include the correct headers? You need to use the "OpenGL-Framework", not the normal OpenGL-Headers.

I'm not using SDL, but Qt instead:
Code:
  1. #include <QtGlobal>
  2.  
  3. #if defined(Q_OS_MAC)
  4.     #include <OpenGL/gl.h>
  5.     #include <OpenGL/glu.h>
  6. #else
  7.     #include <GL/glew.h>
  8.     #include <GL/gl.h>
  9. #endif


However, I have the problem that glBufferSubData does not always work correctly for me. But there is a workaround:
Code:
  1. #if defined(Q_OS_MAC)
  2.     GLubyte* buffer = (GLubyte*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
  3.     memcpy(buffer, m_vertexData, sizeInBytes);
  4.     glUnmapBuffer(GL_ARRAY_BUFFER);
  5. #else          
  6.     glBufferSubData(GL_ARRAY_BUFFER, 0, sizeInBytes, m_vertexData);
  7. #endif

Autor:  pyiap [ Di Jul 26, 2011 17:51 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

Thanks for your replies.

@phlegmatiker - I've tried glBindBufferARB and glGenFramebuffers and both come up as nil as well. I'm using the latest version of dglOpenGL.pas and FPC to compile my project. I didn't find glGenFramebuffersARB defined in the dglOpenGL file.

@CoolCat- Since I'm using dglOpenGL I assumed I got the following header files glext.h, gl_1_1.h, glu.h and weglext.h. Thanks for suggesting the work around for glBufferSubData I'm going to see if there's a work around for what I'm trying to do.

If anyone has any other suggestions I will gladly try them since I've been beating my head against the wall on this problem for quite some time.

Autor:  pyiap [ Mi Jul 27, 2011 18:01 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

After looking deeper, it seems that none of the dglOpenGL functions seem to return anything after dglGetProcAddress is called. Since I'm compiling it using FPC, I get a the GL unit which I believe are the OpenGL function pointers I'm using instead of dglOpenGL function pointers. I'm still trying to figure out what the problem is but here is my compile string

fpc -gl -ve -al -WC -Fucomponents/sdl -Fucomponents/wrp -Fucomponents/jcl -dMACOS -Mdelphi -k-macosx_version_min -k10.5 -k-L/sw/lib -k-lSDL -k-lSDL_Image -k-lSDL_Mixer -k-lsmpeg -k-lSDL_TTF -k-lavcodec -k-lavformat -k-lavutil -k-lswscale -k-llua.5.1.4 -k-framework -kCocoa -k-framework -kCarbon -k-framework -kOpenGL -k-read_only_relocs -kwarning -XMSDL_main -XS MyGame.dpr

Autor:  pyiap [ Mi Jul 27, 2011 21:16 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

Well i found my problem. I needed to modify the dglGetProcAddress to use wglGetProcAddress on the mac when using FPC.

Autor:  Aya [ Do Jul 28, 2011 05:14 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

are you sure wgl* is the correct thing to use on a mac??

Autor:  pyiap [ Do Jul 28, 2011 17:56 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

For my specific situation it seems to be. I had to compile OpenGL into my project so I am able to use the gl unit, which has the wgl* function defined. For some reason the way dglOpenGL was getting the proc address was always returning a nil value for even simple functions like glGetString().

Autor:  Coolcat [ Fr Jul 29, 2011 14:33 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

The 'w' in 'wgl' stands for Windows. Are you sure this works on Mac?

Autor:  pyiap [ Fr Jul 29, 2011 18:12 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

Oddly enough it did work for me. I had to add to the top of dglProcAddress with
{$IFDEF MACOS}
Result := wglGetProcAddress(ProcName);
exit;
{$ENDIF}
As well as add the gl, glu, and glext units to the uses case.

If I didn't add them then all of the dgl function pointers always returned nil for me.

I'm thinking this works for me because I'm compiling OpenGL with FPC. I'm not sure why it doesn't work using the traditional dlsym function call.

Autor:  Stucuk [ Mo Aug 01, 2011 14:18 ]
Betreff des Beitrags:  Re: glBindBuffer on Mac

If your project has another OpenGL Unit in it then it may use that instead of dglOpenGL. Which could explain why dglOpenGL has Nil's for everything.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/