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.


Messages - neumanix

Pages: [1]
1
Nice one!
I was amazed at how effective the UPX compressor is. I compiled in v4.51, got an exe of 1.55MB and UPX shrunk it to 60Kb.
How did you get it to 47Kb btw? Older version of PB?

2
Freebasic / Re: Making tiny FB executable programs
« on: August 30, 2007 »
ok, I solved the problem that I had... I didn't undertand that there has to be a function called "WinMainCRTStartup" in your code.
But now I get other linking errors, some kind of rnd stuff. I guess that's because I used RND which is a freebasic command.
I'll try some more to get the glfw code to work. I'll need a static glfw.lib I guess, gonna try to figure out how to make one :)

3
Freebasic / Re: Making tiny FB executable programs
« on: August 30, 2007 »
I tried this with a couple of programs, one using tinyptc and one using glfw. On both attempts I get a linker error that says "could not find symbol WinMainCRTStartup".
What am i missing here?!

4
Paul, it seems that you have Vsync set to "always off" in the gfx driver. That's not such a good idea. If you set it to "default on" or "application preferable" or somethink like that and add the following to the code:

Code: [Select]
glfwopenwindowhint(glfw_refresh_rate, 60) ' 60Hz refresh !!! OBS, försiktigt här så man inte pajar skärmen !!!

if glfwopenwindow(gfxw,gfxh,0,0,0,0,0,0,glfw_fullscreen)=0 then ' nollorna = låt GL bestämma rgb,alpha,depth,static bits. Annars 8,8,8,8,24,8
   glfwterminate()
    end -1
endif

glfwswapinterval(1) ' WAIT FOR VERTICAL RETRACE!!!

The first line set's the refresh rate, it's optional but use if you want to set an exact rate

The last line turns Vsync on.

Let me know if this works for you.

This should work with the driver set to anything BUT "always off"

p.s. jag är finlandssvensk, bor i Finland, snackar svenska :)



5
Thanks Clyde! Yes, I hope it will be useful. Although I'm quite new to both OpenGL and Freebasic, I can see some potential in GLFW.
I know that producing small exes is important for many, and I find it challenging too, although being a rookie :)

It will sure take a while before I can produce something intro-like, but I'll try to learn as much as possible.

More about GLFW... it supports keyboard, mouse and joystick input, high precision timers, opengl extensions, image/texture loading (although only .tga) and even
some fancy stuff like multithreading. There are functions for setting refresh rate and enabling/disabling Vsync and lots more.

There are some good user and reference guides in .pdf format on the website. It is C syntax but that's quite easy to translate to FB.

Gotta go play with this some more now...

6
Sure, here is the source as well. Just found out about the glfwGetMousePos function, so I implemented that as well :)
For some reason it now compiled even smaller, 25K! And compressed to 10K!!!

Btw, never mind the corny swedish comments in the source... if you're not swedish ofcourse :)

Code: [Select]
#include "gl/glfw.bi"

const gfxw = 640
const gfxh = 480

declare sub cube()
declare sub plane()

dim as integer sphere_rot, mx, my


'---------------------------------------------------------------
'Här följer init-koden. No more gfxlib!!!
'---------------------------------------------------------------
glfwinit()
if glfwopenwindow(gfxw,gfxh,8,8,8,8,24,8,glfw_fullscreen)=0 then
   glfwterminate()
    end -1
endif


glviewport 0,0,gfxw,gfxh ' så att GL och skärmen stämmer överens

glmatrixmode gl_projection ' välj projection matrix
glloadidentity ' och nollställ den

gluperspective 45.0 , gfxw/gfxh , 0.1 , 100.0 ' nice perspective (gfxw/gfxh+.2 för full widescreen)

glmatrixmode gl_modelview ' välj modelview matrix
glloadidentity ' och nollställ den också

glshademodel gl_smooth ' sätt på smooth shading

glenable gl_depth_test ' på med depth testing
gldepthfunc gl_lequal
glcleardepth 1.0

glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ' ännu finare perspective

glenable gl_cull_face

'--------------------------------------------------------
'---------LIGHTING SETUP---------------------------------
'--------------------------------------------------------
dim ambient_light(3) as single = {0.5 , 0.7 , 1.0 , 1.0}
dim diffuse_light(3) as single = {1.0 , 1.0 , 1.0 , 1.0}
dim light1_pos(3) as single = {0.0 , 0.0 , 5.0 , 1.0}

dim sphere_light_diffuse(3) as single = {1.0 , 0.0 , 0.0 , 1.0}

gllightfv gl_light1, gl_ambient, @ambient_light(0)
gllightfv gl_light1, gl_position, @light1_pos(0)
gllightfv gl_light1, gl_diffuse, @diffuse_light(0)
glLightf gl_light1, gl_constant_attenuation, 1.0

glenable gl_lighting
glenable gl_light1

glenable gl_blend
glBlendFunc gl_src_color , gl_one

glenable gl_color_material ' color tracking på
glcolormaterial gl_front , gl_ambient_and_diffuse

'---------------------------------------------------------------------------
'----------DET VAR INITIALISERINGEN, NEDAN FÖLJER HUVUDLOOPEN---------------
'---------------------------------------------------------------------------


while not glfwgetkey(glfw_key_esc) and glfwGetWindowParam(GLFW_OPENED)
    glclear gl_color_buffer_bit or gl_depth_buffer_bit ' CLS
    glloadidentity
    glfwgetmousepos(@mx,@my)
    glcolor3f 0.5 , 0.5 , 0.5
    plane()
    gltranslatef -0.5,0,-5
    glrotatef mx,0,1,0
    glrotatef my,1,0,0
    glcolor3f 0.5 , 0.5 , 1.0
    cube()
    glloadidentity
    gltranslatef 2.0 , 0 , -5
    glrotatef sphere_rot,0,1,1
    glcolor3f 1.0 , 0.5 , 0.5
    glusphere glunewquadric, 0.5 , 3 , 16
    glflush
    sphere_rot=sphere_rot+1
    if sphere_rot>360 then sphere_rot=sphere_rot-360
    'flip
    glfwswapbuffers()
wend
glfwterminate()
end

'---------------------------------------------
' för front facing quads, sätt vertices "motsols", alltså counter-clockwise
' föreställ att man står framför quaden i 3d space
'-------------------------------------------------

sub cube()
    glbegin gl_quads
    'top
        glnormal3f 0.0 , 1.0 , 0.0
        glvertex3f -1.0 , 1.0 , 1.0
        glvertex3f 1.0 , 1.0 , 1.0
        glvertex3f 1.0 , 1.0 , -1.0
        glvertex3f -1.0 , 1.0 , -1.0
       
    'bottom
        glnormal3f 0.0 , -1.0 , 0.0
        glvertex3f -1.0 , -1.0 , -1.0
        glvertex3f 1.0 , -1.0 , -1.0
        glvertex3f 1.0 , -1.0 , 1.0
        glvertex3f -1.0 , -1.0 , 1.0
    ' left
        glnormal3f -1.0 , 0.0 , 0.0
        glvertex3f -1.0 , 1.0 , 1.0
        glvertex3f -1.0 , 1.0 , -1.0
        glvertex3f -1.0 , -1.0 , -1.0
        glvertex3f -1.0 , -1.0 , 1.0
    ' right
        glnormal3f 1.0 , 0.0 , 0.0
        glvertex3f 1.0 , 1.0 , 1.0
        glvertex3f 1.0 , -1.0 , 1.0
        glvertex3f 1.0 , -1.0 , -1.0
        glvertex3f 1.0 , 1.0 , -1.0
    ' front
        glnormal3f 0.0 , 0.0 , 1.0
        glvertex3f -1.0 , 1.0 , 1.0
        glvertex3f -1.0 , -1.0 , 1.0
        glvertex3f 1.0 , -1.0 , 1.0
        glvertex3f 1.0 , 1.0 , 1.0
    ' back
        glnormal3f 0.0 , 0.0 , -1.0
        glvertex3f 1.0 , 1.0 , -1.0
        glvertex3f 1.0 , -1.0 , -1.0
        glvertex3f -1.0 , -1.0 , -1.0
        glvertex3f -1.0 , 1.0 , -1.0
    glend
end sub

sub plane()
    glbegin gl_polygon
        glvertex3f 1.0 , -5.0 , 0.0
        glvertex3f 30.0 , -5.0 , -50.0
        glvertex3f -30.0 , -5.0 , -50.0
        glvertex3f -1.0 , -5.0 , 0.0
    glend
end sub



7
Freebasic / GLFW OpenGL framework (pretty cool!)
« on: April 13, 2007 »
Hi everyone! I've been playing around with some OpenGL and found it quite annoying to have to use Screen or Screenres to open a screen that OpenGL can use.
I guess it loads the whole gfxlib when you just need one function. The resulting .exe gets bloated, although comresses to around 50K or so, but that's still a lot if you want to do a 64K intro or something.

So... I searched around a bit and suddenly found someone here using GLFW. I searched the forum and didn't find any discussion about GLFW so I decided to give this tip... might be
useful for some of you.

GLFW is a framework that has alot of neat features, just visit http://glfw.sourceforge.net/ and read all about it.

The incude file and lib should already be in your FREEBASIC folders.

A little example:

Code: [Select]

#include "gl/glfw.bi" ' also includes "gl.bi" and "glu.bi" automatically

glfwinit()
if glfwopenwindow(640,480,8,8,8,8,32,8,glfw_fullscreen)=0 then  ' glfw_window for windowed mode
   glfwterminate()
    end -1
endif


' normal OpenGL setup follow here

while not glfwgetkey(glfw_key_esc) and glfwGetWindowParam(GLFW_OPENED)
   
     ' do your stuff

     glfwswapbuffers() ' use instead of flip

wend

glfwterminate()
end


Using this results in a much smaller .exe.  I did a simple program with a few spinning objects and it compiled to 32K and compressed to 13K using kkrunchy!

I hope this is good news for someone :)

8
Freebasic / Re: Clearing the screen using TinyPTC
« on: January 03, 2007 »
@Shockwave, I don't know if you missed my reply, but the mod you made didn't work. It runs for a second then crashes.
Did it work for you DrewPee?

9
Freebasic / Re: Clearing the screen using TinyPTC
« on: January 03, 2007 »
Yes I tried that but it still crashes here. It runs for maybe a second, then crash.
Did the modification you made work on your computer? If so, it's a bit strange.

Thanks btw for your nice comment. I'm looking forward to learn more and maybe produce my first ever 64k intro :)
I know i'm a bit like you when it comes to those small exes :)

10
Freebasic / Clearing the screen using TinyPTC
« on: January 03, 2007 »
Hi everyone! I just started trying to get into this freebasic stuff, and it looks quite interesting!
I haven't done much coding for a long while so I'm a little rusty I might add.

I have some questions... What is the best way to clear the screenbuffer when you use tinyptc?
I have tried the redim array with option dynamic and that works well, but then I understood that one can use erase buffer on a static buffer as well. Here below is a simple 2d starscroller I just made. It works like this, but when I try the erase buffer method it crashes.

Also, is this the correct way to use types. In blitz there was the for...each method, but no such thing seems to exist in FB.

This is not much, but maybe it can be helpful to other beginners like myself.

P.S. When i installed the new Vsync tinyptc, it turn smooth as silk!!! Great work guys!

Code: [Select]

'#define ptc_win

#define mycls redim as integer gfxbuffer (gfx_w * gfx_h)

#define writepixel(x,y,col) gfxbuffer(x + y*gfx_w)=col

#include once "tinyptc.bi"

option dynamic
option explicit

const gfx_w = 640
const gfx_h = 480
const gfx_size = gfx_w * gfx_h
const numstars = 1000

dim n
randomize timer

if (ptc_open("horizontal starscroller",gfx_w,gfx_h)=0) then
    end -1
end if

dim as integer gfxbuffer(gfx_size)

type star
    x as integer
    y as integer
    speed as ubyte
    col as integer
end type

dim s(numstars) as star

' setup start positions and speeds

for n=0 to numstars
    s(n).x=(rnd*gfx_w)
    s(n).y=(rnd*gfx_h)
    s(n).speed=(rnd*3)+1
    if s(n).speed = 1 then
        s(n).col = &h101050
    end if
    if s(n).speed = 2 then
        s(n).col = &h303070
    end if
    if s(n).speed = 3 then
        s(n).col = &h707090
    end if
    if s(n).speed = 4 then
        s(n).col = &hd0d0f0
    end if
   
    writepixel(s(n).x, s(n).y, s(n).col)
next

while inkey$<>chr$(27)
    for n=0 to numstars
        s(n).x = s(n).x + s(n).speed
        if s(n).x > gfx_w then
            s(n).x = 0
            s(n).y = (rnd*gfx_h)
        end if
        writepixel(s(n).x, s(n).y, s(n).col)
    next
    ptc_update @gfxbuffer(0)
    mycls
   
wend
ptc_close()
end


Pages: [1]