Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - TinDragon

Pages: [1] 2 3
1
Projects / HLSL Tunnel
« on: June 25, 2012 »
Having managed to get ps_3_0 shaders going I decided to try and make something moving, based the code off a glsl example from iq's shadertoy. Would probably have taken far less time if I actually new any hlsl before hand but I figured it out as I went along and got texture loading going by hacking into my bmax code a way to use the D3DX9_43.dll, this means you need the latest dx install for this to work but why wouldnt a windows user have that anyway :P

Also needs a shader model 3 card, it will likely crash on anything lower.

If you feel like letting me know if it works and what your windows version and gfx card is feel free, would be useful to see how it runs on nvidia as I only have ati :)

I know this could  be done in 1k or less in c/c++ but doing it in bmax is kinda cool, I dont really see anyone else doing it, and this is more an off shoot from me learning directx.

Cheers
Jon

2
General coding questions / HLSL ps_3_0 issue
« on: June 22, 2012 »
Hi all, I have been trying to get a HLSL shader working in bmax, its the simple setup, render a fullscreen quad then use a pixelshader, the code is based off an dx9 example from rbz for c++ and iq's frameworks. I can get it to use the simple ps_2_0 shader that iq has in that framework fine, but any attempt I make at doing a ps_3_0 shader results in nothing being rendered but the background cls colour. Having not really done much HLSL stuff I am not sure if its something I am doing wrong or not.

This is the ps_2_0 shader code that works with ps_2_0 as the target.
Code: [Select]
float4 ps_main(float2 u:TEXCOORD):color
{
return float4(u.x,u.y,0.4,1);
}

If i change the shader target to ps_3_0 should this still compile and display?
I am not getting a compile error and the exe runs, I just dont get anything on screen. I have tried a few different shaders that are ment to be ps_3_0 ones but all give me the same blank screen so I am thinking there's something else i need to do for ps_3_0, probably in how the quad is rendered or some dx transform setting I am missing? but I havent found a simple example that uses this level shader.

Hopefully someone on here can point me in the right direction  :)

Cheers
Jon







3
Well I havent had time to work on this so I have added a tune and given it a name. It's not what I hoped to have done but I will probably look to take the concept further outside the compo and perhaps make what I originally planned.

Think the name gives away what it is, spacebar toggles the glow of the recog on and off. Uses my opengl engine coded in blitzmax and models created in blender (by me as well). Uses a framebuffer extension, so a gl2.0+ card needed but thats it for techy stuff :P

Here's the piccy and download.

4
Projects / Revival By TTD
« on: April 26, 2011 »
Well it's been along time since we released anything and while I got side tracked from my game project I decided to turn one of the tests of the gl framework for bmax into a little retro cracktro inspired effort. I hope you like it and I also hope that it runs ok :)




5
General chat / Intro Inferno
« on: April 24, 2011 »
Hey folks, since I been away from the forums and the demoscene in general I thought I would catch up abit and check out whats been happening and see if i could find inspiration. I use to like going to intro inferno as it tends to be more the smaller prods i like, but at the moment the links seem to end at no site, there's a redirect but then it dies. Anyone have any idea whats happened and if it will be back?

  :(

6
Projects / TTD - JugglerJ2K
« on: August 17, 2009 »
Clyde posted a little challenge in the shoutbox for TTD to replicate the juggler from the RSI megademo, I decided to meet that challenge so here's my little tribute to the juggler.


7
Projects / TTD - GlenzNco
« on: August 14, 2009 »
Here's a new intro featuring one of the effects from my unfinish projects post, I converted it over to the bmax vectorlib and added a couple of other effects you might have seen before. Oh and sorry for the exe size but I cant seem to trim this one anymore using this framework.

Enjoy.

8
Projects / J2K Dance of Light
« on: August 13, 2009 »
Here's one of the only demo/intro things I ever did with blitz3d that used 3d commands from the language rather than pixelpushing. It's the same sort of effect as the 2d alphastars but using a 3d bobs so we get nice blending. I always like the way things glow when you do this sort of thing :)
This was a slight rework back when clyde was running cool creations, I basicly upped the sprite count and changed the logo from 2d to 3d and added some controls so people could mess with the effects abit. Should work on any DX7 upwards cards :)

Here it is, enjoy.

9
Projects / I-Torus Joncom2000/TTD
« on: August 10, 2009 »
Here's another of my old blitz demos, this one uses an early vectorlib and was an attempt to do something like the 16bit demos. You can move on to the next effect with the spacebar. The exe contains 2 versions, the _B version is a bug fixed version that I suggest using as the 1st version failed on some graphics cards. Hopefully it should work for everyone, I have tested on XP and Vista 32bit with no errors.

Here's the Demo and Enjoy  :||

10
Projects / TTD-J2Kryn
« on: August 09, 2009 »
Yesterday I asked Zawran to take part in a small challenge. The challenge was to find a cracktro on youtube and do our own version of it. Its not ment to be a 1-1 remake more a base of inspiration and to look similiar.

Here is the result of my efforts:

11
Projects / Joncom2000 Demo Archives
« on: August 07, 2009 »
Since hardly any of my demos or intros are available anywhere I thought I would post a few here. Almost all are coded in blitzbasic using only 2d drawing so any 3d effects are software rendered. I will post a small screenshot and the demo in a post with alittle bit of information about the demo, if I can remember any :)

So to start the ball rolling here's the first one.

This demo is called "stars in a box" it was my 3rd attempt at making a demo in blitz, the effects are set to change based on events in the scrolltext. I havent got the source to this demo anymore so I have not been able to change it so the scroll text points to the old dbf site. It should run on any dx7 level pc at a reasonable speed. I have tested it on vista with no problems.
 


12
Projects / D3D9 test in bmax
« on: August 03, 2009 »
Hi all, I have been having a go at using directx9 and more specific d3d9 in blitzmax, I converted a example from C/C++ I found on the net and after several failed attempts and some hunting around I finally got the same result as the c++ code gave me in VC++. What I really want to know is it the exe runs on other peoples systems, so if you wouldnt mind testing it, I would be grateful.

I am not to sure how much more I will be able to do but it's been an interesting experience so far and I think messing with the dx Vertex buffers has made me think about vertex arrays and VBO's in GL, something I havent done yet :)

Anyway a screenie and the exe.

Cheers
Jon

13
C / C++ /C# / [C]Simple GDI solid vector code.
« on: July 30, 2009 »
Here are the C source files to one of my very early attempts at using graphics in C code, it uses GDI to render the stuff and isnt an exactly super effects 3d engine but it was back in 2004 when coded it and I had no real idea wtf I was doing  :D

I wouldnt suggest using this code as is for an engine but it might help a few people learn something if only how not to code :D

Headerfile - VectorEngine.h
Code: [Select]
//-----------------------------------------------------------------------------------------------------
// 3d Flat Vector Engine (real basic one)
// by Joncom2000
// Dec 2004
//-----------------------------------------------------------------------------------------------------
#pragma once

#include <windows.h>   // include all the windows headers
#include <math.h>
//-----------------------------------------------------------------------------------------------------
// Setup Constants and Arrays
//-----------------------------------------------------------------------------------------------------
#define MAXPOINTS 10000
#define MAXFACES 10000
float fVX; // X rotation.
float fVY; // Y rotation.
float fVZ; // Z rotation.
int iPoints; // The amount of points in the Object
int iFaces; // The Amount of faces in the Object
float fOriginx[MAXPOINTS]; // Original X co-ordinate store
float fOriginy[MAXPOINTS]; // Original Y co-ordinate store
float fOriginz[MAXPOINTS]; // Original Z co-ordinate store
int iTransx[MAXPOINTS]; // Transformed  X co-ordinate store
int iTransy[MAXPOINTS]; // Transformed Y co-ordinate store
float fTransz[MAXPOINTS]; // Transforned Z co-ordinate store
int iF1[MAXFACES]; // Connections definition
int iF2[MAXFACES]; // Connections definition
int iF3[MAXFACES]; // Connections definition
int iRd[MAXFACES]; // Face red amount
int iGr[MAXFACES]; // Face green amount
int iBl[MAXFACES]; // Face blue amount
//---------------------------------------------------------------------------------
// Z Sort stuff
//---------------------------------------------------------------------------------
int iRenderlist[MAXFACES]; // contains face number
float fRenderzmin[MAXFACES]; // Minimum Z use in color code
//---------------------------------------------------------------------------------
// Polydraw Setup
//---------------------------------------------------------------------------------
COLORREF TempCol;
POINT point_list[3];

// Function prototypes ?
void Rotate3dpoints(int iDistance=3,int iHalfx=320,int iHalfy=240);
int CreateRenderlist();
int Quicksort(int l,int r);
void DrawSortedObject(HDC hDC,int iNumberrendered,int iLight=30);
void TriangleFill(HDC hDC,int tmx1,int tmy1,int tmx2,int tmy2,int tmx3,int tmy3,int r,int g,int b);
void Cls(HDC hDC,int r=0,int g=0,int b=0,int x=640,int y=480);
void ReadModel();
void readstr(FILE *f,char *string);

Engine Code - VectorEngine.cpp
Code: [Select]
//-----------------------------------------------------------------------------------------------------
// 3d Flat Vector Engine (real basic one)
// by Joncom2000
// Dec 2004
//-----------------------------------------------------------------------------------------------------
#include <stdio.h> // Header File For Standard Input/Output
#include "VectorEngine.h"
  //-------------------------------------------------------------------
// NAME : Rotate3dpoints()
// PURPOSE : This function rotates the points in 3d.
// INPUTS : None.
// RETURNS : Nothing.
//-------------------------------------------------------------------
void Rotate3dpoints(int iDistance,int iHalfx,int iHalfy)
{
float cosx,cosy,cosz,sinx,siny,sinz,x3d,y3d,z3d,tx,ty,tz,ox;
cosx=cos((float)(fVX * 0.0174532925));
sinx=sin((float)(fVX * 0.0174532925));
cosy=cos((float)(fVY * 0.0174532925));
siny=sin((float)(fVY * 0.0174532925));
cosz=cos((float)(fVZ * 0.0174532925));
sinz=sin((float)(fVZ * 0.0174532925));
for(int n=0;n<iPoints+1;++n)
{
x3d = fOriginx[n];
y3d = fOriginy[n];
z3d = fOriginz[n];
    ty = (y3d * cosx) - (z3d * sinx);
tz = (y3d * sinx) + (z3d * cosx);
tx = (x3d * cosy) - (tz * siny);
tz = (x3d * siny) + (tz * cosy);
ox = tx;
tx = (tx * cosz) - (ty * sinz);
ty = (ox * sinz) + (ty * cosz);
iTransx[n]=(int((tx / (iDistance-tz))*512))+iHalfx;
iTransy[n]=(int((ty / (iDistance-tz))*512))+iHalfy;
fTransz[n]=tz;
}
}
//-------------------------------------------------------------------
// NAME : CreateRenderlist()
// PURPOSE : Determine which faces to render
// INPUTS : renderbank=bank to draw clear
// RETURNS : None.
//-------------------------------------------------------------------
int CreateRenderlist()
{
int vx1,vx2,vy1,vy2,n;
int iNumberrendered=0;
for(int a=0;a<iFaces+1;++a)
{
vx1= iTransx[iF1[a]]-iTransx[iF2[a]];
vy1= iTransy[iF1[a]]-iTransy[iF2[a]];
vx2= iTransx[iF3[a]]-iTransx[iF2[a]];
vy2= iTransy[iF3[a]]-iTransy[iF2[a]];
n=vx1*vy2-vx2*vy1;
if(n>0)// ;If Not removed by backface cull Then add To renderlist And renderz#
{
iRenderlist[iNumberrendered]=a;
fRenderzmin[iNumberrendered]=fTransz[iF1[a]];
if(fTransz[iF2[a]]<fRenderzmin[iNumberrendered])
{
fRenderzmin[iNumberrendered]=fTransz[iF2[a]];
}
if(fTransz[iF3[a]]<fRenderzmin[iNumberrendered])
{
fRenderzmin[iNumberrendered]=fTransz[iF3[a]];
}
iNumberrendered=iNumberrendered+1;
}
}
iNumberrendered=iNumberrendered-1;
return(iNumberrendered);
}
//-------------------------------------------------------------------
// NAME : Quicksort()
// PURPOSE : Sort visable faces into order
// INPUTS : l & r
// RETURNS : true :).
//-------------------------------------------------------------------
int Quicksort(int l,int r)
{
int p,q,h1,a;
float h2,z;
p=l;
q=r;
z=fRenderzmin[(l+r)/2];
while(true)
{
while(fRenderzmin[p]<z)
{
p=p+1;
}
while(z<fRenderzmin[q])
{
q=q-1;
}
if(p>q)
{
break;
}
//SWAP------------------
h1=iRenderlist[q];
h2=fRenderzmin[q];
iRenderlist[q]=iRenderlist[p];
fRenderzmin[q]=fRenderzmin[p];
iRenderlist[p]=h1;
fRenderzmin[p]=h2;
//----------------------
p=p+1;
q=q-1;
if(q<0)
{
break;
}
}
if(l<q)
{
a=Quicksort(l,q);
}
if(p<r)
{
a=Quicksort(p,r);
}
return(1);
}
//-------------------------------------------------------------------
// NAME : DrawSortedObject()
// PURPOSE : Render visable faces in order
// INPUTS : renderbank=bank to draw clear
// RETURNS : None.
//-------------------------------------------------------------------
void DrawSortedObject(HDC hDC,int iNumberrendered,int iLight)
{
int r,g,b;
for(int a=0;a<iNumberrendered+1;++a)
{
r=iRd[iRenderlist[a]]+int(fRenderzmin[a]*iLight);
g=iGr[iRenderlist[a]]+int(fRenderzmin[a]*iLight);
b=iBl[iRenderlist[a]]+int(fRenderzmin[a]*iLight);
if(r<0)
{
r=0;
}
if(r>255)
{
r=255;
}
if(g<0)
{
g=0;
}
if(g>255)
{
g=255;
}
if(b<0)
{
b=0;
}
if(b>255)
{
b=255;
}
TriangleFill(hDC,iTransx[iF1[iRenderlist[a]]],iTransy[iF1[iRenderlist[a]]],iTransx[iF2[iRenderlist[a]]],iTransy[iF2[iRenderlist[a]]],iTransx[iF3[iRenderlist[a]]],iTransy[iF3[iRenderlist[a]]],r,g,b);
}
}
//------------------------------------------------------------------
// NAME : ReadModel()
// PURPOSE : Reads in a models data (uses. Model.txt for filename :(
// INPUTS : None
// RETURNS : Nothing
//------------------------------------------------------------------
void ReadModel()
{
float x, y, z;
int f1,f2,f3;
FILE *filein;
char oneline[255];
filein = fopen("Data.ttd", "rt"); // File To Load model Data From
readstr(filein,oneline);
sscanf(oneline, "%d\n", &iPoints);
readstr(filein,oneline);
sscanf(oneline, "%d\n", &iFaces);
for (int loop = 0; loop < iPoints; loop++)
{
readstr(filein,oneline);
sscanf(oneline, "%f %f %f", &x, &y, &z);
fOriginx[loop]=x;
fOriginy[loop]=y;
fOriginz[loop]=z;
}
for (int loop = 0; loop < iFaces; loop++)
{
readstr(filein,oneline);
sscanf(oneline, "%d %d %d", &f1, &f2, &f3);
iF1[loop]=f1;
iF2[loop]=f2;
iF3[loop]=f3;
iRd[loop]=128; // Face red amount
iGr[loop]=128; // Face green amount
iBl[loop]=128;
}
fclose(filein);
}
void readstr(FILE *f,char *string)
{
do
{
fgets(string, 255, f);
} while ((string[0] == '/') || (string[0] == '\n'));
return;
}
//------------------------------------------------------------------
// NAME : Cls(hDC,r,g,b,x,y)
// PURPOSE : Quick and dirty cls command
// INPUTS : r,g,b & x,y size
// RETURNS : Nothing
//------------------------------------------------------------------
void Cls(HDC hDC,int r,int g,int b,int x,int y)
{
HPEN pen_color;
HBRUSH brush_color;
// set colors for drawing
TempCol=RGB(r,g,b);
    pen_color=CreatePen(PS_SOLID,1,TempCol);
    brush_color=CreateSolidBrush(TempCol);
    // select them into dc
    SelectObject(hDC,pen_color);
    SelectObject(hDC,brush_color);
// Draw a rectangle
Rectangle(hDC,0,0,x,y);
// Do not forget to clean up.
    DeleteObject(pen_color);
    DeleteObject(brush_color);
}
//------------------------------------------------------------------
// NAME : TriangleFill(hdc,tmx1,tmy1,tmx2,tmy2,tmx3,tmy3,r,g,b)
// PURPOSE : fills a triangle
// INPUTS : three sets of points and seperate rgb values
// RETURNS : Nothing
//------------------------------------------------------------------
void TriangleFill(HDC hDC,int tmx1,int tmy1,int tmx2,int tmy2,int tmx3,int tmy3,int r,int g,int b)
{
HPEN pen_color;
HBRUSH brush_color;
// set colors for polygon
TempCol=RGB(r,g,b);
    pen_color=CreatePen(PS_SOLID,1,TempCol);
    brush_color=CreateSolidBrush(TempCol);
    // select them into dc
    SelectObject(hDC,pen_color);
    SelectObject(hDC,brush_color);
    // create array of points
    point_list[0].x=tmx1;
    point_list[0].y=tmy1;
    point_list[1].x=tmx2;
    point_list[1].y=tmy2;
point_list[2].x=tmx3;
    point_list[2].y=tmy3;
    // draw the polygon
    Polygon(hDC, point_list, 3);
    // Do not forget to clean up.
    DeleteObject(pen_color);
    DeleteObject(brush_color);
}

Example - GDIenginemain.cpp
Code: [Select]
// INCLUDES ///////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN  // just say no to MFC

#include <windows.h>   // include all the windows headers
#include <strsafe.h>   // This enables us to use sprintf
#include <math.h>
#include "VectorEngine.h"
// DEFINES ////////////////////////////////////////////////
// defines for windows
#define WINDOW_CLASS_NAME "WINCLASS1"
#define WINDOW_WIDTH  640
#define WINDOW_HEIGHT 480
// MACROS /////////////////////////////////////////////////
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
// GLOBALS ////////////////////////////////////////////////
HWND      main_window_handle = NULL; // globally track main window
HINSTANCE hinstance_app      = NULL; // globally track hinstance
HDC       hOffscreenDC= NULL;
HBITMAP   hOffscreenBitmap= NULL;
BOOL bFullScreen = FALSE; // Create a boolean and set it to false.  If we choose full screen, set it to TRUE
void EffectSetup();
int EffectMain(HDC hdc);
void GetFPS2(HDC hDC);
float fDelta=1;
// FUNCTIONS //////////////////////////////////////////////
// Fullscreen
void ChangeToFullScreen(int width, int height)
{
DEVMODE dmSettings; // Device Mode variable - Needed to change modes

memset(&dmSettings,0,sizeof(dmSettings)); // Makes Sure Memory's Cleared

// Get current settings -- This function fills our the settings
// This makes sure NT and Win98 machines change correctly
if(!EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dmSettings))
{
// Display error message if we couldn't get display settings
MessageBox(NULL, "Could Not Enum Display Settings", "Error", MB_OK);
return;
}

dmSettings.dmPelsWidth = width; // Set the desired Screen Width
dmSettings.dmPelsHeight = height; // Set the desired Screen Height
dmSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; // Set the flags saying we're changing the Screen Width and Height

// This function actually changes the screen to full screen
// CDS_FULLSCREEN Gets Rid Of Start Bar.
// We always want to get a result from this function to check if we failed
int result = ChangeDisplaySettings(&dmSettings,CDS_FULLSCREEN);

// Check if we didn't recieved a good return message From the function
if(result != DISP_CHANGE_SUCCESSFUL)
{
// Display the error message and quit the program
MessageBox(NULL, "Display Mode Not Compatible", "Error", MB_OK);
PostQuitMessage(0);
}
}



LRESULT CALLBACK WindowProc(HWND hwnd,
    UINT msg,
                            WPARAM wparam,
                            LPARAM lparam)
{
// this is the main message handler of the system
PAINTSTRUCT ps; // used in WM_PAINT
HDC hdc; // handle to a device context

// what is the message
switch(msg)
{
case WM_CREATE:
        {
// do initialization stuff here

        // return success
return(0);
} break;
   
case WM_PAINT:
{
// simply validate the window
        hdc = BeginPaint(hwnd,&ps);
       
        // end painting
        EndPaint(hwnd,&ps);

        // return success
return(0);
    } break;

case WM_DESTROY:
{

// kill the application, this sends a WM_QUIT message
PostQuitMessage(0);

        // return success
return(0);
} break;

default:break;

    } // end switch

// process any messages that we didn't take care of
return (DefWindowProc(hwnd, msg, wparam, lparam));

} // end WinProc

// WINMAIN ////////////////////////////////////////////////
int WINAPI WinMain( HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{

WNDCLASSEX winclass; // this will hold the class we create
HWND    hwnd; // generic window handle
MSG    msg; // generic message
HDC        hdc;      // graphics device context

// first fill in the window class stucture
winclass.cbSize         = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC |
                          CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);

// save hinstance in global
hinstance_app = hinstance;

// register the window class
if (!RegisterClassEx(&winclass))
return(0);
 // Fullscreen ?
  DWORD dwStyle;

  if(MessageBox(NULL, "Click Yes to go to full screen", "Options", MB_YESNO | MB_ICONQUESTION) == IDNO)
{
dwStyle = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX; // If we don't want full screen, open a simple window
}
else // If we chose YES
{
bFullScreen = TRUE; // Set our boolean to TRUE, we wanted fullscreen

// This is the style that we need our window to have in order to be windowless fullscreen
dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
ChangeToFullScreen(WINDOW_WIDTH,WINDOW_HEIGHT); // This changes our screen to full screen with our desired resolution
}
  // Create the window
  if (!bFullScreen)
  {
hwnd = CreateWindowEx(NULL,                // extended style
                            WINDOW_CLASS_NAME,   // class
    "Joncom2000 GDI Engine v0.1", // title
    WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX| WS_VISIBLE,
0,0,   // initial x,y
    WINDOW_WIDTH+6, // initial width
                            WINDOW_HEIGHT+32,// initial height
    NULL,   // handle to parent
    NULL,   // handle to menu
    hinstance,// instance of this application
    NULL); // extra creation parms
  }
  else
  {
hwnd = CreateWindowEx(NULL,                // extended style
                            WINDOW_CLASS_NAME,   // class
    "Joncom2000 GDI Engine v0.1", // title
    WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN| WS_VISIBLE,
0,0,   // initial x,y
    WINDOW_WIDTH, // initial width
                            WINDOW_HEIGHT,// initial height
    NULL,   // handle to parent
    NULL,   // handle to menu
    hinstance,// instance of this application
    NULL); // extra creation parms
ShowCursor(FALSE);
  }
  if (!hwnd)
  return(0);
// save main window handle
main_window_handle = hwnd;

// get the graphics device context
hdc = GetDC(hwnd);
// Create the offscreen device context and bitmap
hOffscreenDC = CreateCompatibleDC(GetDC(main_window_handle));
hOffscreenBitmap = CreateCompatibleBitmap(GetDC(main_window_handle),640,480);
SelectObject(hOffscreenDC, hOffscreenBitmap);
EffectSetup();
SetBkMode(hOffscreenDC,OPAQUE);
SetBkColor(hOffscreenDC,RGB(0,0,0));
SetTextColor(hOffscreenDC, RGB(255, 255, 255));
// enter main event loop, but this time we use PeekMessage()
// instead of GetMessage() to retrieve messages
while(TRUE)
{
// test if there is a message in queue, if so get it
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
// test if this is a quit
if (msg.message == WM_QUIT)
{
break;
}
// translate any accelerator keys
TranslateMessage(&msg);
// send the message to the window proc
DispatchMessage(&msg);
} // end if
    // main game processing goes here
    if (KEYDOWN(VK_ESCAPE))
{
       SendMessage(hwnd, WM_CLOSE, 0,0);
}
EffectMain(hOffscreenDC);
// Blit the offscreen bitmap to the game screen
BitBlt(hdc, 0, 0, WINDOW_WIDTH,WINDOW_HEIGHT,hOffscreenDC, 0, 0, SRCCOPY);
//GetFPS();
} // end while
if(bFullScreen) // If we went to full screen mode
{ // Calling the same function with NULL and 0 reset the screen settings and resolution
ChangeDisplaySettings(NULL, 0);
ShowCursor(TRUE);
}

// release the device context
ReleaseDC(hwnd,hdc);
// Cleanup the offscreen device context and bitmap
DeleteObject(hOffscreenBitmap);
DeleteDC(hOffscreenDC);

// return to Windows like this
return(int(msg.wParam));

} // end WinMain

void GetFPS2(HDC hDC)
{
   // Statics are used so that values exsist after the function has
   // ended so the next time it is called the values are still there.
   // I really don't like using globals so I don't when I can.

   // This will hold the number of frames that will go in the title bar.
   // Lets initialize this to 0;
   static char titleBar[25] = {0};
   static RECT  rect = { 0, 0, 70, 20 };

   // This will hold the number of frames per second in between seconds.
   static float FPS = 0.0f;

   // This will be used to check if a second has passed.
   float nextSecond = 0.0f;

   // This is the last second that occured.
   static float prevSecond = 0.0f;

   // Add to the frames per second every time this function is called.
   FPS++;

   // Get the second in millisecond then multiply it by 0.001 to convert this to
   // seconds.
   nextSecond = GetTickCount() * 0.001f;

   // If the time we have now substracted from the previous second is greater than
   // or equal to 1 (i.e. if a second has passed) then we display the FPS number.
   if(nextSecond - prevSecond > 1.0f)
      {
        // Make the second we just got the previous second so we can used this the
        // next time the function is called.
    prevSecond = nextSecond;
   
        // print the FPS in the titlebar array.  Don't forget to cast the FPS so
        // what is printed is a whole number.  Or you can just print only 2 or
        // even no decimal places after the number.  What ever turns you on.
StringCbPrintf(titleBar,25,"%d FPS ", int(FPS));
if(FPS>1)
{
fDelta=float((85.0/FPS));
}
        // Reset the FPS counter.
        FPS = 0;
      }
DrawText(hDC, titleBar, -1, &rect, DT_SINGLELINE | DT_RIGHT | DT_VCENTER);
}

void EffectSetup()
{
ReadModel();
}
int EffectMain(HDC hDC)
{
int iNumberrendered;
Cls(hDC);
fVX=fVX+float(1*fDelta);
fVY=fVY+float(0.5*fDelta);
fVZ=fVZ+float(0.25*fDelta);
if (fVX>360)
{
fVX=fVX-360;
}
if (fVY>360)
{
fVY=fVY-360;
}
if (fVZ>360)
{
fVZ=fVZ-360;
}
Rotate3dpoints(250,320,240);
iNumberrendered=CreateRenderlist();
Quicksort(0,iNumberrendered);
DrawSortedObject(hDC,iNumberrendered,1);
GetFPS2(hDC);
return (0);
}

The code was compiled originally in VC++ 2003.net but it does compile under VC 2008 express, not sure about DevC++ but only non-standard include is for fps display so can probably be worked around :)

Attached is a rar with the sourcecode, compiled exe and a test data file for a object.

Cheers
Jon


14
Blitz / [BMAX]Magnified Rotozoom source
« on: July 26, 2009 »
Here's the source code to one of my challenge entries, it requires Zawrans software render framework to compile which is also available on the forum.
It's not the best commented source in the world but atleast shows some more uses for Zawrans code for any bmax users interested :)

Code: [Select]
SuperStrict

Framework BRL.GLMax2D
Import BRL.Pixmap
Import BRL.PNGLoader
'Import BRL.Random
Import BRL.Retro

AppTitle="Rotozoom Magnify"

SetGraphicsDriver GLMax2DDriver()

Include "zSoftwareRenderFramework_v04.bmx"
Const XRES:Int=800
Const YRES:Int=600
Graphics XRES,YRES,0

Global timerUpd:Int = MilliSecs()
Global timerFrq:Int = 1000/30 ' 30 fps

' create an image buffer to store the screen in
Global screenBuffer:zImageBuffer = zImageBuffer.make(XRES,YRES)

' create an image buffer used for the magnification frame
Global tmpImg:zImageBuffer = zImageBuffer.make(62,62)


Const hxres:Int=XRES/2
Const hyres:Int=YRES/2

Local ang:Float=0.0
Local c:Int,xo:Int,yo:Int,y:Int,x:Int,i:Int,j:Int

Repeat

' clear screen buffer
screenBuffer.clear()

ang=ang+0.75
c=750*Cos(ang)
xo=200+200*Sin(ang*2)
yo=200+200*Cos(ang*3)
For y=0 To yres-1
For x=0 To xres-192
i=x+xo-hxres
j=y+yo-hyres
screenBuffer.setpixel(x,y,(((i+j*c/256) & 255) ~ ((j-i*c/256) & 255)),0,0,255)
Next
Next

' copy rects from screen buffer to temporary buffers
tmpImg.copyrectblock(screenBuffer,288,208,62,62,0,0)
' draw temporary buffers scaled to the screen buffer
tmpImg.drawScaledBlock(screenBuffer,xres-188,4,3.0,3.0)
tmpImg.drawScaledBlock(screenBuffer,xres-188,204,3.0,3.0)
tmpImg.drawScaledBlock(screenBuffer,xres-188,yres-191,3.0,3.0)
' draw screenbuffer to the screen
screenBuffer.blitToScreen()
Flip

While MilliSecs() < timerUpd+timerFrq
Wend
timerUpd = MilliSecs()

Until KeyDown(KEY_ESCAPE)
End

hehe notice I have a clear screen in there that I dont even thing I need :P

cheers
Jon

15
Yeah I know its a cheap effect but I was having a look at zawrans software render framework for bmax and thought I would have a go at coding a rotozoom in it, which I then take a sample from and magnify about 5x and draw down the right hand side. It works well and runs pretty fast at my end for a 800x600 screen, hopefully it will work for everyone at a decent rate. Zawrans framework has some very cool functions so this is I guess a TTD entry since it combines code from us both :D


16
While looking over my coding archives I came across several projects that I started but for one reason or another never finished and wish that I had. Of all the little games, demo effects and apps that I have made as well as the ones that I never finish the one that each time I look at it I wish I had is my giana sisters remake in blitzbasic (pre-blitz3d era), I spent many hours on that project which did include playing the amiga and atari ST versions alot :D

I actually got fairly far in some respects, while I had for the most part ripped the gfx from the 16bit versions and rescaled and touched up a few so that I had something to use in game, the game was playable, has several levels mapped out. Features enemy's, collectables and even some of the bonus blocks. It lacked a little something in the movement as I had no momentum and you couldn't headbash blocks to break them at the point I stopped work on it but at the time I was doing very well. I am not sure why I stopped work on it, probably to code my entries to the 2003 retro remakes comp, but for some reason I never went back to it.

Now when I look at the code I can hardly believe that I even wrote it, there's hardly any useful comments and I didnt have a single function/procedure in the entire code, everything is done with gosubs. It's such a mess that I would be much better off starting again from scratch if I decided to give it another go, but this was one of my very early coded games and its cool to see how much my coding standard has improved over the years, some of which is thanks to people on here and the old ezboard site from wayback when  :D

Any of you have a project like this were you started but never finished and wish you had?

Oh and here's a screenie from the giana game, maybe 1day i will have another go at it  ;D


17
I havent had much time to code so I pulled this from some very old code I had made ages ago, sorry for the large exe size but its compiled using b3d as I havent converted it to bmax. Would need a lib like zawrans framework due to how I am copyrect alot from an image buffer anyway  ;)


18
Blitz / [BMAX]Oldskool stars in a box
« on: April 03, 2009 »
Was going over old code archives and found a fun little routine from my early attempts at demos effects, decided to quickly convert this one to bmax as it's one of those effects I always liked :)

Code: [Select]
Const xres=1024
Const yres=768

Graphics xres,yres,0


Global numpoints ' Number of points in the point table.
Global numconn ' Number of connections in the connect table.
Global distance  = 250 ' Used to calculate perspective.
Global rotx# ' X rotation.
Global roty# ' Y rotation.
Global rotz# ' Z rotation.
Global angle#=0.5 ' Rotation angle speed
Global centrex=xres/2 ' Centre offset x
Global centrey=yres/2 ' Centre offset y
Global numstars=300 ' Number of stars in 3d field

' Read data for 3d.
ReadData numpoints ' Read in the number of points in the object
Global points[numpoints+1, 3] ' Holds the point locations of the  3d object.
Global xpos[numpoints+1]
Global ypos[numpoints+1]
For n = 1 To numpoints
ReadData x, y, z
points(n, 0) = x
points(n, 1) = y
points(n, 2) = z
Next
ReadData numconn ' Read in the numer of connections in the 3d object
Global lines[numconn+1, 2] ' Holds the connections of the 3d a to b.
For n = 1 To numconn
ReadData a, b
lines(n, 0) = a
lines(n, 1) = b
Next

' Data for starfield
Global starx[numstars+1]
Global stary[numstars+1]
Global starz[numstars+1]
Global speed[numstars+1]
For lop=0 To numstars
starx(lop)=Rnd(-149,149)
stary(lop)=Rnd(-74,74)
starz(lop)=Rnd(-49,49)
speed(lop)=1+(lop Mod 3)
Next

' ------------------ Main Loop
Repeat
Cls
box3d()
star3d()
Flip
' Update rotation angles
rotx# =(rotx# + angle#) Mod 360
roty# =(roty# + angle#) Mod 360
rotz# =(rotz# + angle#) Mod 360
Until KeyDown(KEY_ESCAPE) Or MouseDown(1)
End
' ------------------ End main loop

' --- This rotates and draws the box
Function box3d()
SetColor 0,255,255
For n = 1 To numpoints
x = points(n, 0)
y = points(n, 1)
z = points(n, 2)
        ' X rotation
ty# = ((y * Cos(rotx#)) - (z * Sin(rotx#)))
tz# = ((y * Sin(rotx#)) + (z * Cos(rotx#)))
' Y rotation
tx# = ((x * Cos(roty#)) - (tz# * Sin(roty#)))
tz# = ((x * Sin(roty#)) + (tz# * Cos(roty#)))
' Z rotation
ox# = tx#
tx# = ((tx# * Cos(rotz#)) - (ty# * Sin(rotz#)))
ty# = ((ox# * Sin(rotz#)) + (ty# * Cos(rotz#)))
' Calculate new x and y location with perspective
'xpos(n)=(tx#*(distance/(distance+tz#)))+centrex
'ypos(n)=(ty#*(distance/(distance+tz#)))+centrey
xpos(n)=(tx#*(400/(distance+tz#)))+centrex
ypos(n)=(ty#*(400/(distance+tz#)))+centrey
Next
For n = 1 To numconn
DrawLine xpos(lines(n, 0)), ypos(lines(n, 0)),xpos(lines(n, 1)), ypos(lines(n, 1))
Next
End Function

' --- This rotates and draws the 3d starfield
Function star3d()
For n = 0 To numstars
x = starx(n)
y = stary(n)
z = starz(n)
        ' X rotation
ty# = ((y * Cos(rotx#)) - (z * Sin(rotx#)))
tz# = ((y * Sin(rotx#)) + (z * Cos(rotx#)))
' Y rotation
tx# = ((x * Cos(roty#)) - (tz# * Sin(roty#)))
tz# = ((x * Sin(roty#)) + (tz# * Cos(roty#)))
' Z rotation
ox# = tx#
tx# = ((tx# * Cos(rotz#)) - (ty# * Sin(rotz#)))
ty# = ((ox# * Sin(rotz#)) + (ty# * Cos(rotz#)))
' Calculate new x and y location with perspective
nx=(tx#*(400/(distance+tz#)))+centrex
ny=(ty#*(400/(distance+tz#)))+centrey
If speed(n)<2
SetColor 100,100,100
EndIf
If speed(n)=2
SetColor 175,175,175
EndIf
If speed(n)>2
SetColor 255,255,255
EndIf
If nx>0 And nx<xres
If ny>0 And ny<yres
Plot nx,ny
EndIf
EndIf
starx(n)=starx(n)+speed(n)
If starx(n)>149
starx(n)=-149
EndIf
Next
End Function

' Define a cube
DefData 8 ' Points in cube
DefData -150,-75,50
DefData 150,-75,50
DefData 150,-75,-50
DefData -150,-75,-50
DefData -150,75,50
DefData 150,75,50
DefData 150,75,-50
DefData -150,75,-50
DefData 12 ' Number of connecting lines
DefData 1,2
DefData 2,3
DefData 3,4
DefData 4,1
DefData 5,6
DefData 6,7
DefData 7,8
DefData 8,5
DefData 8,4
DefData 7,3
DefData 6,2
DefData 5,1

It's not the best code in the world but it does its job, shows how you can do some of those old wireframe 3d effects in bmax for those that havent coded them before as well :)

19
Well I made this vector clock for the time challenge but I cant think of anything really interesting to do with it since rotating it kinda makes it hard to read the time and spoils its usefulness as a clock. So here it is as a Clock  :)

Its rendered using a version of TTD's old vectorlib and seems to keep good time  :D


20
Projects / Blitzmax shader test
« on: March 21, 2009 »
As you know I have been coding an opengl engine in blitzmax, well I got stuck on something so decided to see if I could get GLSL shaders to work in bmax. Sfter hunting for information on shaders and how to use them in opengl I tired for several hours to work out first if bmax had all the calls available, which it does, I then spent several more hours learning how to call them in the right order with various degrees of success. Then I struggled on some more trying to work out how to get the shader code into the shaders, getting it in the right format proved more of a challenge than everything else, but finally life appeared on my screen :)

So here is a test.exe which shows that bmax can do shaders and that I managed to get one into it, it was hard work and its rather ugly code and I have no idea if I am cleaning up after myself when you exit correctly SO it might have a memory leak, but it should be right :)

The actually vertex and fragment shader code is from an example I got off the net since I have never coded a shader, there included in the archive since i could not get the code to compile if I added them to the exe, something else to sort out at some point :)





Pages: [1] 2 3