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

0 Members and 1 Guest are viewing this topic.

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
REMAKES 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: March 06, 2011 by Shockwave »
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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17378
  • Karma: 497
  • evil/good
    • View Profile
    • My Homepage
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.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4381
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
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++
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline musashi9

  • ZX 81
  • *
  • Posts: 3
  • Karma: 0
    • 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:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • 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 :)

Offline madeyes

  • ZX 81
  • *
  • Posts: 23
  • Karma: 4
    • 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

Offline patrick

  • ZX 81
  • *
  • Posts: 2
  • Karma: 0
    • 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

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
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.
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

Offline patrick

  • ZX 81
  • *
  • Posts: 2
  • Karma: 0
    • 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 :)

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
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
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

Offline mmeuldijk

  • ZX 81
  • *
  • Posts: 1
  • Karma: 0
    • 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

Offline bj

  • ZX 81
  • *
  • Posts: 20
  • Karma: 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.

Offline James_wright_1990

  • C= 64
  • **
  • Posts: 48
  • Karma: 4
    • 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
"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.

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: TUTORIAL #1 - Setup
« Reply #13 on: December 07, 2009 »
@James: what version/compiler do you use?
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

Offline James_wright_1990

  • C= 64
  • **
  • Posts: 48
  • Karma: 4
    • 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 »
"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.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2731
  • Karma: 485
    • View Profile
    • http://www.rbraz.com/
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.


Challenge Trophies Won:

Offline James_wright_1990

  • C= 64
  • **
  • Posts: 48
  • Karma: 4
    • 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
"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.

Offline jokkmokk

  • ZX 81
  • *
  • Posts: 6
  • Karma: 2
    • View Profile
Re: TUTORIAL #1 - Setup
« Reply #17 on: November 08, 2010 »
Great tutorial man!

Downloaded the template and it compiles fins under VS6. :goodpost:

Seems to have some difficulties under VS2010, though.

Thanks again!

Offline spiffy

  • ZX 81
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: REMAKES TUTORIAL #1 - Setup
« Reply #18 on: March 15, 2014 »
Hi! :)

Very good tutorial!

I just found it.. :) and it's just what I needed :) Thx!


Offline dr.zeissler

  • C= 64
  • **
  • Posts: 69
  • Karma: 0
    • View Profile
Re: REMAKES TUTORIAL #1 - Setup
« Reply #19 on: December 09, 2017 »
 :inspired:Can I use this for a mac?

I own a nice little and quiet g4-mac-mini with osx 10.4.

It has a G4 PPC 1,5Ghz and an ATI 9200 (64MB). That should be enough to made some old cracktros/intros run at 80fps.
Perhaps it it possible to use some techniques the OS has build in, like core-image etc.
Some software seems to use this and produces a real stutterfee image movement or call it scrolling.

Thx
Doc
« Last Edit: December 09, 2017 by dr.zeissler »