Author Topic: Problem Backgroud scroll with 1 line Black Pikel  (Read 2639 times)

Offline Kyo

  • Dr. Type
  • ****
  • Posts: 350
    • View Profile

The problem is the black line that is created when approached two tile that are not Px2 Texture.

Code: (glbasic) [Select]
IMPORT "C" void __stdcall glTexParameteri(unsigned int flag0, unsigned int flag1, unsigned int flag2);
GLOBAL GL_CLAMP_TO_EDGE%                                   = 0x812F
GLOBAL GL_TEXTURE_2D%                                      = 0x0DE1
GLOBAL GL_TEXTURE_WRAP_S%                                  = 0x2802
GLOBAL GL_TEXTURE_WRAP_T%                                  = 0x2803


FUNCTION z_drawstage: num%,x%,y%

        STARTPOLY num
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);// Changed \\
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);// Changed \\
                POLYVECTOR x1,y1,0,0,color
                POLYVECTOR x1,y1+y2,0,sy,color
                POLYVECTOR x1+x2,y1+y2,sx,sy,color
                POLYVECTOR x1+x2,y1,sx,0,color
        ENDPOLY
ENDFUNCTION


Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3958
    • View Profile
    • Space Fractal
here is the full code:

Code: (glbasic) [Select]
// --------------------------------- //
// Project: Test_BG
// Start: Tuesday, August 26, 2014
// IDE Version: 12.243


// SETCURRENTDIR("Media") // go to media files



AUTOPAUSE TRUE
SETCURRENTDIR("Media") // go to media files

SYSTEMPOINTER TRUE
SETSCREEN 1280,720,FALSE

GLOBAL screen_w, screen_h

GETSCREENSIZE screen_w, screen_h

SMOOTHSHADING TRUE


LIMITFPS 30

initZ(1)

LOADSPRITE "1.png", 1
LOADSPRITE "1.png", 2
LOADSPRITE "1.png", 3


WHILE TRUE
IF KEY(203) THEN av_x = av_x + 3
IF KEY(205) THEN av_x = av_x - 3

FOR i = 1 TO 3
IF i = 1 THEN x = 0
IF i = 2 THEN x = 299
IF i = 3 THEN x = 299*2

z_drawstage( i,x + av_x,0)
NEXT

SHOWSCREEN
WEND


// Changed \\
IMPORT "C" void __stdcall glTexParameteri(unsigned int flag0, unsigned int flag1, unsigned int flag2);
GLOBAL GL_CLAMP_TO_EDGE%                                   = 0x812F
GLOBAL GL_TEXTURE_2D%                                      = 0x0DE1
GLOBAL GL_TEXTURE_WRAP_S%                                  = 0x2802
GLOBAL GL_TEXTURE_WRAP_T%                                  = 0x2803


FUNCTION z_drawstage: num%,x%,y%,flip=0,xzoom = 0, yzoom = 0, adv_x = 0, Scale# = 1, color=0xFFFFFF, lungh = -1
LOCAL sx%,sy%,x1%,y1%,x2%,y2%

GETSPRITESIZE num,sx,sy

IF lungh >= 0 THEN sx = lungh

IF xzoom <> 0 THEN xzoom = x_zoom + xzoom
IF yzoom <> 0 THEN yzoom = y_zoom + yzoom

IF xzoom <> 0 THEN x = x - adv_x


IF xzoom = 0 THEN xzoom = x_zoom
IF yzoom = 0 THEN yzoom = y_zoom



x1=(x_offset+(x*xzoom)) * Scale#
x2=(sx*xzoom) * Scale#
y1=(y_offset+(y*yzoom)) * Scale#
y2=(sy*yzoom) * Scale#


SMOOTHSHADING TRUE
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);// Changed \\
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);// Changed \\
STARTPOLY num
POLYVECTOR x1,y1,0,0,color
POLYVECTOR x1,y1+y2,0,sy,color
POLYVECTOR x1+x2,y1+y2,sx,sy,color
POLYVECTOR x1+x2,y1,sx,0,color
ENDPOLY
ENDFUNCTION

This one works on Windows, but crash on MacOSx:

Code: (glbasic) [Select]

Thread 0:: Dispatch queue: com.apple.main-thread
0   dyld                          0x8ff10322 misaligned_stack_error + 0
1   com.flynetstudios.testbg      0x00052f8c OpenGLRainbows::PolyEnd() + 28
2   com.flynetstudios.testbg      0x00006952 __GLBASIC__::ENDPOLY() + 26
3   com.flynetstudios.testbg      0x00003816 __GLBASIC__::z_drawstage(int, int, int, double, double, double, double, double, double, double) + 742
4   com.flynetstudios.testbg      0x00003ba2 __GLBASIC__::__MainGameSub_() + 610
5   com.flynetstudios.testbg      0x0002e2a1 SDL_main + 817
6   com.flynetstudios.testbg      0x00004991 -[SDLMain applicationDidFinishLaunching:] + 88
7   com.apple.Foundation          0x96bfe732 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 49
8   com.apple.CoreFoundation      0x90d895a4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
9   com.apple.CoreFoundation      0x90c6b04b _CFXNotificationPost + 3435
10  com.apple.Foundation          0x96bed21f -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
11  com.apple.AppKit              0x99ac8575 -[NSApplication _postDidFinishNotification] + 367
12  com.apple.AppKit              0x99ac8215 -[NSApplication _sendFinishLaunchingNotification] + 239
13  com.apple.AppKit              0x99ac4b44 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 840
14  com.apple.AppKit              0x99ac4431 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 277
15  libobjc.A.dylib                0x9795d304 -[NSObject performSelector:withObject:withObject:] + 77
16  com.apple.Foundation          0x96c0d47a __76-[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]_block_invoke + 121
17  com.apple.Foundation          0x96c0cfb1 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 430
18  com.apple.Foundation          0x96c0cdbb _NSAppleEventManagerGenericHandler + 218
19  com.apple.AE                  0x9408bb15 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 387
20  com.apple.AE                  0x9405aed6 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 44
21  com.apple.AE                  0x9405adce aeProcessAppleEvent + 318
22  com.apple.HIToolbox            0x94ab5571 AEProcessAppleEvent + 55
23  com.apple.AppKit              0x99ac0148 _DPSNextEvent + 1089
24  com.apple.AppKit              0x99abf870 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 119
25  com.apple.AppKit              0x99ab215c -[NSApplication run] + 727
26  com.flynetstudios.testbg      0x000047b9 CustomApplicationMain + 428
27  com.flynetstudios.testbg      0x00004c34 main + 280
28  com.flynetstudios.testbg      0x00002c6e _start + 228
29  com.flynetstudios.testbg      0x00002b89 start + 41

The reason the glTexParameteri is required to been inside the POLYGON is to avoid drawing a border. If its move outside it, then you will see a border.

Im thinks im have tried to do something like this in Greedy Mouse in the early stage, but did do a very differemt workaround.

The bug is confirmed
.
« Last Edit: 2014-Sep-02 by spacefractal »
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3958
    • View Profile
    • Space Fractal
its look like MacOSx dosent like __stdcall on the IMPORT call. when that got removed, then its works.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.