wrap c++ objects with inheritance

2010-11-06 Thread Matthew Talbert
Can anyone point me to documentation or examples of how to wrap C++
objects with gobject and preserve inheritance? I want to do something
like this:

ClassA
ClassB (inherits from ClassA)

and wrap in gobject like this:

GClassA
GClassB

and I need to be able to cast GClassB back to GClassA. GClassA will
have as a private member a pointer to ClassA, and GClassB will have a
pointer to ClassB. What's the most elegant way to do this?

Thanks,
Matthew
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Strange display problem with gtk-win32 and VC++

2010-11-06 Thread John Emmas
For the past few years I've been migrating my Windows apps to GTK+ which I now 
tend to use in preference to Microsoft's MFC.  However, I've always been 
conscious of the fact that the official gnome binaries are (apparently) built 
using the 'C' runtime that equates to VC6.  VC6 has been obsolete for nearly a 
decade and is utterly useless for building modern-day apps.  As it happens, I'm 
building with VC8 but I'm worried about the potential problems of mixing VC6 
and VC8 runtimes in the same application.

Fortunately, the more recent releases of GTK+ come with Visual Studio projects 
supplied as part of the sources.  So I decided to try and build libgtk-win32 
and its dependencies, using VC8.

To test my build, I used a very simple Hello World app.  In fact it's the 
Hello World example from Andrew Krause's book 'Foundations of GTK+ 
Development'.  It launches a very simple window whose title is Hello World!.  
The window has a gtk label which is supposed to display the text Welcome to 
GTK+.

If I build the app and link it to the official gnome binaries, it works 
perfectly well.  However, if I rebuild those binaries (using the various Visual 
Studio projects supplied with gtk / glib etc) the app doesn't work.  The window 
and title display correctly but the label (which is supposed to say Welcome to 
GTK+) just displays a sequence of 15 squares.  The number of squares is always 
related to the label.  So if I shorten the label text to 10 characters, I get 
10 squares etc. I'm not sure if this mailing list supports file attachments but 
if there's a way to attach a file, I have a small screenshot available which 
illustrates the problem.

Anyway, has anyone here ever seen this kind of thing before?  Or can anyone 
suggest a particular place where I should start looking for the problem?

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problem with 64 bit gtk binaries in Win 7 (32 bit works fine)

2010-11-06 Thread Mario M
Hello,
 thanks for the info about the underscores : ), now I learned something
interesting.

I ended up downloading the source and MSYS and compiling GTK+ in my 64 bit
system. It was a long and tedious process :P getting all the dependencies,
setting up environment variables... also I had to install PERL because some
part of the compilation needed it, but...

In the end compiling it worked and my linker now recognized it and I didn't
have underscores problems anymore :)

However, I found that it didn't solve the vertex problem. I was so
frustrated that I ended up compiling WxWindows and trying to learn how to
use it (which has been a bit complicated because I don't have too much time
left for this project), but when I built the app using WxWindows, I had the
same problem!

Here is a more detailed description of this problem:
I have a class that stores values read from files in float arrays. I have
another class that uses the previous one, and this latter class is used in
the main file,  in the GTK+ functions.

 In my laptop with a 32 bit system, everything is cool. It works as
expected.
In my 64 bit machine (and another 64 bit machine), the array values are
messed up. If I initialize the arrays to some arbitrary number, that will be
the final value of the arrays when I call them. However, if I directly
called the first class from the main.cpp file without using the second
class, it works!

I built a test program that uses those classes the same way, without using
GTK+ (using GLUT for window creation), it works without a problem!

After discovering that WxWindows didn't solve the problem, I set up various
tests, and in the end found out the source of the problem. In the class that
reads from files, I was using cstdio functions (fscanf mainly). I found out
than when called from GTK+ with the intermediary class, the fscanf calls
would read the strings but not the floats, the values stored in the passed
variables would stay the same as before the call. (these values are vertex
positions)

I solved this issue changing all the csdtio calls to c++ calls ( from the
ifstream library e.g. ifstream fin(file); finfloatVar; ). With the c++
calls the values were adecuately read and stored. There is a side problem,
now the reading process is significantly slower and I have to wait several
seconds for the program to read the files.

I am utterly perplexed by this, any insight is welcome : )

Thanks again for your time, and thanks Jaroslay for answering my first
e-mail.

Mario Maqueo

2010/11/2 Jaroslav Šmíd jardas...@gmail.com

 Mingw64 defaults to no leading underscores (this is quite new
 feature), make sure GTK+ libraries are compiled by mingw64 version
 built after this was done. If you use newer mingw64 and older GTK+ or
 vice versa - trouble ahead :-)


 On Tue, Nov 2, 2010 at 9:03 AM, Mario M maqueo.ma...@gmail.com wrote:
  Hello, I have Windows 7 64 bits and I am working on a GTK+ project that
 uses
  OpenGL in C++. I am using GLADE and the normal version of GTK+ (not
 gtkmm).
 
  I was working on a laptop with Windows 7 32 bits and the program worked
  fine, but the video card in that laptop was really bad (Intel,
 integrated)
  so I switched to a desktop with 64 bit windows and a better video card
  (Nvidia GT 240).
 
  The code compiles fine in both versions of windows, using the 32 bit
 version
  of gtk. However, some horrible things have been happening:
 
  - The OpenGL window would not update correctly, taking a long time to do
 so,
  seemingly at random times.  I was using gtkglext for the OpenGL binding
 but
  I found out this problem was caused by gtkglext not being updated (since
  2006) and the problem is with Aero in Windows, If desktop compositing was
  disabled, it would work fine. I decided to ditch gtkglext and use OpenGL
  directly, after a while I managed to and this problem was fixed.
 
  - Some colors were messed up with lighting enabled, at first I thought
 this
  and the previous problem had to do with the video card, but this was
 weird
  because the same program without gtk would work fine. However I managed
 to
  correct it adding a few simple OpenGL instructions. I'm not sure why it
  worked fine without GTK+, but it seems to work fine now with my fix.
 
  - I have a library for loading 3d models, in my laptop it worked fine,
 but
  on the new computer (and another one where i tested it), the 3d models
  render as a single horizontal :S, all of them. They are drawn using
 openGL
  functions and storing the vertex positions in lists. I discovered this:
 When
  I load an object in the main.cpp file, and draw it, it works fine,
 however,
  when I load it in an external file, and draw it, it doesn't work ( I get
  just a horizontal line, and again, without gtk+ it works fine). This has
 me
  really perplexed, I think it might have something to do with the linker
 but
  I have no idea how. I added some debugging and I think the problem is in
 the
  vertex positions, I printed their x,y,z 

Re: Problem with 64 bit gtk binaries in Win 7 (32 bit works fine)

2010-11-06 Thread Mario M
Sorry for the typo, Jaroslav.

2010/11/6 Mario M maqueo.ma...@gmail.com

 Hello,
  thanks for the info about the underscores : ), now I learned something
 interesting.

 I ended up downloading the source and MSYS and compiling GTK+ in my 64 bit
 system. It was a long and tedious process :P getting all the dependencies,
 setting up environment variables... also I had to install PERL because some
 part of the compilation needed it, but...

 In the end compiling it worked and my linker now recognized it and I didn't
 have underscores problems anymore :)

 However, I found that it didn't solve the vertex problem. I was so
 frustrated that I ended up compiling WxWindows and trying to learn how to
 use it (which has been a bit complicated because I don't have too much time
 left for this project), but when I built the app using WxWindows, I had the
 same problem!

 Here is a more detailed description of this problem:
 I have a class that stores values read from files in float arrays. I have
 another class that uses the previous one, and this latter class is used in
 the main file,  in the GTK+ functions.

  In my laptop with a 32 bit system, everything is cool. It works as
 expected.
 In my 64 bit machine (and another 64 bit machine), the array values are
 messed up. If I initialize the arrays to some arbitrary number, that will be
 the final value of the arrays when I call them. However, if I directly
 called the first class from the main.cpp file without using the second
 class, it works!

 I built a test program that uses those classes the same way, without using
 GTK+ (using GLUT for window creation), it works without a problem!

 After discovering that WxWindows didn't solve the problem, I set up various
 tests, and in the end found out the source of the problem. In the class that
 reads from files, I was using cstdio functions (fscanf mainly). I found out
 than when called from GTK+ with the intermediary class, the fscanf calls
 would read the strings but not the floats, the values stored in the passed
 variables would stay the same as before the call. (these values are vertex
 positions)

 I solved this issue changing all the csdtio calls to c++ calls ( from the
 ifstream library e.g. ifstream fin(file); finfloatVar; ). With the c++
 calls the values were adecuately read and stored. There is a side problem,
 now the reading process is significantly slower and I have to wait several
 seconds for the program to read the files.

 I am utterly perplexed by this, any insight is welcome : )

 Thanks again for your time, and thanks Jaroslay for answering my first
 e-mail.

 Mario Maqueo

 2010/11/2 Jaroslav Šmíd jardas...@gmail.com

 Mingw64 defaults to no leading underscores (this is quite new
 feature), make sure GTK+ libraries are compiled by mingw64 version
 built after this was done. If you use newer mingw64 and older GTK+ or
 vice versa - trouble ahead :-)


 On Tue, Nov 2, 2010 at 9:03 AM, Mario M maqueo.ma...@gmail.com wrote:
  Hello, I have Windows 7 64 bits and I am working on a GTK+ project that
 uses
  OpenGL in C++. I am using GLADE and the normal version of GTK+ (not
 gtkmm).
 
  I was working on a laptop with Windows 7 32 bits and the program worked
  fine, but the video card in that laptop was really bad (Intel,
 integrated)
  so I switched to a desktop with 64 bit windows and a better video card
  (Nvidia GT 240).
 
  The code compiles fine in both versions of windows, using the 32 bit
 version
  of gtk. However, some horrible things have been happening:
 
  - The OpenGL window would not update correctly, taking a long time to do
 so,
  seemingly at random times.  I was using gtkglext for the OpenGL binding
 but
  I found out this problem was caused by gtkglext not being updated (since
  2006) and the problem is with Aero in Windows, If desktop compositing
 was
  disabled, it would work fine. I decided to ditch gtkglext and use OpenGL
  directly, after a while I managed to and this problem was fixed.
 
  - Some colors were messed up with lighting enabled, at first I thought
 this
  and the previous problem had to do with the video card, but this was
 weird
  because the same program without gtk would work fine. However I managed
 to
  correct it adding a few simple OpenGL instructions. I'm not sure why it
  worked fine without GTK+, but it seems to work fine now with my fix.
 
  - I have a library for loading 3d models, in my laptop it worked fine,
 but
  on the new computer (and another one where i tested it), the 3d models
  render as a single horizontal :S, all of them. They are drawn using
 openGL
  functions and storing the vertex positions in lists. I discovered this:
 When
  I load an object in the main.cpp file, and draw it, it works fine,
 however,
  when I load it in an external file, and draw it, it doesn't work ( I get
  just a horizontal line, and again, without gtk+ it works fine). This has
 me
  really perplexed, I think it might have something to do with the linker
 but
  I have 

Re: Strange display problem with gtk-win32 and VC++

2010-11-06 Thread Guy Rouillier

On 11/6/2010 1:03 PM, John Emmas wrote:


If I build the app and link it to the official gnome binaries, it
works perfectly well.  However, if I rebuild those binaries (using
the various Visual Studio projects supplied with gtk / glib etc) the
app doesn't work.  The window and title display correctly but the
label (which is supposed to say Welcome to GTK+) just displays a
sequence of 15 squares.  The number of squares is always related to
the label.  So if I shorten the label text to 10 characters, I get 10
squares etc. I'm not sure if this mailing list supports file
attachments but if there's a way to attach a file, I have a small
screenshot available which illustrates the problem.


If it works with the official GTK binaries (which is what I assume you 
meant when you said gnome binaries), I would just stick with those. 
You don't want to be in the business of supplying GTK binaries.  That's 
a difficult, time-consuming task; just look at all the conversations 
about the Windows GTK libraries involving Tor - no one ever wants to 
volunteer to help.


Since the number of squares equals the number of characters in the label 
you are trying to display, the problem appears to be one of font 
rendering.  Other than that meager observation, I can't really help.


--
Guy Rouillier
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list