Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
translating win32API C tutorial to fB ::New question::
#21
Quote:Hi
<snip>

With that said, I can't seem to make the FB compiler understand the following wgl statements from msdn:

hRC = wglCreateContext hDC

wglMakeCurrent hDC, hRC

wglMakeCurrent NULL, NULL

wglDeleteContext hRC

The compiler does'nt seem to understand them and it says "variables not declared " when it encounters them.


I need to create a Rendering context with the Device context and then make them current.

Also, on exit , I need to null them both as well as delete the Rendering context.


I'm trying to see a way of setting updirectly OpenGL thru the Win32 API. But, the above and maybe just a couple of other things are getting in the way.

<snip>
Glu

Hi:

I translated one of NeHe’s OpenGL tutorials (Lesson29) to FreeBASIC. It does OpenGL through the Win32 API so it answers your questions above. I found a bug in the DEVMODE definition, and I needed to add 4 new function definitions. I will post the details in a separate thread where they will be more noticeable.

Other than this, all was plain sailing.

The glaux library is not distributed with FreeBASIC, but as far as I know, this is not much used except for loading bitmaps. I am sure you could find it on the internet if you need it, or just use raw format files like lesson29. I will see if I can make a replacement function for loading bitmaps. Or perhaps there are already some available?

I put NeHe’s Lesson29 on my website in case you want to have a look at it. You will find it on this page.

http://www.freewebs.com/weekendcode/windows.htm


Have fun

Garvan
Reply
#22
Nice work, but I don't understand why you're using the win32 API... Apart from being a good coding exercise, it makes the code not portable.
SDL or the built-in gfxlib (whose OpenGL driver was based on the NeHe basecode btw) are a better choice IMHO... See the FB examples/gfx/fbgfx_opengl.bas example, it's NeHe lesson 4 ported to gfxlib; as you can see it can't be made easier to set up an OpenGL mode.
ngelo Mottola - EC++
Reply
#23
Quote:Nice work, but I don't understand why you're using the win32 API... Apart from being a good coding exercise, it makes the code not portable.
SDL or the built-in gfxlib (whose OpenGL driver was based on the NeHe basecode btw) are a better choice IMHO... See the FB examples/gfx/fbgfx_opengl.bas example, it's NeHe lesson 4 ported to gfxlib; as you can see it can't be made easier to set up an OpenGL mode.

Hi:

In this case it was a programming exercise.

I like the gfxlib because it works on my computer without having to set anything up, but I need to learn more about it. So far I have just compiled the samples, and read the help file.

SDL is not so interesting to me because I don’t like the need to distribute and set up dlls with small utilities.

I honestly don’t know much about the other graphic technologies. A little DirectX, and that is it. I have a lot to learn.

Garvan
Reply
#24
Garvan




Quote:I translated one of NeHe’s OpenGL tutorials (Lesson29) to FreeBASIC. It does OpenGL through the Win32 API so it answers your questions above. I found a bug in the DEVMODE definition, and I needed to add 4 new function definitions. I will post the details in a separate thread where they will be more noticeable.


Okay, good work!..

I need to take a look at the code. I just quickly executed the EXE. On exit and in fullscreen mode it does´nt seem to re-establish the previous screen resolution. I'm not sure if that is a bug in devmode or in the change display serttings function.


Like I said, I need to take a look at the code when I get a chance.


Again, Good work and Good going.


Glu
Reply
#25
Hi:

I retested and it works correctly here using WinXP Home on a Toshiba laptop. Did you recompile the exe? We might have different versions of FreeBASIC.

The code uses two different methods to change display settings, if the first fails, it tries the second, so I could easily have missed a bug during testing. Or perhaps both methods fail on your machine? Have you tried using the F1 key to toggle full screen and windowed mode? As a check you could download a version compiled in C from NeHe’s site and test that exe.

Any help would be appreciated.

Thanks

Garvan
Reply
#26
Hi again


Okay. I retested your new version on another machine and it seems to return the previous resolution when exiting in fullscreen mode.


However, when pressing the F1 key, when in fullscreen mode, instead of changing back to windowed mode, will end up cutting the app. But, when in windowed mode, it will change to fullscreen mode.

Just a minor detail, really.


The gfx full screen option produces an illegal error on this machine. Go figure.


Thnx and again, good work.






Glu
Reply
#27
This is kind of late, but okay...

About the CreateWindow thing...

The original Win32 API used CreateWindow to create windows, and it was actually a real function. It took a WNDCLASS for a parameter instead of a WNDCLASSEX. So, CreateWindowEx takes a WNDCLASSEX. Any Win32 thing (or DX function, or any MS function for that matter) with an EX on the end of it is an updated version of the original. (WNDCLASSEX has one more structure element than WNDCLASS, and CreateWindowEx has one more parameter).
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)