Menu

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.

Show posts Menu

Messages - backspace

#46
Haha. Yes it is sometimes embarrassing to make such mistakes, but its part of the process of learning. I'll get there eventually.
#47
So if I wish to link to 'libddraw.a' I would add '-llibddraw.a' in the lnk text area. I think I get it.
Thanks hardyx.
#48
This is very humiliating. I had scratched my head for a long time on this one, and it is really such a silly mistake on my part. I had dimensioned the Createscreen to 256x256 instead of 512x512. So Drawline can obviously not draw to an area that does not exist. My Bad.
#49
I seem to have a problem with DRAWLINE not being able to draw to a sprite created with CREATESCREEN. The DRAWRECT does work. So I am wondering if this a bug, or am I doing something wrong?

Code with the problem
Code (glbasic) Select

// Screen 0, Sprite 13
CREATESCREEN 0, 13, 256, 256

// Use screen for all output
USESCREEN 0

PRINT "Offscreen", 0,0
ALPHAMODE 0.8
DRAWRECT 254,0,5, 256, RGB(0,250,0)    // <<---- This works
DRAWLINE 256,256,512,256, RGB(0,250,0) // <<---- Does not work
   
// Switch back to the window
USESCREEN -1

// Draw the screen
DRAWSPRITE 13, 0, 0

SHOWSCREEN
MOUSEWAIT
#50
I can include "c" header files within an INCLUDE statement. However, is it possible to link to an external (gcc  .a / .o) library, in order to use that library's functions in my compiled project?  If possible, how?
Thanks in advance.
#52
Hi, I'm still kinda new to this, but it seems that GLBasic converts the Basic code into c++ code. So i've read. Is it in any way possible to see the c++ code that gets produced ?
Thanks.
#53
Here's an extended drawing library that adds a few extra drawing primitives.
Objects include line, lineto, rectangle, filledrectangle, circle, filledcircle, oval, filledoval. pixel
Just comment out the "test" function, add the file to your project, and call the required functions. Use the test function as and example
Setting _drawcolor will set the color for all subsequent drawing calls
line and pixel save the last x,y location - for using lineto function.

Code (glbasic) Select
// --------------------------------- //
// Project: DrawingObjects

test()

TYPE _DSTORE
x
y
color
ENDTYPE

GLOBAL _dstore AS _DSTORE; _dstore.x=0; _dstore.y=0; _dstore.color = RGB(255,255,255)

FUNCTION _drawcolor: r,g,b
_dstore.color = RGB(r,g,b)
ENDFUNCTION

FUNCTION _line: x1, y1, x2, y2
DRAWLINE x1, y1, x2, y2, _dstore.color
_dstore.x = x2
_dstore.y = y2
ENDFUNCTION

FUNCTION _lineto: x,y
DRAWLINE _dstore.x, _dstore.y, x, y, _dstore.color
_dstore.x = x
_dstore.y = y
ENDFUNCTION

FUNCTION _rectangle: x,y,w,h
_line(x,y,x+w-1,y)
_lineto(x+w-1,y+h-1)
_lineto(x,y+h-1)
_lineto(x,y)
ENDFUNCTION

FUNCTION _filledrectangle: x, y, w, h
DRAWRECT x, y, w, h, _dstore.color
ENDFUNCTION

FUNCTION _pixel: x,y
SETPIXEL x,y,_dstore.color
_dstore.x = x
_dstore.y = y
ENDFUNCTION

FUNCTION _circle: x,y,r
_pixel((SIN(0)*r)+x , (COS(0)*r)+y)
FOR i = 1 TO 360 STEP 10
_lineto( (SIN(i)*r)+x , (COS(i)*r)+y)
NEXT
_lineto( (SIN(0)*r)+x , (COS(0)*r)+y)
ENDFUNCTION

FUNCTION _filledcircle: x,y,r
LOCAL lx,rx,yy
FOR i = 0 TO 180 STEP 0.5
lx = (SIN(i)*r)+x
rx = (SIN(360-i)*r)+x
yy = (COS(i)*r)+y
_line(lx,yy,rx,yy)
NEXT
ENDFUNCTION

FUNCTION _oval: x,y,w,h
_pixel((SIN(0)*w/2)+x , (COS(0)*h/2)+y)
FOR i = 1 TO 360 STEP 10
_lineto( (SIN(i)*w/2)+x , (COS(i)*h/2)+y)
NEXT
_lineto( (SIN(0)*w/2)+x , (COS(0)*h/2)+y)
ENDFUNCTION

FUNCTION _filledoval: x,y,w,h
LOCAL lx,rx,yy
FOR i = 0 TO 180 STEP 0.5
lx = (SIN(i)*w/2)+x
rx = (SIN(360-i)*w/2)+x
yy = (COS(i)*h/2)+y
_line(lx,yy,rx,yy)
NEXT
ENDFUNCTION

FUNCTION test:
WHILE TRUE
_drawcolor(200,100,50)
_line(300,50,200,100)
_lineto(200,200)
_lineto(400,200)
_lineto(400,100)
_lineto(300,50)
_filledrectangle(140,240,200,100)
_rectangle(400,250,100,50)
_pixel(500,100)
_drawcolor(255,40,100)
_circle(500,100,50)
_filledcircle(500,400,60)
_oval(500,100,90,50)
_drawcolor(0,50,255)
_filledoval(500,400,50,95)

SHOWSCREEN
WEND
ENDFUNCTION