1,075,509 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by tomtetlaw

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

My Ubuntu version is 12.04.

I'm simply trying to include GL/glu.h in my program, but I get the error:
fatal error: GL/glu.h: No such file or directory

I include it like this:
#include <GL/glu.h>

I have libgl1-mesa-glx-dbg, libgl1-mesa-dev, mesa-common-dev all installed.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

Don't worry I don't think it's possible anyway. Thanks for your help

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

I am using polymorphism yes, I can write the code like this:

class Interface { public: virtual void Foo( void ) = 0; }
class Derived : public Interface { void Foo( void ) { printf( "Foo!\n" ); }

But because I'm lazy, I want to create a number of macros so that I only have to write this code:

BeginInterface( Interface )
    void Foo( void );
EndInterface( Interface, Derived )

And the macros will generate code like in the first sample.
Then I can just write:

void Derived::Foo( void )
{
    printf( "Foo!\n" );
}

After I thought of this idea for a while I was pretty convinced that it was impossible but I though I'd try here to see if anyone has seen or implemented something like this before.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

Sorry, I'm not very good at describing problems.

Yeah I want to use OOP interfaces.

It has nothing to do with code reuse for different projects or anything. I just want to write one class definition and have the macros generate both the interface for that class and the class that implements it.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

Q1. I don't fully understand this question. What classes?
Q2. That part isn't a question.
Q3. I'm trying to write macros that create the definition of the interface class and the definition of the implementation class with me only having to write one.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

I appolagise for the slightly ambiguous title, I didn't know what to call it.

I want to create a way to define interfaces without having to also write the class declaration that implements it.
I have the class members, and the interface defined, but I am not sure how (if possible) to make it generate the implentation class declaration as well.

For anyone who doesn't know __interface makes all the functions within it automatically public and pure virtual.

Idealy this is how I would like to write the interfaces:

BeginMembers( ITest )
    int m_nTest;
EndMembers( ITest )

BeginInterface( ITest, CTest ) // not sure if these will be the actuall paramaters
    void TestFunc( void );
EndInterface( ITest, CTest )

void CTest::TestFunc( void )
{
    printf( "%d\n", m_nTest );
}

Which would generate code like this:

class ITest_members
{
    protected:
        int m_nTest;
};

__interface ITest // I'm aware that this is not portable.
{
    public:
        void TestFunc( void );
};

class CTest : public ITest_members, public ITest
{
    public:
        void TestFunc( void );
};

Right now this is the code I have:

#define BeginMembers( iName ) class iName##_members { protected:
#define EndMembers( iName ) };

#define BeginInterface( iName ) __interface iName##_interface {
#define EndInterface( iName ) \
class iName : public iName##_interface, public iName##_members \
{ \
public: \
    ~iName( void ) { } \
};

I'm stuck on how to get it to generate the CTest class declaration, any ideas would be greatly appreciated.
The reason that I'm doing this is that I'm lazy and don't want to have to write the CTest class that is exactly the same as the interface class.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

What I don't understand is why i is not being set to 0 when it first gets to the for loop.
I'll look around for things that could be overwriting memory.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

max in the actual code is 12. and even if i is a value different to 0 before this loop, it always gets changed to max
btw it gets changed to max before the first line of code of the first run of the loop

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

I'm using VC++ 2010 with Windows 7 x64. I'm compiling all my code as C code.

I have a for loop like this:

for (i = 0; i < max; i++)
{
    ...
}

But when I run it, i is being set to max

If I set i to 0 in the first line of the for loop, it does change to 0, but at the end of the for loop, it does not go back up and check the condition, it just exits out of the loop.

Setting i to 0 before the start of the for loop does not change this, neither does using an entirely different counter variable.

Here is the actual code being used:

indices = malloc (sizeof(short) * data.face_count * 3);
for (i = 0; i < data.face_count; i += 3);
{
    indices[i]     = data.face_list[i]->vertex_index[0];
    indices[i + 1] = data.face_list[i]->vertex_index[1];
    indices[i + 2] = data.face_list[i]->vertex_index[2];
}

EDIT: Changing it to a while loop makes it function normally, so it's something to do with that paticular for loop (all others work correctly).

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

How do I make the coordinate system in DirectX 11 relative to the top left of the screen? I've setup an orthographic projection matrix, so that I can use screen coordinates but it makes more sense to me to have a top left origin, since I come from working with OpenGl.

I setup my projection matrix like this:
ww = the width of the window
and wh = the height of the window

projection = XMMatrixIdentity ();
projection = XMMatrixOrthographicLH (ww, wh, -1, 1);
tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

Yeah their doccos are strange sometimes.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

It ended up being me forgetting to resize my OpenGL viewport when the window was resized.. doh!
Thanks for your help! :)

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

I think what you're refering to GetSystemMetrics, I'll give it a try

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

Ok, I figured out that around the center of the screen on the y axis, the y coordinate is 20 pixels down from where it should be, and the x coordinate seems fine

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

I wouldn't know what to send you because 1. it's quite a large code base, and 2. i'm not doing any scaling anywhere, this is the only part that i access these co-ordinates, i don't change them anywhere.
I've also stepped through each line of code from where I get the coordinates to where I use them and they are the same the whole way through.

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

When I handle WM_MOUSEMOVE in my window prodedure, HIWORD(lParam) and LOWORD(lParam) are both a little off. It's returning a point that is slightly to the left and slightly above where my cursor actually is...
What's really weird is that as I move the cursor closer to the top left of the client area of the window, the amout that the position I'm given differs from the actual cursor position gets smaller...

At first I thought it was because it was in screen coordinates and I needed to call ScreenToClient to convert it to client space coordinates, but this was not the case.

This is how I handle it, I don't change the coords it gives me anywhere.

case WM_MOUSEMOVE:
    input->HandleInput (LOWORD(lParam), HIWORD(lParam));
    break;
tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

If it matters, I'm using Windows 7 x64 and compiling with VC++ 2010. I have called AVIFileInit before this

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

First of all I learnt how to do this from http://nehe.gamedev.net/tutorial/playing_avi_files_in_opengl/23001/

AVIStreamGetFrameOpen is always returning NULL. I checked to see if I could open the AVI file in windows media player and that worked, so that means it can't be a codec problem, right? I'm not too sure. All the variables have valid values before the call to AVIStreamGetFrameOpen

Here's my code:

if (AVIStreamOpenFromFile(&avi, file, streamtypeVIDEO, 0, OF_READ, NULL) != 0)
    return;

AVIStreamInfo (avi, &info, sizeof(info));
w = info.rcFrame.right - info.rcFrame.left;
h = info.rcFrame.bottom - info.rcFrame.top;
lastframe = AVIStreamLength (avi);
mpf = AVIStreamSampleToTime (avi, lastframe) / lastframe;

header.biSize = sizeof (BITMAPINFOHEADER);                  
header.biPlanes = 1;                                        
header.biBitCount = 24;                                     
header.biWidth = w;                                     
header.biHeight = h;                                        
header.biCompression = BI_RGB;                              

bitmap = CreateDIBSection (hdc, (BITMAPINFO*)(&header), DIB_RGB_COLORS, (void**)(&data), NULL, NULL);
SelectObject (hdc, bitmap);

pgf = AVIStreamGetFrameOpen (avi, NULL);
if (!pgf)
    return;
tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0

Thanks for your reply, this is really helpful. I always love writing my own libraries instead of using others :p (not sarcastic)

tomtetlaw
Practically a Master Poster
615 posts since Sep 2008
Reputation Points: 9
Solved Threads: 5
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.1280 seconds using 2.62MB