GLBasic forum

Other languages => GLBasic - de => Topic started by: WPShadow on 2008-Feb-29

Title: gl.gbas
Post by: WPShadow on 2008-Feb-29
Hi!

Ich wollte mal nachfragen, ob es zur "gl.gbas" und zu den OpenGL - Befehlen irgendwo ein eher einfaches Tutorial oder so gibt?

Ich habe nachgesehen und das Red Book ist irgendwie etwas komplex und etwas unleserlich für jemanden, der irgendwie so wenig Plan hat, wie ich... =/

Gruß

W.

PS.: Ich erweitere meine Frage um diesen Link:

http://www.amazon.de/OpenGL-Shading-Language-Randi-Rost/dp/0321334892/ref=pd_sim_?ie=UTF8&qid=1204275268&sr=8-1

Was haltet ihr davon? Empfehlenswert für Einsteiger?
Title: gl.gbas
Post by: Kitty Hello on 2008-Feb-29
Das Orange Book ist super. Wenn Du Red+Blue hast+kapiert hast. Das ist die Basis.
http://nehe.gamedev.net Ist _die_ Anlaufstelle für OpenGL.
Title: gl.gbas
Post by: WPShadow on 2008-Feb-29
Also empfiehlst du mir das Red Book für den Anfang?

Ich war schon einige Male kurz davor es mir zu kaufen, aber irgendwie konnte ich mich nicht dazu durch ringen. Sag einfach ja/nein und ich werde deine Antwort in meine Entscheidung einfließen lassen...
Title: gl.gbas
Post by: bigsofty on 2008-Feb-29
GLBasic example:

Code (glbasic) Select
WHILE TRUE

X_MAKE3D 1,1000,45 // Viewport 3D

    glClear(GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT)    // Clear Screen And Depth Buffer
    glLoadIdentity()                                    // Reset The Current Modelview Matrix
    glTranslatef(-1.5,0.0,-6.0)                        // Move Left 1.5 Units And Into The Screen 6.0
    glBegin(GL_TRIANGLES)                                // Drawing Using Triangles
        glColor3f(1.0,0.0,0.0)                        // Set The Color To Red
        glVertex3f( 0.0, 1.0, 0.0)                    // Top
        glColor3f(0.0,1.0,0.0)                        // Set The Color To Green
        glVertex3f(-1.0,-1.0, 0.0)                    // Bottom Left
        glColor3f(0.0,0.0,1.0)                        // Set The Color To Blue
        glVertex3f( 1.0,-1.0, 0.0)                    // Bottom Right
    glEnd()                                            // Finished Drawing The Triangle
    glTranslatef(3.0,0.0,0.0)                        // Move Right 3 Units
    glColor3f(0.5,0.5,1.0)                            // Set The Color To Blue One Time Only
    glBegin(GL_QUADS)                                    // Draw A Quad
        glVertex3f(-1.0, 1.0, 0.0)                    // Top Left
        glVertex3f( 1.0, 1.0, 0.0)                    // Top Right
        glVertex3f( 1.0,-1.0, 0.0)                    // Bottom Right
        glVertex3f(-1.0,-1.0, 0.0)                    // Bottom Left
    glEnd()                                            // Done Drawing The Quad

 SHOWSCREEN
WEND
This is a translation of one of the early Nehe demos (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=03) into GLBasic using gl.gbas. I do believe their is a full German translation of the tutorial text as well as the code also.

May I say, this is a great way of learning OpenGL.
Title: gl.gbas
Post by: WPShadow on 2008-Feb-29
Sounds great!

Is there any way to use the gl* - Code with 3D - models (*.ddd)???
And something with textures?

I've found texture mapping, but X_SETTEXTURE seems to be the same! How about this effects:

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08

Is something like that easy to make???
Title: gl.gbas
Post by: Schranz0r on 2008-Feb-29
Ne da ist Glaux dabei, das musste wenn dann mit einbinden...
Viel spass    ;)
Title: gl.gbas
Post by: WPShadow on 2008-Feb-29
Glaux??? <-- Erkläre dich...
Title: gl.gbas
Post by: Schranz0r on 2008-Feb-29
Erklärung:

Glaux ist...(siehe Google) ;)
Title: gl.gbas
Post by: WPShadow on 2008-Feb-29
#include                        // Header File For The GLaux Library

Tja, sagt mir jetzt aber auch noch nicht wirklich viel...

Bekomme ich jetzt etwas mehr Infos???
Title: gl.gbas
Post by: WPShadow on 2008-Mar-01
Und noch eine kleine Frage:

Ich bin bei Rendermonkey (v 1.8) auf diverse bereits fertige Shader gestoßen! Kann man die so einfach mit übernehmen?

Code (glbasic) Select
uniform float distortion_amount2;
uniform float distortion_amount1;
uniform float distortion_amount0;
uniform vec4 height_attenuation;
uniform sampler2D fire_distortion;
uniform sampler2D fire_opacity;
uniform sampler2D fire_base;

varying vec2  vTexCoord0;
varying vec2  vTexCoord1;
varying vec2  vTexCoord2;
varying vec2  vTexCoord3;

// Bias and double a value to take it from 0..1 range to -1..1 range
vec4 bx2v(vec4 x)
{
   vec4 retVal =x;
   retVal = (2.0 * x) - 1.0;
   return retVal;
}
vec4 bx2(float x)
{
   float retVal;
   retVal = 2.0 * x - 1.0;
   return vec4(retVal,retVal,retVal,retVal);
}

void main(void)
{
   // Sample noise map three times with different texture coordinates
   vec4 noise0;
   vec4 noise1;
   vec4 noise2;

   noise0 = texture2D(fire_distortion, vTexCoord1);
   noise1 = texture2D(fire_distortion, vTexCoord2);
   noise2 = texture2D(fire_distortion, vTexCoord3);

   // Weighted sum of signed noise
   vec4 noiseSum = bx2v(noise0) * distortion_amount0 +
                   bx2v(noise1) * distortion_amount1 +
                   bx2v(noise2) * distortion_amount2;

   // Perturb base coordinates in direction of noiseSum as function of height (y)
   vec2 perturbedBaseCoords = vTexCoord0 + noiseSum.xy * ( (vTexCoord0.y) * height_attenuation.x + height_attenuation.y);

   
   // Sample base and opacity maps with perturbed coordinates
   vec4 base    = texture2D(fire_base,    perturbedBaseCoords);
   vec4 opacity = texture2D(fire_opacity, perturbedBaseCoords);

   gl_FragColor =  base * opacity;
}
Title: gl.gbas
Post by: bigsofty on 2008-Mar-01
Quote from: WPShadowSounds great!

Is there any way to use the gl* - Code with 3D - models (*.ddd)???
And something with textures?

I've found texture mapping, but X_SETTEXTURE seems to be the same! How about this effects:

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08

Is something like that easy to make???
The .BMP should be read by GLB (I think that "LOADSPRITE" is simpler) and the handle can be retrieved with a little C code, I'm pretty sure Gernots already  provided an example of retrieving a texture handle from GLBasic already. (Once you have the handle you can easily apply the texture to polygons in your openGL program)

I don't see why GLBasic model display routines should not work fine in the middle of all this to use .ddd's?

All the camera, screen set up, input etc... is handled by GLB, so this shortens the code by quite a bit. ;)

Not got a lot of time unfortunately, got a new baby in the house, so I'll bang nehe8 together if I can fight off the clucking Grandparents for a minute... :P
Title: gl.gbas
Post by: bigsofty on 2008-Mar-01
"glTexImage2D" is missing from "gl.gbas", Gernot needs to add this I'm afraid.

Something like...

Code (glbasic) Select
void __stdcall glTexImage2D(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, const void*);
Title: gl.gbas
Post by: sechsrad on 2008-Mar-02
ich möchte diese datei nachladen mit einer art >include "gl.gbas"< , wie geht das in glbasic?

mfg
Title: gl.gbas
Post by: Schranz0r on 2008-Mar-02
IDE-> Rechte seite-> auf die Registrierkarte Datein wechseln -> rechtsklick-> datei hinzufügen

Das wars schon
Title: gl.gbas
Post by: sechsrad on 2008-Mar-02
jup, danke.

mfg
Title: gl.gbas
Post by: sechsrad on 2008-Mar-02
die befehle in der eingebundenen datei  "gl.gbas " werden nicht erkannt :
"gl-system.gbas"(7) error : call to undefined function : glClear

wenn ich diese datei direkt unter meinem hauptprogramm setze, läuft es.

wie wird denn eine verknüpfung dorthin eingeleitet?

mfg
Title: gl.gbas
Post by: Schranz0r on 2008-Mar-02
Das geht wunderbar, hatte da noch nie probleme!
Title: gl.gbas
Post by: sechsrad on 2008-Mar-02
lade mal oben das openl-demoprogramm und binde die gl.gbas extra ein, ob es bei dir funktioniert, vielleicht geht das mit keiner inline!
Title: gl.gbas
Post by: Schranz0r on 2008-Mar-02
du brauchst kein inline!

das sind gewrappte Befehle für GLBasic!

EDIT:

Hier ne Demo wie es geht http://www.styleattax.de/OpenGL_in_GLBasic.rar
Title: gl.gbas
Post by: sechsrad on 2008-Mar-02
he, du bist klasse, danke. diese kleine demo ist die lösung.

mfg
Title: gl.gbas
Post by: Schranz0r on 2008-Mar-02
gehts auf GP2X ?
Title: gl.gbas
Post by: sechsrad on 2008-Mar-02
Quotegpc_temp1.cpp:(.text+0x8ed4): undefined reference to `glTexCoordPointer'
alle opengl-befehle werden beim compilieren im gp2x-modus rausgeschmissen, wie es oben steht.

macht aber nichts. diese demo ist eine sehr gute hilfe für die arbeit unter windows.

mfg
Title: gl.gbas
Post by: Kitty Hello on 2008-Mar-03
NEIN! GP2X hat kein OpenGL.
Title: gl.gbas
Post by: Schranz0r on 2008-Mar-03
konnte ich nicht wissen :(
Title: gl.gbas
Post by: Kitty Hello on 2008-Mar-03
Kein Problem. Wollte es nur klarstellen.
Title: gl.gbas
Post by: trucidare on 2008-Mar-03
Hmm hab wohl vergessen hier was zu schreiben ;)
der gp2x hat bisher nur 1 spiel das mit open gl funktioniert aber die lib ist nich gerade ausgereift und vorallem irgendwie nirgends zu finden ?!?!?!
Title: gl.gbas
Post by: bigsofty on 2008-Apr-28
Quote from: bigsofty"glTexImage2D" is missing from "gl.gbas", Gernot needs to add this I'm afraid.

Something like...

Code (glbasic) Select
void __stdcall glTexImage2D(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, const void*);
Was this fixed Gernot?

Also, am I right in saying that the PDA 3D lib is OpenGLES?