Graphics

Member
Posts: 567
Joined: 2004.07
Post: #1
I made a file that basically made and opengl window or fullscreen, but it crashes. Mad
here's the code:
PHP Code:
/*
 *  GL_graphics.c
 *  Lesson 01
 *
 *  Created by Ryan on Sun Mar 20 2005.
 *  Copyright (c) 2005 __MyCompanyName__. All rights reserved.
 *
 */

#include "GL_graphics.h"

static int runningFullscreen 0;

int ToggleFullscreen(int widthint height)
{
    if (!
runningFullscreen
    {
        if (!
GL_setFullscreen(widthheight)) return 0;
        return 
1;
    }
    if (!
GL_setWindowed(widthheight)) return 0;
    return 
1;
}


int GL_setWindowed(int widthint height)
{
    
int bpp;
    const 
SDL_VideoInfoinfo SDL_GetVideoInfo( );
    
bpp info -> vfmt -> BitsPerPixel;
    
/* Set bit depth, and double buffering */
    
SDL_GL_SetAttributeSDL_GL_RED_SIZE);
    
SDL_GL_SetAttributeSDL_GL_GREEN_SIZE);
    
SDL_GL_SetAttributeSDL_GL_BLUE_SIZE);
    
SDL_GL_SetAttributeSDL_GL_DEPTH_SIZE16 );
    
SDL_GL_SetAttributeSDL_GL_DOUBLEBUFFER);
    
// makes a window
    
if(!SDL_SetVideoModewidthheightbppSDL_OPENGL SDL_RESIZABLE )) // if something went wrong while making a window
    
{
    
        
fprintfstderr"Video mode (windowed) set failed: %s\n",
                 
SDL_GetError( ) );
        
SDL_Quit(); // quit (duh)
        
return 0;
    }
    
    
GL_reshape(widthheight);  // reshapes
    
runningFullscreen 0;
    
    return 
1;    // success!
}

int GL_setFullscreen(int widthint height)
{
    
int bpp;
    const 
SDL_VideoInfoinfo NULL;
    
    
info SDL_GetVideoInfo( );
    
bpp info->vfmt->BitsPerPixel;
    
    
/* Set bit depth, and double buffering */
    
SDL_GL_SetAttributeSDL_GL_RED_SIZE);
    
SDL_GL_SetAttributeSDL_GL_GREEN_SIZE);
    
SDL_GL_SetAttributeSDL_GL_BLUE_SIZE);
    
SDL_GL_SetAttributeSDL_GL_DEPTH_SIZE16 );
    
SDL_GL_SetAttributeSDL_GL_DOUBLEBUFFER);
    
    
// makes sets screen to fullscreen
    
if(!SDL_SetVideoModewidthheightbppSDL_OPENGL SDL_FULLSCREEN )) // check to see if something went wrong while going fullscreen 
    
{
        
fprintfstderr"Video mode (fullscreen) set failed: %s\n",
                 
SDL_GetError( ) );
        
SDL_Quit();
        return 
0;
    }
    
    
GL_reshape(widthheight);
    
runningFullscreen 1;
    
    
GL_reshape(widthheight);  // reshapes
    
runningFullscreen 0;
    
    return 
1;    // success!
    
}

void GL_reshape(int widthint height)
{
    
float ratio = (float) width / (float) height;    
    
glEnable(GL_DEPTH_TEST);
    
glShadeModelGL_SMOOTH );    
    
glClearColor000);
    
glViewport00widthheight );
    
glMatrixModeGL_PROJECTION );
    
glLoadIdentity( );
    
gluPerspective60.0ratio1.01024.0 );
    
#ifdef __APPLE__    // if this is a mac...
    
long VBL 1;
    
CGLSetParameter(CGLGetCurrentContext(),  kCGLCPSwapInterval, &VBL); // turn VBL sync on
    #endif


It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
where does it crash, how does it crash, &c. Just the code's not much use.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #3
it chrashes precisely when i call:
PHP Code:
if (!GL_setWindowed(widthheight)) printf("something went wrong"); 

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
where does it crash, how does it crash.

that means backtrace, not line, and SIGSEGV, SIGBUS, SIGABRT, SIGKILL, &c
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #5
«PROJECTNAME» has exited due to signal 10 (SIGBUS).

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
OneSadCookie Wrote:that means backtrace, not line

This is like getting blood from a stone! Do you want help or not?
Quote this message in a reply
Member
Posts: 156
Joined: 2002.11
Post: #7
I am with you 100% on this one, OSC. Smile
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #8
Nayr, I think they want you to post the backtrace which will be in the crash log for your app, located in your local library folder: Library/Logs/CrashReporter/appname.crash.log

OSC has a habit of assuming people are just pretending to not know something to annoy him and then punishing them for it, rather than explaining simply and clearly what he means (without technical jargon that learning programmers haven't grasped yet.) Of course, all knowledgeable smart people are usually very busy, right?

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #9
oh. In that case, i know the problem. The
PHP Code:
bpp info -> vfmt -> BitsPerPixel
part.

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #10
ok, here's the crash:
Code:
Date/Time:      2005-03-25 15:17:13 -0500
OS Version:     10.3.8 (Build 7U16)
Report Version: 2

Command: Lesson 01
Path:    /Users/ryan/Projects/SDL NeHe/Lesson 01/build/Lesson 01.app/Contents/MacOS/Lesson 01
Version: Lesson 01 version 0.1 (0.1)
PID:     597
Thread:  0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000008

Thread 0 Crashed:
0   ???                          0x0000ab6c GL_setWindowed + 0x2c (GL_graphics.c:30)
1   ???                          0x0000a9c0 SDL_main + 0x28 (main.c:16)
2   ???                          0x0000a644 -[SDLMain applicationDidFinishLaunching:] + 0x64 (SDLMain.m:197)
3   com.apple.Foundation         0x909f7184 _nsnote_callback + 0xb0
4   com.apple.CoreFoundation     0x901aa5c0 __CFXNotificationPost + 0x1b4
5   com.apple.CoreFoundation     0x901aefd0 _CFXNotificationPostNotification + 0x340
6   com.apple.Foundation         0x909f4fd0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 0x74
7   com.apple.AppKit             0x92ee3e70 -[NSApplication _postDidFinishNotification] + 0x70
8   com.apple.AppKit             0x92ee3d5c -[NSApplication _sendFinishLaunchingNotification] + 0x5c
9   com.apple.AppKit             0x92ee3f8c -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 0x78
10  com.apple.Foundation         0x90a4a544 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 0x164
11  com.apple.Foundation         0x90a50c6c _NSAppleEventManagerGenericHandler + 0x78
12  com.apple.AE                 0x91674a10 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 0xd0
13  com.apple.AE                 0x91677858 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 0x2c
14  com.apple.AE                 0x91674c50 aeProcessAppleEvent + 0x11c
15  com.apple.HIToolbox          0x928c4338 AEProcessAppleEvent + 0x3c
16  com.apple.AppKit             0x92dd301c _DPSNextEvent + 0x358
17  com.apple.AppKit             0x92de98c8 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 0x74
18  com.apple.AppKit             0x92dfdc30 -[NSApplication run] + 0x21c
19  ???                          0x0000a5a4 CustomApplicationMain + 0x148 (SDLMain.m:177)
20  ???                          0x0000a97c main + 0x184 (SDLMain.m:278)
21  ???                          0x00009c80 _start + 0x188 (crt.c:267)
22  ???                          0x00009af4 start + 0x30

PPC Thread State:
  srr0: 0x0000ab6c srr1: 0x0000f030                vrsave: 0x00000000
    cr: 0x22002248  xer: 0x0000001d   lr: 0x0000ab60  ctr: 0x30024878
    r0: 0x00000000   r1: 0xbfffeab0   r2: 0x00000000   r3: 0x00000000
    r4: 0x0000ab60   r5: 0x000003a0   r6: 0xfefefeff   r7: 0x80808080
    r8: 0x4000186b   r9: 0x0000c0f4  r10: 0x0000000b  r11: 0x42002242
   r12: 0x30024878  r13: 0x00000000  r14: 0x00000000  r15: 0x00000000
   r16: 0x00000000  r17: 0xbffff600  r18: 0x00000000  r19: 0x00000000
   r20: 0x00323710  r21: 0x0d9a1072  r22: 0x0000000d  r23: 0x0030bfe4
   r24: 0x00000000  r25: 0x0030bfd0  r26: 0xa2dc5170  r27: 0x0030bfd0
   r28: 0x00000000  r29: 0xbfffec10  r30: 0xbfffeab0  r31: 0x909f70f4

Binary Images Description:
    0x1000 -     0xbfff ??? Lesson 01 version 0.1 (0.1)    /Users/ryan/Projects/SDL NeHe/Lesson 01/build/Lesson 01.app/Contents/MacOS/Lesson 01
0x30000000 - 0x3004cfff SDL 1.2.8    /Users/ryan/Projects/SDL NeHe/Lesson 01/build/Lesson 01.app/Contents/MacOS/../Frameworks/SDL.framework/Versions/A/SDL
0x87520000 - 0x87560fff com.apple.glut 3.2.7 (GLUT-3.2.7)    /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT
0x8fe00000 - 0x8fe4ffff dyld     /usr/lib/dyld
0x90000000 - 0x90122fff libSystem.B.dylib     /usr/lib/libSystem.B.dylib
0x90190000 - 0x9023dfff com.apple.CoreFoundation 6.3.6 (299.33)    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x90280000 - 0x904f9fff com.apple.CoreServices.CarbonCore 10.3.6 (10.3.5)    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x90570000 - 0x905dffff com.apple.framework.IOKit 1.3.6 (???)    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x90610000 - 0x9069afff com.apple.CoreServices.OSServices 3.0.1    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x90700000 - 0x90700fff com.apple.CoreServices 10.3 (???)    /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x90720000 - 0x90787fff com.apple.audio.CoreAudio 2.1.2    /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x907f0000 - 0x907f9fff com.apple.DiskArbitration 2.0.4    /System/Library/PrivateFrameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x90810000 - 0x90810fff com.apple.ApplicationServices 1.0 (???)    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0x90830000 - 0x9089ffff libobjc.A.dylib     /usr/lib/libobjc.A.dylib
0x90910000 - 0x90983fff com.apple.DesktopServices 1.2.3    /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
0x909f0000 - 0x90b4bfff com.apple.Foundation 6.3.5 (500.56)    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x90c30000 - 0x90c4afff libGL.dylib     /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x90c60000 - 0x90cc2fff libGLU.dylib     /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x90d00000 - 0x90d1bfff com.apple.SystemConfiguration 1.7.1 (???)    /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x90d40000 - 0x90d40fff com.apple.Carbon 10.3 (???)    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x90d60000 - 0x90d6bfff com.apple.opengl 1.3.8    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x90ec0000 - 0x90ec0fff com.apple.Cocoa 6.3 (???)    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
0x910b0000 - 0x91101fff com.apple.bom 1.2.5 (63.2)    /System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
0x912a0000 - 0x912bdfff com.apple.audio.SoundManager 3.8    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSound.framework/Versions/A/CarbonSound
0x912e0000 - 0x912f7fff com.apple.LangAnalysis 1.5.4    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
0x91320000 - 0x913dffff ColorSync     /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x91460000 - 0x91473fff com.apple.speech.synthesis.framework 3.2    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x914a0000 - 0x91509fff com.apple.htmlrendering 1.1.2    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering
0x91560000 - 0x91619fff com.apple.QD 3.4.65 (???)    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
0x91670000 - 0x916a8fff com.apple.AE 1.4    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x916e0000 - 0x91773fff com.apple.print.framework.PrintCore 3.3    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
0x917e0000 - 0x917f0fff com.apple.speech.recognition.framework 3.3    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
0x91810000 - 0x9182afff com.apple.openscripting 1.2.1 (???)    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
0x91850000 - 0x91860fff com.apple.ImageCapture 2.1.5    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
0x91890000 - 0x9189cfff com.apple.help 1.0.1    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
0x918c0000 - 0x918cdfff com.apple.CommonPanels 1.2.1 (1.0)    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
0x918f0000 - 0x9193efff com.apple.print.framework.Print 3.3    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
0x91990000 - 0x9199bfff com.apple.securityhi 1.2 (90)    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
0x919c0000 - 0x91a33fff com.apple.NavigationServices 3.3.2    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/NavigationServices.framework/Versions/A/NavigationServices
0x91a90000 - 0x91a90fff com.apple.audio.units.AudioUnit 1.3.2    /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x91ab0000 - 0x91ac4fff libCGATS.A.dylib     /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGATS.A.dylib
0x91ae0000 - 0x91aebfff libCSync.A.dylib     /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCSync.A.dylib
0x91b10000 - 0x91b2afff libPDFRIP.A.dylib     /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libPDFRIP.A.dylib
0x91b50000 - 0x91b5ffff libPSRIP.A.dylib     /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libPSRIP.A.dylib
0x91b80000 - 0x91b93fff libRIP.A.dylib     /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
0x91bb0000 - 0x91d45fff com.apple.QuickTime 6.5.2    /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
0x92070000 - 0x92096fff com.apple.FindByContent 1.4 (1.2)    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/FindByContent.framework/Versions/A/FindByContent
0x920c0000 - 0x922a7fff com.apple.security 2.4 (177)    /System/Library/Frameworks/Security.framework/Versions/A/Security
0x92430000 - 0x92468fff com.apple.LaunchServices 10.3.5 (98.4)    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x92740000 - 0x92777fff com.apple.CFNetwork 1.2.1 (7)    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x927d0000 - 0x92b54fff com.apple.HIToolbox 1.3.5 (???)    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
0x92d30000 - 0x92d80fff com.apple.HIServices 1.4.1 (0.0.1d1)    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x92dc0000 - 0x932bffff com.apple.AppKit 6.3.6 (743.33)    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x935d0000 - 0x938a8fff com.apple.CoreGraphics 1.203.30 (???)    /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x939a0000 - 0x939b4fff libcups.2.dylib     /usr/lib/libcups.2.dylib
0x939d0000 - 0x939d4fff libmathCommon.A.dylib     /usr/lib/system/libmathCommon.A.dylib
0x93b50000 - 0x93bf3fff com.apple.audio.toolbox.AudioToolbox 1.3.2    /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x94060000 - 0x94078fff com.apple.WebServices 1.1.1 (1.1.0)    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/WebServicesCore.framework/Versions/A/WebServicesCore
0x945b0000 - 0x945b9fff libz.1.dylib     /usr/lib/libz.1.dylib
0x94610000 - 0x9462afff libresolv.9.dylib     /usr/lib/libresolv.9.dylib
0x94650000 - 0x946affff com.apple.SearchKit 1.0.2    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x94a30000 - 0x94af5fff libxml2.2.dylib     /usr/lib/libxml2.2.dylib
0x94b20000 - 0x94badfff com.apple.ink.framework 101.1.3 (55.10)    /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
0x968d0000 - 0x969b2fff libicucore.A.dylib     /usr/lib/libicucore.A.dylib
0x96a20000 - 0x96ae2fff libcrypto.0.9.7.dylib     /usr/lib/libcrypto.0.9.7.dylib
0x96b40000 - 0x96b6efff libssl.0.9.7.dylib     /usr/lib/libssl.0.9.7.dylib
0x96bf0000 - 0x96c7ffff ATS     /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x96cb0000 - 0x96d9efff libiconv.2.dylib     /usr/lib/libiconv.2.dylib
0x97510000 - 0x97518fff libbsm.dylib     /usr/lib/libbsm.dylib

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #11
SDL_GetVideoInfo( ) == NULL maybe? Do you init SDL properly?
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #12
hmm, ok it basicaly works now, but I can't render anything when I call glTranslatef. Mad
Source

It's not magic, it's Ruby.
Quote this message in a reply
Puzzler183
Unregistered
 
Post: #13
Are you guessing numbers for glTranslatef or do you actually know what's going on? I can't view your source since I'm on a computer without a decompression program...
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #14
Puzzler183 Wrote:Are you guessing numbers for glTranslatef or do you actually know what's going on? I can't view your source since I'm on a computer without a decompression program...

in the source, you literally uncomment the
PHP Code:
// glTranslatef( 0.0f, 0.0f,-3.0f); 
I hacked this code together with code from kill Cote, cone3d, and the example from doc wiki on libsdl.org.

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #15
Anyone? I'd really like to get this working, and it's only three files (plus the texture file, but that's another bug report).

It's not magic, it's Ruby.
Quote this message in a reply
Post Reply