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 - Clyde

Pages: [1] 2 3 4 5 6 7 8 ... 14
C / C++ /C# / [c++] Bug In 3d
« on: November 01, 2014 »

I've converted a 3d thang ive been working on over from freebasic to cpp.

There's a weird drawing bug with the triangles at certain points as it rotates.

I'm scratching my brain cell as to how to fix it.  In basic, it works a charm.

So it got me thinking that it's to do with how floats are dealt with and rounding issues.
Should it be up or down, or even involve precision?  And which bits, the scanline and / or draw triangle bits;  there's some stuff in global - maths, that might be of use.

Thanks for your help and being a super star,

C / C++ /C# / [c++] Pointers And Classes
« on: October 24, 2014 »

I'm trying to use pointers with classes, but not alot of luck. I remember mentioned sometime ago about making them static, but not really sure on that.

The errors I'm graced with are:

cx0030: Error: expression cannot be evaluated

and then for every element / variables in that particular class, there are loads of question mark, eg. wwidth=??????, height=??????

Hugest of thanks for your time and any help.

General coding questions / [ogl] Omitting Black Pixels
« on: October 17, 2012 »

I really need a hand with making a texture on an object to not display black pixels / opaque
I don't want any colour blending, just for the background / mask colour to be invisible. The only sort of way to do it is to use glBlend, but that will blend. The aim is to display a logo on a quad, but it looks very lame with the background colour showing up.

The code is in freebasic format, but is gl related. Apologies for the slight mess, have been head scratching and trying different things for weeks for ideas on how to do it. Maybe there is something in the setting up of the texture, or it's the blend function types. There's quite a selection up gl's sleeves. It also uses 8 bit images and converts to 32 bit, have done this so later ron the exe size isn't so large when using bmp2raw.

Hugest Of Thanks,

General coding questions / Subdivided Cube
« on: May 24, 2012 »

I've made some progress on a subdivided / segmented cube that's made out of the idea of a segmented quad to form the sides. But the texture on the left side doesn't look right. I've compared this with a regular cube, and I believe the u's or v's need rotating 90 degrees to the right.

As far as I know the for loops are fine and don't need dabbling with. I've mucked about with al-sorts of ordering of the u and v positions in the addvertex parts, though not much luck.

Hopefully it's a case of altering the stuff to do with the pos_u0# and pos_v0#.

Code: [Select]
; Sub Divided Cube V9.9
; Created By Clyde^GVY 20/05/2012
Graphics3D 800,600,32,2
SetBuffer BackBuffer()

Dim textures(2)

Global camera
Global light
Global seg_cube

Global texture_image
Global texture_file$="media\this way up.bmp"


Function init()
   PositionEntity    ( camera, 0.0, 0.0, -10.0 )
   light=CreateLight( camera )
   texture_image   =LoadImage      ( texture_file$ )
   textures(0)      =LoadTexture   ( texture_file$ )
   textures(1)      =create_texture   ( 1, 1, $f0f0f0 )
   seg_cube      =create_segmented_cube   ( 4, 2, 3, 10.0, 10.0, 10.0 )
   PositionEntity   ( seg_cube, 0.0, 0.0, 50.0 )
   EntityTexture   ( seg_cube, textures(0) )

End Function

Function main()

   Local rx#= -45.0
   Local ry#=  45.0
   Local rz#=   0.0
   Local wire_mode%=0

   While Not KeyHit(1)
      WireFrame( wire_mode% )
      EntityTexture( seg_cube, textures( wire_mode% ) )
      RotateEntity( seg_cube, rx#, ry#, rz# )
      ; a = turn z axis.
      If KeyDown(30) Then rz#=rz#-0.25
      ; d = turn z axis.
      If KeyDown(32) Then rz#=rz#+0.25
      ; cursor up = up.
      If KeyDown(200) Then rx#=rx#+0.25
      ; cursor down = down.
      If KeyDown(208) Then rx#=rx#-0.25
      ; cursor left = left.
      If KeyDown(203) Then ry#=ry#-0.25
      ; cursor right = right.
      If KeyDown(205) Then ry#=ry#+0.25
      ; w = toggle wireframe.
      If KeyHit(17) Then wire_mode%=Not wire_mode%
      DrawImage( texture_image, 0, 0 )

End Function

Function create_segmented_cube( segs_x%, segs_y%, segs_z%, scale_x#, scale_y#, scale_z# )

   Local entity=CreateMesh()
   Local cube   =CreateSurface(entity)
   ; floats.
   Local pos_x0#=0.0, pos_y0#=0.0, pos_z0#=0.0
   Local pos_x1#=0.0, pos_y1#=0.0, pos_z1#=0.0
   Local pos_u0#=0.0, pos_v0#=0.0
   Local pos_u1#=0.0, pos_v1#=0.0
   Local div_u#=0.0
   Local div_v#=0.0
   Local xx#=0.0, yy#=0.0, zz#=0.0
   Local segs_xx#=Float(segs_x%)
   Local segs_yy#=Float(segs_y%)
   Local segs_zz#=Float(segs_z%)

   ; integers.
   Local x%=0, y%=0, z%=0
   Local v0%=0, v1%=0, v2%=0, v3%=0
   ; centering.
   Local cent_x#=-(( segs_xx# * scale_x# ) / 2.0 )
   Local cent_y#=-(( segs_yy# * scale_y# ) / 2.0 )
   Local cent_z#=-(( segs_zz# * scale_z# ) / 2.0 )
   Local left_side%   =1
   Local front_side%   =1
   Local top_side%      =1
   ; left side.
   If ( left_side%=1 ) Then
      div_u#= ( 1.0 / segs_yy# )
      div_v#= ( 1.0 / segs_zz# )

      For z%=0 To segs_z%-1
           For y%=0 To segs_y%-1
               pos_y0#=cent_y# + ( yy# * scale_y# )
               pos_z0#=cent_z# + ( zz# * scale_z# )
               pos_y1#=cent_y# + (( yy# + 1.0 ) * scale_y# )
               pos_z1#=cent_z# + (( zz# + 1.0 ) * scale_z# )

            pos_u0#=div_u# * yy#
            pos_v0#=div_v# * zz#
            pos_u1#=div_u# * ( yy# + 1.0 )
            pos_v1#=div_v# * ( zz# + 1.0 )
            v0%=AddVertex( cube, cent_x#, -pos_y1#, pos_z0#, -pos_u1#, -pos_v0# )
               v1%=AddVertex( cube, cent_x#, -pos_y0#, pos_z0#, -pos_u0#, -pos_v0# )
            v2%=AddVertex( cube, cent_x#, -pos_y0#, pos_z1#, -pos_u0#, -pos_v1# )
               v3%=AddVertex( cube, cent_x#, -pos_y1#, pos_z1#, -pos_u1#, -pos_v1# )

            AddTriangle( cube, v2%, v1%, v0% )
            AddTriangle( cube, v3%, v2%, v0% )
   End If
    ; front side.
   If ( front_side%=1 ) Then
      div_u#=( 1.0 / segs_xx# )
      div_v#=( 1.0 / segs_yy# )
      For y%=0 To segs_y%-1
           For x%=0 To segs_x%-1
               pos_x0#=cent_x#+ ( xx#        * scale_x# )
               pos_y0#=cent_y#+ ( yy#        * scale_y# )
               pos_x1#=cent_x#+(( xx#+1.0 ) * scale_x# )
               pos_y1#=cent_y#+(( yy#+1.0 ) * scale_y# )
               pos_u0#=div_u# * xx#
            pos_v0#=div_v# * yy#
            pos_u1#=div_u# * (xx#+1.0)
            pos_v1#=div_v# * (yy#+1.0)
               v0=AddVertex( cube, -pos_x0, -pos_y1, cent_z, -pos_u0, pos_v1 )
               v1=AddVertex( cube, -pos_x0, -pos_y0, cent_z, -pos_u0, pos_v0 )
               v2=AddVertex( cube, -pos_x1, -pos_y0, cent_z, -pos_u1, pos_v0 )
               v3=AddVertex( cube, -pos_x1, -pos_y1, cent_z, -pos_u1, pos_v1 )
            AddTriangle( cube, v2%, v1%, v0% )
            AddTriangle( cube, v3%, v2%, v0% )
   End If
    ; top side.
   If ( top_side%=1 ) Then

      div_u#=( 1.0 / segs_xx# )
      div_v#=( 1.0 / segs_zz# )

      For z%=0 To segs_z%-1
           For x%=0 To segs_x%-1
               pos_x0#=cent_x#+(  xx#        * scale_x# )
               pos_z0#=cent_z#+(  zz#        * scale_z# )
               pos_x1#=cent_x#+(( xx#+1.0 ) * scale_x# )
               pos_z1#=cent_z#+(( zz#+1.0 ) * scale_z# )
                pos_u0#=div_u# * xx#
            pos_v0#=div_v# * zz#
            pos_u1#=div_u# * (xx#+1.0)
            pos_v1#=div_v# * (zz#+1.0)

               v0%=AddVertex( cube, pos_x1#, -cent_y#, pos_z0#, pos_u1#, -pos_v0# )
               v1%=AddVertex( cube, pos_x0#, -cent_y#, pos_z0#, pos_u0#, -pos_v0# )
               v2%=AddVertex( cube, pos_x0#, -cent_y#, pos_z1#, pos_u0#, -pos_v1# )
               v3%=AddVertex( cube, pos_x1#, -cent_y#, pos_z1#, pos_u1#, -pos_v1# )
              AddTriangle( cube, v0%, v1%, v2% )
            AddTriangle( cube, v0%, v2%, v3% )

   End If
   UpdateNormals( entity )
   Return        ( entity )
End Function

Function create_texture( wwidth%, height%, colour% )
   Local x%=0, y%=0
   Local texture=CreateTexture( wwidth%, height% )

   SetBuffer       TextureBuffer( texture )
   LockBuffer       TextureBuffer( texture )
   For y%=0 To height%-1
      For x%=0 To wwidth%-1
         WritePixelFast( x%,y%, colour%, TextureBuffer( texture ) )
   UnlockBuffer    TextureBuffer( texture )
   SetBuffer       BackBuffer()

   Return texture

End Function

I know I've used b3d to illustrate the problem, but I shall be converting this over into a different language once sussed, so please no inbuilt b3d commands.

Cheers For The Help - Much Appreciated!!! :D

C / C++ /C# / Shader - Colours And Lighting.
« on: May 06, 2012 »

I've setup the lighting outside of the shader in the usual ways. And am finding my feet with simple stuffs. But am having problems with getting the final object to display with it's overall colour with the shader - including the light, entity and texture colours. I had a go with the following:

Code: [Select]

// vert shader
varying vec4 tex_coord;

void main()
   gl_Position      = gl_ModelViewProjectionMatrix * gl_Vertex;
   gl_TexCoord[0]   = tex_coord;//gl_MultiTexCoord0;


fragment shader:
Code: [Select]

// test_one_frag_shader

float light_colour;
float texture_colour;
float final_colour;

varying vec4 tex_coord;

uniform sampler2D texture;

void main()
   texture_colour   =texture2D( texture, tex_coord );
   light_colour   =gl_LightSource[0].ambient;

   final_colour   =texture_colour + light_colour;

   gl_FragColor   =final_colour;

If I just use: gl_FragColor=texture2D( texture, gl_TexCoord[0] ); then I get the object with it's texture, but no lighting. It's probably not as simple as what I thought; perhaps normals. Anyhelp, would be great!! :D

[edit] Or to put it another way, how do I get the lighting colour from lighting that I've already setup using GL_LIGHT0. And then incorporate that into the shader?


C / C++ /C# / Loading A Text File / Shader
« on: April 03, 2012 »
Dear Demo Dudes,

I've done a bit more in the cpp world with visual studio 2010. And am concentrating on loading text files with fstream.

As soon as I use the command glCreateShader( type ); it will throw up that the loading and size code is bugged, but I don't know why that is, as if it's left commented out it goes through. Perhaps, there's another lib I need to include in the project properties.

Cheers in advanced,

General coding questions / Object Orientation
« on: March 14, 2012 »
Dear DBF Interactive,

I am tinkering around with an idea, but am stuck with rotating the objects so they resemble that of a dial.

Imagine a clock face with markers, a volume control, or better still the rays of a sun. Maybe cog teeth would be a better example, as that is an idea i've had floating about for eons. Where each bit is set at an angle as they go around.

I've got the positions worked out with sin and cos and 360.0f / amount_of_markers.
but the divide markers are not equally spread; best to imagine a clock face, 3 6 9 12.

I have compiled and added at blitz3d example of it so far. I hope you get what I'm waffling on about.

Nice to see you again, and many thanks.

Freebasic / Position Checker
« on: October 24, 2010 »
With this I'd like it so that any newly created ovals do not occupy the same positions / space as an existing ones. I'm having problems in the position check function
srce + exe attached, uses tinyptc_ext and deprecated.
Thanks for your time and help,

My team are moaning at me as they've got widescreen HD monitors and I haven't ( not fair, hehe )

How would in this framework allow for 4:3 / 16:9 displays?
And are these the common aspect ratios? What would those settings be too, if they are used.

Many thanks,

General chat / Prods with long titles
« on: October 10, 2010 »
Have you seen or know of any demo scene releases with pretty long names?
take care,

C / C++ /C# / Resource Menu System
« on: September 23, 2010 »
Wonder if you could help with an example of making a menu system with radio buttons and check boxes with a resource.
I'd like to link it with the ogl textured cube routines and jims tinyptc d3d lib.

I'd be really stuck on how to make choice1=option1 or option2, etc.

here's an example I knocked up in notepad:
Code: [Select]
 =        =
 = image goes in here  =
 =        =
 option 1 ( )
 option 2 (0)
 fullscreen [/]
 =========  ========
 = start =  = exit =
 =========  ========

Cheers and hugest of thanks,

General chat / In A Word - Monitors
« on: September 22, 2010 »
I've had my Vision Master Pro 410 monitor for what seems like a life time.
And it's about time to invest into a new one. I wonder if you could recommend to me, some good makers?
I'm not sure on High Definition / LED, as it sounds as if I would maybe need to also update my Nvidia 7600gs graphics card, and wether a geforce9 will fit into my PC / PCI-e. Though I've always wanted a slimmer VDU! Im thinking of somewhere between 20-24 inch.

C / C++ /C# / OGL: Loading Images From Memory
« on: September 22, 2010 »
I've seen how to load bmps from a file.
However I'm having a bit of bother.

I'd like to using the method I've used previously of a gfx_buffer class and rbz's bmp2raw / bin2c, to load and create images from memory.
some code to illustrate.
Code: [Select]
#include "media\image_raw.cpp"
#include "media\image_pal.cpp"
class gfx_buffer
 int wwidth, height;
 unsigned int *pixels;

void load_texture()
 texture_one=create_gfx_buffer(128,128);//load_gfx_buffer( image_pal, image_raw, 128, 128 );
 for ( int x=0; x<128; x++ )
  for ( int y=0; y<128; y++)
   texture_one->pixels[ x+y*texture_one->wwidth ]=0xff00f0;
 glGenTextures(1, &texture_one->pixels[0]);     // Create The Texture
 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
 glBindTexture(GL_TEXTURE_2D, texture_one->pixels[0]);

gfx_buffer *create_gfx_buffer( int wwidth, int height, unsigned int mask_colour=0 )
 gfx_buffer *buffer = new gfx_buffer;
 buffer->pixels = new unsigned int [wwidth*height];
 buffer->wwidth = wwidth;
 buffer->height = height;
 return buffer;


C / C++ /C# / Using Pivots In OGL
« on: September 21, 2010 »
I havent forgotten about Jim's ptc / Direct X library. Im toying between the two sides software and hardware.
Now that I've got VC++ Express 2010 installed, I thought I'd try a bit of Open GL for a change, and Im going to try and best explain this problem.
In Blitz3D you'd use a pivot to control a group of entitys; so they rotate / turn at the same ratios, and say for example you wanted them all to slope down. All the children dance the same manner.
What I'd like to know is how to incorparate such a thing.
I've whipped up a bit of psuedo code, if it's helpfull.
Code: [Select]
void update_cubes( cube_pivot )
 for ( int a=0; a<MAX_CUBES; a++ )
  render_flat_shaded_cubes( cube_pivot, flt_pos_x[a], flt_pos_y[a], flt_pos_z[a],1.0f,1.0f,1.0f );
void render_flat_shaded_cubes( control_pivot, float pos_x, float pos_y, float pos_z, float scale_x, float scale_y, float scale_z )
 // set positions.
 glTranslatef( pos_x, pos_y, pos_z );     
 //glRotatef ( angle_x,1.0f,0.60f,0.80f); 
 glBegin(GL_QUADS);      // Draw A Quad
  // 1st side
  glVertex3f( -scale_x,-scale_y,-scale_z );// 0,1)
  glVertex3f( -scale_x, scale_y,-scale_z );//, 0,0)
  glVertex3f(  scale_x, scale_y,-scale_z );//, 1,0)
  glVertex3f(  scale_x,-scale_y,-scale_z );//, 1,1)
  // 2nd side
  glVertex3f(-scale_x,-scale_y,  scale_z);    // Top Left
  glVertex3f(-scale_x, scale_y,  scale_z);    // Top Right
  glVertex3f(-scale_x, scale_y, -scale_z);    // Bottom Right
  glVertex3f(-scale_x,-scale_y, -scale_z);    // Bottom Left
  // 3rd side.
  glVertex3f( scale_x,-scale_y, scale_z);    // Top Left
  glVertex3f( scale_x, scale_y, scale_z);    // Top Right
  glVertex3f(-scale_x, scale_y, scale_z);    // Bottom Right
  glVertex3f(-scale_x,-scale_y, scale_z);    // Bottom Left
  // 4th side.
  glVertex3f( scale_x,-scale_y, -scale_z);    // Top Left
  glVertex3f( scale_x, scale_y, -scale_z);    // Top Right
  glVertex3f( scale_x, scale_y,  scale_z);    // Bottom Right
  glVertex3f( scale_x,-scale_y,  scale_z);    // Bottom Left
  // 5th side.
  glVertex3f( -scale_x, scale_y, -scale_z);    // Top Left
  glVertex3f( -scale_x, scale_y,  scale_z);    // Top Right
  glVertex3f(  scale_x, scale_y,  scale_z);    // Bottom Right
  glVertex3f(  scale_x, scale_y, -scale_z);    // Bottom Left
  // 6th side.
  glVertex3f( -scale_x, -scale_y,  scale_z);    // Top Left
  glVertex3f( -scale_x, -scale_y, -scale_z);    // Top Right
  glVertex3f(  scale_x, -scale_y, -scale_z);    // Bottom Right
  glVertex3f(  scale_x, -scale_y,  scale_z);    // Bottom Left

Cheers all!

General chat / Todays Games
« on: August 06, 2010 »
A little rant, as the screenshots look amazing!

I've just bought some games for the PC recently which I haven't done for eons, the last game I bought was World Of Warcraft.

And you know what I am totally disgusted as no effort what so ever, has been made to make them PC friendly and use any peripherals, as they are straight "no effort" optimizing. I always thought that games were developed on PC's and then ported, so what the beggars going on.

further more, You cannot customize the keys on a few of them, and you need an xbox 360 controller if you find the keys frustrating.

I think it's a shame that in the move to fill the software giants pockets, they can hurry out a quick buck release.

I'm sending them back as really dissappointing.

is there a game you've saved up for and then been let down?

Useful links / PC Demoscene FAQ
« on: July 23, 2010 »
Quite usefull I thought, especially for new talents wanting some info on demoscene.

I've never had any luck with this ( installing a HD and WorkBench), if anyone knows how to run aga demos,could you give steps on what to do please? Also I don't want to muck up my pc.
Muchos Gracias Amigas,

General chat / Border Surrounding Projects
« on: May 09, 2010 »
Yo Dudes!
I don't know if this happens to you at all, but when ever I run my project antics. There is this thick-ish border around the display it looks like a polaroid photo. And what I'd like to do and know is, if there's a setting or some ting to banish it?
I generally get this in freebasic and now cpp, but not in Blitz 3D or Plus. Would be groovy to put a stop to it, if it's at all possible, maybe there's a setting on the graphics card (nvidia) or it's being emulated.
Thanks for listening and many thanks,

C / C++ /C# / [C++] Conflicting Issues pt 1
« on: April 29, 2010 »
strange thing happend to me Today, the proggie I was working on worked in the sense of it rendering and updating etc. I added a new function which only dealt with a different way of making a colour palette, and then everything went tits up. I have even removed that function. And im wondering if ive found a gremlin again.
im using the usual suspects from my previous adventures w/2008, tinyptc, libmmx, MSVCRTS. Im getting these in the build dialog ( btw using MSVC++ 2010 express )
Quote from: Bob The Builder Report
1>------ Build started: Project: Wicked Plasma, Configuration: Release Win32 ------
1> wicked plasma 1-1.cpp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1> Generating code
1> Finished generating code
1>MSVCRTS.lib(cinitexe.obj) : warning LNK4254: section '.CRT' (40000040) merged into '.data' (C0000040) with different attributes
1>MSVCRTS.lib(cinitexe.obj) : warning LNK4254: section '.CRT' (40000040) merged into '.data' (C0000040) with different attributes
1> Wicked Plasma.vcxproj -> C:Documents and SettingsClydemy documentsvisual studio 2010ProjectsWicked PlasmaReleaseWicked Plasma.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I wondered if anyone had any ideas,
Cheers and all the very best,

C / C++ /C# / [C++] Conversion Blues
« on: April 29, 2010 »
Been racking my brains in order to get the conversion right in C++ 2010, from blitz which for sin and cos returns a degrees (PI/180.0)
Each time I try, it gets further from the original. hehe.
And I'd be thrilled to see it sorted. :D
b3d code:
% = integer
# = float
Code: [Select]

for y=0 to h-1
for x=0 to w-1
col1=128+128* ( Sin(Sqr((x%-w2%)*(x%-w2%)+(y%-h2%)*(y%-h2%))*1.23#) )

my lastest conversion attempt in c++ 2010
Code: [Select]
c1=(float) (128.0f+128.0f) * ( sinf( sqrt(float( (x-w2)*(x-w2)+(y-h2)*(yy-h2))*1.23)));//*DEGREES);

Pages: [1] 2 3 4 5 6 7 8 ... 14