Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mär 28, 2024 14:12

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 11 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: glBindBuffer on Mac
BeitragVerfasst: Mo Jul 25, 2011 23:23 
Offline
DGL Member

Registriert: Mo Jul 25, 2011 22:24
Beiträge: 6
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.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Di Jul 26, 2011 06:43 
Offline
DGL Member
Benutzeravatar

Registriert: So Sep 26, 2010 12:54
Beiträge: 238
Wohnort: wieder in Berlin
Programmiersprache: Englisch
try these variants:

glBindBufferARB
glGenFramebuffersARB


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Di Jul 26, 2011 08:39 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
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

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Di Jul 26, 2011 17:51 
Offline
DGL Member

Registriert: Mo Jul 25, 2011 22:24
Beiträge: 6
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.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Mi Jul 27, 2011 18:01 
Offline
DGL Member

Registriert: Mo Jul 25, 2011 22:24
Beiträge: 6
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


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Mi Jul 27, 2011 21:16 
Offline
DGL Member

Registriert: Mo Jul 25, 2011 22:24
Beiträge: 6
Well i found my problem. I needed to modify the dglGetProcAddress to use wglGetProcAddress on the mac when using FPC.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Do Jul 28, 2011 05:14 
Offline
DGL Member
Benutzeravatar

Registriert: Di Dez 03, 2002 22:12
Beiträge: 2105
Wohnort: Vancouver, Canada
Programmiersprache: C++, Python
are you sure wgl* is the correct thing to use on a mac??


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Do Jul 28, 2011 17:56 
Offline
DGL Member

Registriert: Mo Jul 25, 2011 22:24
Beiträge: 6
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().


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Fr Jul 29, 2011 14:33 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
The 'w' in 'wgl' stands for Windows. Are you sure this works on Mac?

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Fr Jul 29, 2011 18:12 
Offline
DGL Member

Registriert: Mo Jul 25, 2011 22:24
Beiträge: 6
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.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glBindBuffer on Mac
BeitragVerfasst: Mo Aug 01, 2011 14:18 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
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.

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 11 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 9 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.050s | 17 Queries | GZIP : On ]