|
Post by Darkjester on Dec 26, 2011 2:04:12 GMT -5
Here is[glow=red,2,300] SOIL[/glow] (Simple opengl image library), the library is mostly complete, it is functional for the most part, just missing a few flags, enjoy. -DJ soilplugin.zip
|
|
|
Post by matthew on Dec 26, 2011 2:54:07 GMT -5
It loads correctly but I haven't been able to test it yet. Could you provide some Basic4GL code examples so I could see it in action?
|
|
|
Post by Darkjester on Dec 26, 2011 3:07:59 GMT -5
sparks demo from the demo folder using soil.
' Sparks Demo ' Written by Scott Brosious
const width = 200, height = 200 const nops = 1000 ' Number of pixels const Speed = 1 ' Speed
dim xcntr,ycntr
xcntr = width / 2 ycntr = height / 2
const scale = 3
dim buffer(width)(height)
dim col1# dim col2# dim texture dim a dim i,j dim time ' Current time dim t1,t2 ' Starting and ending time variables
dim xpos(nops) ' Xposition dim ypos(nops) ' Yposition dim ang(nops) ' Angles dim st(nops) ' Start time dim et(nops) ' End time dim mt(nops) ' Time to move
for i = 1 to nops
gosub Inittime
st(i) = t1 et(i) = t2
gosub Angles
ang(i) = a
next
' Set 2D mode glMatrixMode (GL_PROJECTION) glLoadIdentity () glOrtho (0, width, 0, height, -1, 1) glMatrixMode (GL_MODELVIEW) glDisable (GL_DEPTH_TEST)
texture = soil_load_ogl_texture("data\ball.png", SOIL_LOAD_AUTO,SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y) glEnable (GL_TEXTURE_2D)
' Translucency, Blending glBlendFunc(GL_SRC_ALPHA,GL_ONE) glEnable(GL_BLEND)
while true
' Clear screen glClear (GL_COLOR_BUFFER_BIT)
glBindTexture (GL_TEXTURE_2D, texture)
for i = 1 to nops
if time > st(i) then mt(i) = mt(i) + 1 :endif ' If current time greater then start time then move it.
if mt(i) > et(i) then gosub Refresh :endif ' If movetime greater then endtime start again
xpos(i)= xcntr + cosd(ang(i)) * (mt(i) * Speed) ypos(i)= ycntr + sind(ang(i)) * (mt(i) * Speed)
if xpos(i) < 0 or xpos(i) > width then goto skip1 endif if ypos(i) < 0 or ypos(i) > height then goto skip1 endif
buffer(xpos(i))(ypos(i)) = 10
skip1:
next
for j = 0 to height for i = 0 to width
buffer(i)(j) = buffer(i)(j) - 1
next next
glBegin (GL_QUADS)
for j = 0 to height for i = 0 to width
col1# = buffer(i)(j)
if col1# < 0 then goto skip2 endif if col1# > 10 then col1# = 10 endif
col2# = col1# / 10
glColor4f (1, 1, 1, col2#)
glTexCoord2f (0, 1) glVertex2f (i - scale,j + scale) ' Top left
glTexCoord2f (0, 0) glVertex2f (i - scale,j - scale) ' Bottom left glTexCoord2f (1, 0) glVertex2f (i + scale,j - scale) ' Bottom right
glTexCoord2f (1, 1) glVertex2f (i + scale,j + scale) ' Top right
skip2:
next next
glEnd ()
' Display output SwapBuffers ()
time = time + 1
wend
ReFresh:
gosub InitTime st(i) = t1 et(i) = t2 mt(i) = 0 gosub Angles ang(i) = a
return
InitTime:
t1 = rnd() % 20 t2 = rnd() % width
return
Angles:
a = rnd() % 360
return
|
|
|
Post by matthew on Dec 29, 2011 4:17:02 GMT -5
Okay that works.
|
|
|
Post by Darkjester on Jan 12, 2012 13:38:32 GMT -5
thanks matthew, soil allows you to load more image types than basic4gl internal, specifically it allows bmp,png,jpg,tga,dds(DTX1/2/3/4/5, uncompressed),psd,hdr, it can right TGA,BMP, and DDs i am missing a few functions for the cubemap support as well as correct DXT compression Constants
|
|