Category Archives: OpenGL

Blender 3D – Using OpenGL include addon .

I have many source code to deal with OpenGL. The main goal come when you need to put objects into enviroment.
Even you use C, C++, C#, assembly language or python – PyOpenGL module this will give you some problems when you need to import 3D objects.
With this addon from here, all you need is more good.
The main reason I like this addon come with all data and infos to work with 3D files.
If you think is more simple to use .obj file then you have some hacked problems.
First ths .obj files can be change and if you use just some parts then you need to parse it.
The addon create one .h file header and also has a good structure of date.
Go to the link – show on the top of this tutorial , unarchive and put into:
C:\Program Files\Blender Foundation\Blender\2.73\scripts\addons
If you install Blender 3D , just put into your path under addons folder.
The next pictures will show how to use this:
opengl_blender_001
opengl_blender_002
Use your editor to see the output.
opengl_blender_003

Posted in 3D, All, Blender 3D, OpenGL, Programming. Tagged with , , , , , .

Working with GLFW library under Fedora.

Today I will try to use GLFW library.

GLFW is a C library that lets you using an OpenGL context and window, display modes and inputs like keyboard, mouse, joystick and time.

GLFW supports Windows, Mac OS X and Unix, Linux and FreeBSD and any operating systems with the X Window System.

Also you can read more about this library here.

First install the library using root account.

Now let’s see the source code.

First I includes all librarys I need.

In the main function I start to see if the library is working.

The next step is to set some settings, see:

… and also testing the desktop settings.

The settings it’s show on console with cout function.

Now I make the window context using fullscreen option.

I set the title of the window.

I enable the keys.

The next source code it’s close the window.

Testing with time command to see how fast working.

The netbeans IDE make the package in this path.

I make RPM package for Fedora distro.

I test my example and working well.

Posted in 3D, All, C++, Linux, OpenGL, Programming. Tagged with , , , , , .

Make your shadres online with SpiderGL – MeShader interface.

SpiderGL is a JavaScript 3D Graphics library which relies on WebGL for realtime rendering.

You can test it online using your browser using this website.

The website allow you to write shaders and also rendering the output.

About the web interface then has some windows to write your code and set the viewer.

See the next image:

meshade website

All steps show you how to use this web interface.

You need to load the 3D object using the Load button with this mesh: data/gargoyle1k.obj.

The website come with default example from shaders source code ( see step 2 and 3).

The steps 4 will apply the shaders and show on log windows if you got errors.

The step 5 will save your shaders.

Now about shaders source code.

If you want to use shader you need to have two source code: vertex shader source code and fragment shader source code.

The website interface come with two windows for each source code.

All two windowes need to have this source code in the top of each windows source code:

This tell shaders rendering about the data used by vertex and fragment shader.

This can be already declare in some engine scripting.

For example if you use Unity 3D engine then you can redefine VERTEX_P and FRAGMENT_P at the top of your shader file.

… where VERTEX_P and FRAGMENT_P it’s vertex and fragment shaders source code.

About Vertex Shader Source is the source code can be used to:

… is a set of attributes and functions performed by vertices and is responsible for running the vertex shaders.

About Fragment Shader Source is the source code can be used to:

… all the interpolated values computed in vertex shaders is used to code all effects that the application requires.

Also the fragment shader has no access to the frame buffer.

What do you know about shaders source code ?

Has one part of declarations like any programming language.

Also come with main function to run the shader.

The declarations is also like any language with variable , constants:

Uniforms are values which do not change during a rendering.

Attributes are only available in vertex shader and they are input values which change every vertex.

Varyings are used for passing data from a vertex shader to a fragment shader.

const this variables can be declared as const are compile-time constants and are not visible outside the shader that declares them.

If you know C language then the language syntax is C-like.

The default example from website :

The vertex shader

The fragment shader

Simple example I created using this website to show the normals.

Change this source code line from fragment shader:

The result rendering is:

meshade-002

You can see the object is fill with colors with x,y and z colors.

I will come with new tutorials about shaders.

Posted in 3D, All, OpenGL. Tagged with , , , .

How to get? the GLSL and OpenGL version.

You can get version from the OpenGL and GL Shading program by:

If don’t initialize the OpenGL you can get it:

Let’s try one simple example.

The output will be print on the shell.

Posted in Linux, OpenGL, Programming. Tagged with , , .

How to create an executable in Linux using OpenGL.

I will try to show you briefly how to create a Linux OpenGL applications.

We check if the graphics card and settings are done correctly, using the command:

As freeglut devel package provides libraries for OpenGL. Let’s install that package.

Then we see if we have the necessary files.

Let’s try a simple opengl example. This example use glut functions.

The code source is show below with with explanations…

We run the application now.

opengl example tutorial

I wait your opinion and possibly more complex example.

Posted in 3D, Linux, OpenGL, Programming. Tagged with , , , .