Dark Bit Factory &  Gravity

Dark Bit Factory & Gravity

  • July 30, 2010 *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Pages: [1]   Go Down

Author Topic: TUTORIAL #1 - Setup  (Read 2387 times)

0 Members and 1 Guest are viewing this topic.

stormbringer

  • Time moves by fast, no second chance
  • Contributing Author
  • Amiga 1200
  • ******
  • Karma: 73
  • Offline Offline
  • Posts: 450
    • View Profile
    • WWW
TUTORIAL #1 - Setup
« on: June 13, 2009 »
So here it is: the first tutorial.

This tutorial will setup a simple screen/window and prepare everything for the final masterpiece.

Instead of starting to explain the Win32 API and the OpenGL API first, I give here and example on how to quickly create a skelton for an intro/demo using the GLTK, a small toolkit I wrote for this purpose.

GLTK takes care of everything required to setup a window/screen and I'll discuss this in details later when needed. First we have a look at what the high-level skeleton should look like, then we go deeper. Anyway, the source code is provided here anyway.

You will also notice that I make no use of the standard C type but rather personally defined types like CError and some others. These types have been defined in a file called dna.h (also provided here). This file just defines types with intelligent name.

First of all we'll discuss the high-level code found in the main.c file. Once the basics of the skeleton are understood, we can add more relevant stuff

Code: [Select]
/* RETRO-REMAKES TUTORIAL #1 - Screen/Window setup

Written by Stormbringer (stormbringer@retro-remakes.net)

This tutorial shows how to use the gltk api:

  a small Graphic Library Toolkit written on purpose for setting up a screen and some drawing properties for OpenGL

Here you will learn the basics of setting up a screen/window with OpenGL capabilities and intercept basic information,
such as mouse clicks, paint requests and time changes

*/

/*

  include the GLTK (Graphics Library Toolkit)

*/
#include "..\gltk\gltk.h"







/*

  our screen "object" that holds the properties of our screen/window

*/
GLTKScreenProperties screenProperties;







/*

  intro_on_mouse_left_down()

  user pressed the left mouse button

*/
CError intro_on_mouse_left_down(pCVoid userData)
{
/* quit */
gltk_screen_quit();

/* done */
return(0);
}






/*

  intro_on_vsync()

  this method works like a timer interrupt. we will use it to track time changes and update the animation of or elements, etc

*/
CError intro_on_vsync(pCVoid userData, CFloat64 deltaTime)
{

return(0);
}







/*

  intro_on_paint()

  this method is used to paint the graphic elements on screen

*/
CError intro_on_paint(pCVoid userData)
{
/* clean the screen
*/
/* black background */
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

/* clear depth buffer with default value */
glClearDepth(1.0f);

/* disable the depth test */
glDisable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

/* disable any clippin */
glDisable(GL_SCISSOR_TEST);


/* draw some stuff here...
*/


/* done */
return(0);
}




/*

  entry point

*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
/* hide cursor */
gltk_screen_show_cursor(FALSE);

/* init screen structure */
memset(&screenProperties,0,C_SIZE_OF(screenProperties));

/* name of the  */
screenProperties.name="My new cracktro";

/* define window dimensions
*/
screenProperties.width=640;
screenProperties.height=480;

/* request vsync

NOTE: in order for this option to work fine, you need to set your graphics driver Vertical Sync option on "Application Controlled"
*/
screenProperties.vsync=TRUE;

/* request refresh rate

NOTE: this will only work 100% in full screen mode, if the graphics card is capable of it
*/
screenProperties.vsyncFPS=60;

/* flag for window mode/full screen mode
*/
screenProperties.fullScreen=FALSE;

/* our method for painting the screen
*/
screenProperties.paintMethod=intro_on_paint;

/* our method for managing the time (where we change animation, etc)
*/
screenProperties.vsyncMethod=intro_on_vsync;

/* our method to intercept the left mouse button
*/
screenProperties.leftMouseDown=intro_on_mouse_left_down;

/* open the screen/window using the give properties
*/
if (gltk_screen_open(&screenProperties))
{
/* run the main loop, intercept system events, etc
*/
gltk_screen_run_loop(&screenProperties);


/* close screen window
*/
gltk_screen_close(&screenProperties);
}


/* exit and return code to system */
return(0);
}
« Last Edit: September 22, 2009 by Shockwave »
Logged
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Shockwave

  • good/evil
  • ADMIN
  • Senior Member
  • ********
  • Karma: 356
  • Offline Offline
  • Posts: 15085
  • evil/good
    • View Profile
    • WWW
Re: TUTORIAL #1 - Setup
« Reply #1 on: June 13, 2009 »
It builds and compiles fine in visual studio 2008 :-)

I got a nice empty borderless window, this looks cool. I need to find some tutorials of using visual studio next as I never used this IDE before but in fairness your framework looks nice to use.
Logged
Shockwave ^ Codigos....  Error: Keyboard not attached.... Press F1 to continue.

benny!

  • Senior Member
  • ******
  • Karma: 174
  • Offline Offline
  • Posts: 3424
  • in this place forever!
    • View Profile
    • WWW
Re: TUTORIAL #1 - Setup
« Reply #2 on: June 13, 2009 »
Nice one. Source code looks good. Seems that I need to re-install the Visual
Suite again on my comp.

K++
Logged
[ microBLOG - PHLOCKS - LABS - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

musashi9

  • ZX 81
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #3 on: June 14, 2009 »
Great stuff I have slways wanted to learn this and now I can   :updance:
Logged

Hotshot

  • Pentium
  • *****
  • Karma: 42
  • Offline Offline
  • Posts: 1166
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #4 on: June 14, 2009 »
work fine apart from 2 warning when i compiled the files.
Good to see a New Tutorial in our Forum :)
Logged

madeyes

  • ZX 81
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 15
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #5 on: June 16, 2009 »
These tutorials are a great idea....keep it up stormbringer I hope to see lots more
When I get time I'll be having a play with this
Logged

patrick

  • ZX 81
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #6 on: June 17, 2009 »
Hello all!

New here and this is my first post. My first question might be stupid but where do I get this gltk ? Or
is there something I'm missing. I tried to google for it but didn't find anything. Is there an svn-server or somthing where I could get it?

cheers

Patrick
Logged

stormbringer

  • Time moves by fast, no second chance
  • Contributing Author
  • Amiga 1200
  • ******
  • Karma: 73
  • Offline Offline
  • Posts: 450
    • View Profile
    • WWW
Re: TUTORIAL #1 - Setup
« Reply #7 on: June 17, 2009 »
@patrick: welcome here mate! the source code is in the zip file in my first post here, look at the top.
Logged
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

patrick

  • ZX 81
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #8 on: June 17, 2009 »
oh, how did I miss that :D. Well, thanks stormbringer. Quite a useful pack of functionality got to say :)
Logged

stormbringer

  • Time moves by fast, no second chance
  • Contributing Author
  • Amiga 1200
  • ******
  • Karma: 73
  • Offline Offline
  • Posts: 450
    • View Profile
    • WWW
Re: TUTORIAL #1 - Setup
« Reply #9 on: June 17, 2009 »
feel free to use it and learn more here through the tutorials. questions & comments are welcome
Logged
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

mmeuldijk

  • ZX 81
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 1
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #10 on: June 18, 2009 »
i had to harash you a lot of starting this tutorials, but you finnaly stated it, good job my friend.

greetings from the Gambia
Logged

bj

  • ZX 81
  • *
  • Karma: 8
  • Offline Offline
  • Posts: 10
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #11 on: September 23, 2009 »
Hi all, just given this a try, thanks a lot. Successful so far, though it took me a while to realise I'd need to register in order to see the download link.
Logged

James_wright_1990

  • C= 64
  • **
  • Karma: 4
  • Offline Offline
  • Posts: 46
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #12 on: December 07, 2009 »
Hi

Great tutorial the only problem is that when I tried to biuld the soulution i Got these errors:
Warning   1   warning LNK4076: invalid incremental status file '.\Debug/TUTORIAL1_Setup.ilk'; linking nonincrementally   TUTORIAL1_Setup   TUTORIAL1_Setup
Error   2   fatal error LNK1104: cannot open file 'LIBCD.lib'   TUTORIAL1_Setup   TUTORIAL1_Setup

Does anyone know how to fix this?

james
Logged
"if debugging is the proccess of removing bugs from software then that means that programming must be the proccess of putting them in" my favourite programming quote.

stormbringer

  • Time moves by fast, no second chance
  • Contributing Author
  • Amiga 1200
  • ******
  • Karma: 73
  • Offline Offline
  • Posts: 450
    • View Profile
    • WWW
Re: TUTORIAL #1 - Setup
« Reply #13 on: December 07, 2009 »
@James: what version/compiler do you use?
Logged
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

James_wright_1990

  • C= 64
  • **
  • Karma: 4
  • Offline Offline
  • Posts: 46
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #14 on: December 07, 2009 »
Hi

Im using visual studio 2008 Proffesional when i press build the errors come up I checked over the code and i dont see any errors and i know other people have got it work with visual studio so Im a bit confused I know my laptop has a bit of a personality problem so it could just be it acting up

James

edit(scratch that i individually compiled all of the .c files then built it and now i just get two warnings is that normal)
« Last Edit: December 07, 2009 by James_wright_1990 »
Logged
"if debugging is the proccess of removing bugs from software then that means that programming must be the proccess of putting them in" my favourite programming quote.

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
Re: TUTORIAL #1 - Setup
« Reply #15 on: December 07, 2009 »
@James_wright_1990: Works fine for me under MSVC 2008, first delete all files inside "Debug" folder, and just let MSVC convert "TUTORIAL1_Setup.dsp" and it will compile fine on debug/release mode.


Logged
rbz ^ Codigos

James_wright_1990

  • C= 64
  • **
  • Karma: 4
  • Offline Offline
  • Posts: 46
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #16 on: December 07, 2009 »
Cheers for that got it sorted now all working fine thanks for the help. Builds fine great tutorial.

James
Logged
"if debugging is the proccess of removing bugs from software then that means that programming must be the proccess of putting them in" my favourite programming quote.
Pages: [1]   Go Up
 

 

B l a c k R a i n V.2 by C r i p

Page created in 0.132 seconds with 19 queries.