Author Topic: opengl without libs  (Read 8608 times)

0 Members and 1 Guest are viewing this topic.

kryton9

  • Guest
opengl without libs
« on: March 22, 2011, 07:53:24 PM »
Charles as you know in C, you need to include the gl.h and also link to libopengl32.a. I don't understand how you are using opengl without linking to the lib files as you do in C?

Charles Pegge

  • Guest
Re: opengl without libs
« Reply #1 on: March 22, 2011, 09:50:37 PM »
Hi Kent,

There is a set of Opengl headers in inc/glo2/gl. These are original MS & Khronos c headers. I only provide a couple of dummy H files in inc/glo2 to make it useable for Oxygen.

Oh - and I borrowed Petr's thinBasic WGL.inc :)

Charles

kryton9

  • Guest
Re: opengl without libs
« Reply #2 on: March 23, 2011, 04:51:28 PM »
So we don't need to lib files? Just c header files and the dynamic dll Charles?

Charles Pegge

  • Guest
Re: opengl without libs
« Reply #3 on: March 23, 2011, 10:50:18 PM »

No Kent. Oxygen does not use libs. Only the headers are needed with an indication of which DLL are being referred to and a few typedefs where necessary.

This is how Opengl headers are utilised in PortViwer1. (I've tidied it a little :) )

Code: [Select]
  'OPENGL HEADERS
  '==============

  #define WINGDIAPI
  #define APIENTRY
  #define const
  typedef word wchar_t
  typedef sys ptrdiff_t
  '
  includepath "..\..\inc\glo2\"
  library "opengl32.dll"
    include once "gl\gl.h"
    'include once "gl\glext.h"
  library "glu32.dll"
    include once "gl\glu.h"
  library ""
  '
  include once "gl\thinbasic_wgl.inc"
 

Charles

kryton9

  • Guest
Re: opengl without libs
« Reply #4 on: March 23, 2011, 11:06:21 PM »
Thanks Charles, I will try to get SDL working if I can using your example here.

Charles Pegge

  • Guest
Re: opengl without libs
« Reply #5 on: March 24, 2011, 01:43:47 AM »
I have not studied SDL headers. Often C headers have symbols with the same characters but different case - OpenCL for example. For these vexing situations, it becomes necessary to make Oxygen at least partially case sensitive. Usually the style is to put all equates into upper case and everything else in mixed case.

To make Oxygen sensitive to all-capitalised SYMBOLS and distinguish them from others use:

#case capital

other options:
#case sensitive
#case insensitive
(default)

Charles

kryton9

  • Guest
Re: opengl without libs
« Reply #6 on: March 24, 2011, 10:51:07 AM »
Thanks Charles, those tips are very important. I hope to start tonight when I get home. When I run into a problem I can't resolve after a few hours I will be posting for help :)

kryton9

  • Guest
Re: opengl without libs
« Reply #7 on: March 27, 2011, 08:06:53 PM »
I just don't understand this stuff. I have to give up on the conversion Charles, sorry about that.

Charles Pegge

  • Guest
Re: opengl without libs
« Reply #8 on: March 28, 2011, 03:42:29 AM »
Hi Kent,

C headers are not a bundle of joy, nor is raw Opengl for that matter. The best I can offer is examples to play with. I always start with a working example and then gradually morph it into something new, hopefully creating a few useful abstractions in the process.

The GDIplus "WinImage" image example is a case in point. I adapted it from one of José's Multimedia examples which in turn came from an MS C++ example.

Charles

PS: Which SDL were you looking at Kent?
« Last Edit: March 28, 2011, 04:10:06 AM by Charles Pegge »

kryton9

  • Guest
Re: opengl without libs
« Reply #9 on: March 28, 2011, 10:48:48 AM »
Actually now I found out that SFML also has c header versions and it is nicer than SDL. SFML (Simple Fast Multimedia Library) is in C++, and that is how I used it before. But I noticed the C version when I was looking at the Ruby and Python versions.

SFML c++ version also provides both dynamic and static versions in the download. So it is a really nice library. I have not played with the C version yet.
http://www.sfml-dev.org/download.php

...Just downloaded C version, it too has static and dynamic libraries. Here is an example of the c code using it. As you can see really well done and easy.

Code: [Select]
#include <SFML/Audio.h>
 #include <SFML/Graphics.h>
 
 int main()
 {
     sfWindowSettings Settings = {24, 8, 0};
     sfVideoMode Mode = {800, 600, 32};
     sfRenderWindow* App;
     sfImage* Image;
     sfSprite* Sprite;
     sfFont* Font;
     sfString* Text;
     sfMusic* Music;
     sfEvent Event;

     /* Create the main window */
     App = sfRenderWindow_Create(Mode, "SFML window", sfResize | sfClose, Settings);
     if (!App)
         return EXIT_FAILURE;

     /* Load a sprite to display */
     Image = sfImage_CreateFromFile("cute_image.jpg");
     if (!Image)
         return EXIT_FAILURE;
     Sprite = sfSprite_Create();
     sfSprite_SetImage(Sprite, Image);
 
     /* Create a graphical string to display */
     Font = sfFont_CreateFromFile("arial.ttf", 50, NULL);
     if (!Font)
         return EXIT_FAILURE;
     Text = sfString_Create();
     sfString_SetText(Text, "Hello SFML");
     sfString_SetFont(Text, Font);
     sfString_SetSize(Text, 50);
 
     /* Load a music to play */
     Music = sfMusic_CreateFromFile("nice_music.ogg");
     if (!Music)
         return EXIT_FAILURE;

     /* Play the music */
     sfMusic_Play(Music);
 
     /* Start the game loop */
     while (sfRenderWindow_IsOpened(App))
     {
         /* Process events */
         while (sfRenderWindow_GetEvent(App, &Event))
         {
             /* Close window : exit */
             if (Event.Type == sfEvtClosed)
                 sfRenderWindow_Close(App);
         }
 
         /* Clear the screen */
         sfRenderWindow_Clear(App, sfBlack);
 
         /* Draw the sprite */
         sfRenderWindow_DrawSprite(App, Sprite);
 
         /* Draw the string */
         sfRenderWindow_DrawString(App, Text);
 
         /* Update the window */
         sfRenderWindow_Display(App);
     }
 
     /* Cleanup resources */
     sfMusic_Destroy(Music);
     sfString_Destroy(Text);
     sfFont_Destroy(Font);
     sfSprite_Destroy(Sprite);
     sfImage_Destroy(Image);
     sfRenderWindow_Destroy(App);
 
     return EXIT_SUCCESS;
 }
« Last Edit: March 28, 2011, 10:52:56 AM by kryton9 »

Charles Pegge

  • Guest
Re: opengl without libs
« Reply #10 on: March 29, 2011, 01:32:48 AM »

Hi Kent,

Big download! (27Meg) but that includes all kinds of binary stuff.
At first glance the headers look nice and clean.

I don't think we would have any difficulty in using SFML or SDL for that matter.

Charles

kryton9

  • Guest
Re: opengl without libs
« Reply #11 on: March 29, 2011, 05:12:29 AM »
I think what happened is that Oxygen Alpha is so powerful and usable, but for guys like you who know things inside and out.

I studied the code you have in the headers and elsewhere and I can see that you were also using that code for testing purposes on syntax, clever idea, but it makes it very hard to study for the uninitiated. I am not complaining, just observing. It makes me appreciate all that has to be handled and how you even got it to come together.

jcfuller

  • Guest
Re: opengl without libs
« Reply #12 on: March 29, 2011, 05:45:10 AM »
I think what happened is that Oxygen Alpha is so powerful and usable, but for guys like you who know things inside and out.
I agree Kent.
With my memory worse than ever and 10 different ways to do the same thing I'm afraid I'll have to wait until a Beta with advanced documentation before I can get involved again.

James

Charles Pegge

  • Guest
Re: opengl without libs
« Reply #13 on: March 29, 2011, 12:02:13 PM »

It's mostly qbasic syntax with additional flexibility. I find the greatest burden is wading through endless libraries - system graphics audio, kernel. This is the most serious challenge to one's long suffering brain cells.

This is why I think a rich variety of working examples are more useful and instructive than the reference material. Biology works this way - mutations -> evolution!

Charles

kryton9

  • Guest
Re: opengl without libs
« Reply #14 on: March 30, 2011, 03:23:50 PM »
I think I will try to take your approach Charles and try to develop my game/experimental engine using the winapi and opengl instead of third party libraries.