[win32] Teh Toon [intro]

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
xperience2003
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Oct 05, 2004 9:05 pm
Location: germany
Contact:

[win32] Teh Toon [intro]

Post by xperience2003 »

small toon-styled intro just for fun
Image

download 83kb

HAVE FUN =)
User avatar
Peace
User
User
Posts: 14
Joined: Sun Aug 10, 2008 12:14 pm
Location: Then
Contact:

Re: [win32] Teh Toon [intro]

Post by Peace »

very cool intro, runs fine here!
hope you'll "insert Disk 2" very soon :wink:
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: [win32] Teh Toon [intro]

Post by flaith »

Where is Mario :D
Nice intro, congrats :mrgreen:
“Fear is a reaction. Courage is a decision.” - WC
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: [win32] Teh Toon [intro]

Post by djes »

Cool!!! Where is the first tristar demo I've seen, want to see it again! :D
Zach
Addict
Addict
Posts: 1676
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: [win32] Teh Toon [intro]

Post by Zach »

I gotta do something like this one day :oops:
xperience2003
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Oct 05, 2004 9:05 pm
Location: germany
Contact:

Re: [win32] Teh Toon [intro]

Post by xperience2003 »

code of the torus part

Code: Select all


TLInit()
TLOpenScreen(800,600,32,".:teh toon:.  .:xP^Trs:.") 

If GLSL_InitShaders()=0
 MessageRequester("error","shader nicht verfuegbar")
 End
EndIf 

;erstelle shadercontext 
Vertex.s = PeekS(?Shader_Vertex, ?EndShader_Vertex - ?Shader_Vertex)
Pixel.s =  PeekS(?Shader_Pixel,  ?EndShader_Pixel - ?Shader_Pixel)
glslVertexShader = GLSL_CreateVertexShader(Vertex.s)
glslPixelShader  = GLSL_CreatePixelShader(Pixel.s)
glslContext      = GLSL_CreateProgramObject()

;fuege die geladenen und erstellten shader dem context zu
GLSL_AttachObject(glslContext, glslVertexShader)
GLSL_AttachObject(glslContext, glslPixelShader)
GLSL_LinkProgram(glslContext)

;finde die variablen im shaderprogramm
color0loc=GLSL_GetUniformLocation(glslContext,"color0")
color1loc=GLSL_GetUniformLocation(glslContext,"color1")
color2loc=GLSL_GetUniformLocation(glslContext,"color2")
color3loc=GLSL_GetUniformLocation(glslContext,"color3")
color4loc=GLSL_GetUniformLocation(glslContext,"color4")

Dim scenetoru.f(9)
For i=0 To 9
scenetoru.f(i)=-i*3
Next


;framegrenze
Global fps, dtime, stime             ;fuer die framegrenze
fps = 80
dtime = 1000.0 / fps 

TLFogColor(0.8,0.76,1.0,1.0)

Repeat
 If ElapsedMilliseconds() - stime > dtime 
  jo.f+0.6:jo2.f+1.6
  
  TLScreenMode2D(800,600)
  TLClearColor(0.8,0.7,0.5,1.0): TLCls()
  TLMeshCullingOff()
  For i= 0 To 10
   TLPolygon2D(250,550,TLSin(jo+(i*36))*820+250,TLCos(jo+(i*36))*820+550,TLSin(jo+10+(i*36))*820+250,TLCos(jo+10+(i*36))*820+550,0.9,0.8,0.6,1.0)
  Next
 
  TLScreenMode3D(800,600,350,45) 
  TLMeshCullingOn()
  TLPlotterReset()
  
  For i=0 To 9
    scenetoru.f(i)+0.1
    If scenetoru.f(i)>3:scenetoru.f(i)=-27:EndIf
  Next
  TLPlotterSave()
  TLPlotterMove(5,2,-9)
  TLPlotterRotateY(35)
  TLPlotterRotateX(-35)
  TLPlotterRotateZ(jo)
 
  ;shader "anwerfen"
  GLSL_UseProgramObject(glslContext) 
  TLPlotterSave() 
  For i=0 To 9
    TLPlotterRotateZ(90)
   Select i
   Case 0,5
    ;hier neue werte in die variablen reinschreiben
    GLSL_SendUniform4f(color0loc, 1.0, 0.0,1.0,1.0) ;vorn
    GLSL_SendUniform4f(color1loc, 0.8, 0.0,0.8,1.0)
    GLSL_SendUniform4f(color2loc, 0.7, 0.0,0.7,1.0)
    GLSL_SendUniform4f(color3loc, 0.5, 0.0,0.5,1.0)
    GLSL_SendUniform4f(color4loc, 0.3, 0.0,0.3,1.0) ;hinten
   Case 1,6
    GLSL_SendUniform4f(color0loc, 0.0, 1.0,1.0,1.0) ;vorn
    GLSL_SendUniform4f(color1loc, 0.0, 0.8,0.8,1.0)
    GLSL_SendUniform4f(color2loc, 0.0, 0.6,0.7,1.0)
    GLSL_SendUniform4f(color3loc, 0.0, 0.4,0.5,1.0)
    GLSL_SendUniform4f(color4loc, 0.0, 0.3,0.3,1.0) ;hinten
   Case 2,7
    GLSL_SendUniform4f(color0loc, 0.8, 0.9,1.0,1.0) ;vorn
    GLSL_SendUniform4f(color1loc, 0.7, 0.7,0.8,1.0)
    GLSL_SendUniform4f(color2loc, 0.5, 0.5,0.7,1.0)
    GLSL_SendUniform4f(color3loc, 0.4, 0.3,0.5,1.0)
    GLSL_SendUniform4f(color4loc, 0.2, 0.1,0.3,1.0) ;hinten
   Case 3,8
    GLSL_SendUniform4f(color0loc, 0.2, 0.9,1.0,1.0) ;vorn
    GLSL_SendUniform4f(color1loc, 0.2, 0.7,0.8,1.0)
    GLSL_SendUniform4f(color2loc, 0.1, 0.5,0.7,1.0)
    GLSL_SendUniform4f(color3loc, 0.1, 0.3,0.5,1.0)
    GLSL_SendUniform4f(color4loc, 0.0, 0.1,0.3,1.0) ;hinten   
   Case 4,9
    GLSL_SendUniform4f(color0loc, 0.9, 0.5,0.0,1.0) ;vorn
    GLSL_SendUniform4f(color1loc, 0.8, 0.4,0.0,1.0)
    GLSL_SendUniform4f(color2loc, 0.7, 0.2,0.0,1.0)
    GLSL_SendUniform4f(color3loc, 0.6, 0.1,0.0,1.0)
    GLSL_SendUniform4f(color4loc, 0.2, 0.1,0.0,1.0) ;hinten
  EndSelect 
   TLPlotterSave() 
   TLPlotterMove(0,0,scenetoru.f(i))
   TLPlotterRotateX(90)  
   TLRender3DSmoothTorus(0, 0, 0, 0.5, 2,22,22)
   TLPlotterLoad() 
  Next
  TLPlotterLoad() 

  GLSL_UseProgramObject(0)  
  TLPlotterLoad() 
  
   TLFlipbuffers()
  stime = ElapsedMilliseconds()
EndIf
       
 event=WindowEvent()
 Delay(1)
Until GetAsyncKeyState_(#VK_ESCAPE)     ;linke mouse geklickt?

  
GLSL_DeleteObject(glslPixelShader)
GLSL_DeleteObject(glslVertexShader)
GLSL_DeleteObject(glslContext)
TLCloseScreen()                  ;bildschirm schliessen
End

DataSection
  Shader_Pixel:
    IncludeBinary "toonf2b.frag"
  EndShader_Pixel:
  Shader_Vertex:
    IncludeBinary "toonf2.vert"
  EndShader_Vertex:
EndDataSection

toonf2b.frag

Code: Select all

// TLib Toonshader by jhd^daWn
varying vec3 lightDir,normal;
uniform vec4 color0;
uniform vec4 color1;
uniform vec4 color2;
uniform vec4 color3;
uniform vec4 color4;

void main()
{
	float intensity;
	vec4 color;
	vec3 l = normalize(vec3(gl_LightSource[0].position));
	vec3 n = normalize(normal);
	intensity = dot(l,n);
	if (intensity > 0.95)
		color = color0;
	else if (intensity > 0.8)
		color = color1;
      else if (intensity > 0.6)
		color = color2;
      else if (intensity > 0.4)
		color = color3;
	else if (intensity > 0.15)
		color = color4;
	else
		color = vec4(0.01,0.01,0.01,1.0);
	gl_FragColor = color;
} 

toonf2.vert

Code: Select all

// TLib Toonshader by jhd^daWn
varying vec3 lightDir,normal;
void main()
{
	lightDir = normalize(vec3(gl_LightSource[0].position));
	normal = gl_NormalMatrix * gl_Normal;
	gl_Position = ftransform();
} 


..and the lib..copy to pure userlibs drawer
i use pb 4.2 the lib doesn't work with the new pb version

download 80kb

,,sry..no description for the lib..maybe later..maybe never..maybe ask by pm

HAVE FUN =)
Post Reply