Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Godlord

Members
  • Posts

    5689
  • Joined

  • Last visited

    Never

Everything posted by Godlord

  1. I think function pointers are what you are looking for. Yours faithfully, S.J.R. van Schaik.
  2. > look at a premade code and figure it out from it? Good luck with that. You'll have to understand numerous concepts related to both advanced computer graphics and linear algebra if you want to take that route. > Does anyone know of a good article that explains the logic behind Shaders, it doesn't necessarily have to be oriented to SFML, as I'm pretty sure the logic is universal. I really don't want a link to some pre-made code, as I want to figure this out myself; I've tried looking around and I just can't find anything that would explain it to me. > > Regards, > > GP SFML is just a cross-platform library that simply offers an abstract interface to deal with graphics, sound, etc. However, it doesn't really do anything with shaders. If you want to learn about writing shaders for OpenGL, then you can find more information at the following websites: * http://www.arcsynthesis.org/gltut/index.html * https://en.wikibooks.org/wiki/OpenGL_Programming Yours faithfully S.J.R. van Schaik.
  3. SDL doesn't really offer any functions to tint images. However, there are a few ways to do it. The most obvious and fastest way to do it is to simply use OpenGL. Alternatively, you can also write your own function that applies the following formula to your images: dst_colour = src_colour * blend_colour / 255; However, since that operation has to be done in software, it is going to be painfully slow. Finally, the way used for old games is to have multiple palettes, where you'd dim the background by simply switching to another palette for that image or those images (of course, you'll need images where the palette indices are specified within the pixels, rather than the colours directly). Yours faithfully, S.J.R. van Schaik.
  4. That's because you have to break cases explicitly (you forgot to put a break statement at the end of some of your cases). Yours faithfully, S.J.R. van Schaik.
  5. > Did a bit of research and wow, thanks for bringing it up. Never heard of it before. Or QueryPerformanceCounter(), if you can deal with all of its pitfalls (or if you don't care about them). Yours faithfully, S.J.R. van Schaik.
  6. > Wouldn't I still need to copy the data from the buffer? It's not guarenteed that realloc will use the same area of memory, right? realloc will copy over the memory, if it can't extend the current chunk of memory. > Also, you're "next_power_of_two" will not work on numbers that are already powers of two. It will, actually, as it doesn't decrement the input before filling in the right-hand side with ones. However, that is the behaviour of next_strict_power_of_two in my repository (I intended to actually show you the one that does have the same behaviour as you described): ``` size_t cdl_next_power_of_two(size_t input) { size_t index; --input; for (index = 1; index < sizeof(size_t); index index; } return ++input; } ``` Yours faithfully, S.J.R. van Schaik.
  7. ![](http://82.174.230.73/~stephan/dionysos.png) Yours faithfully, S.J.R. van Schaik.
  8. ![](http://82.174.230.73/~stephan/dionysos.png) Yours faithfully, S.J.R. van Schaik.
  9. Normally, Microsoft Windows will look in the same path as where the executable is located for those system libraries. Therefore you normally won't have to register them. However, you might want to try registering them, as it won't do any harm. Yours faithfully, S.J.R. van Schaik.
  10. It's kind of hard to pin-point the exact cause, as the process consists of multiple steps: * Read the local INI file for the local version. * Download and read the remote INI file for the current version (possible problem: downloading may not work due to insufficient rights; msinet.ocx may be missing). * If the local version does match, exit the process. * Download the RAR-package (possible problem: downloading may not work due to insufficient rights; msinet.ocx may be missing). * Extract the RAR-package (possible problem: unrar.dll may be missing). * Update the local INI-file (possible problem: writing may not work due to insufficient rights). Yours faithfully, S.J.R. van Schaik.
  11. Hmm, has it been able to download the RAR-file, and does it contain everything that is required? Also, are there are any errors being shown when updating? Yours faithfully, S.J.R. van Schaik.
  12. Where is your executable located (i.e. what is its path)? Yours faithfully, S.J.R. van Schaik.
  13. Hmm, you can send me the plain files, if you want. I can probably open them in vim. I just won't be able to really execute the code, though. Yours faithfully, S.J.R. van Schaik.
  14. I don't really have a VB6 editor installed, though. Yours faithfully, S.J.R. van Schaik.
  15. You'll want to look at your code that deals with writing the files, then. As there may be some errors that you haven't caught yet. Yours faithfully, S.J.R. van Schaik.
  16. > I know, it does ask it then, but it still doesn't correctly update the files then. > > I though doing it this way would make it do it correctly, but is that true? You might want to check what kind of errors you are getting when updating the files. As I can't be entirely sure whether the source of the problem is the lack of administrator rights or not. Although, in this specific case, it doesn't seem to be. Yours faithfully, S.J.R. van Schaik.
  17. > Oh I'm sorry I didn't saw the difference. xD > > EDIT: So it did worked now but is this thesame as running a programm as admin, because when I run it as admin it also does it wrong. Basically, it should ask the user whether he or she wants to run the programme as an administrator or not, because that's how UAC works. Yours faithfully, S.J.R. van Schaik.
  18. No, NtAuthory is suppoed to be NtAuthority. Hence why you are getting run-time error 424: object required. Yours faithfully, S.J.R. van Schaik.
  19. That's supposed to be NtAuthority. Yours faithfully, S.J.R. van Schaik.
  20. Re-allocating and copying memory are slow operations. Therefore, you'll want to rewrite your resize-method in such a fashion that it can accept the amount of bytes that have to be stored. That way, you won't have to use a loop where you keep re-allocating the buffer until you have found a size that satisfies your demand. Additionally, you want to compute the next power of two, as sizes that are a power of two are favoured when using the heap. Furthermore, being able to compute the next power of two allows you to implement greedy allocation in a straight-forward fashion. In order to compute the next power of two you can use the following function from my library: ``` size_t next_power_of_two(size_t input) { size_t index; for (index = 1; index < sizeof(size_t); index index; } return ++input; } ``` On top of that you are currently using the C++ allocation operators. These are only useful when you want to allocate objects, as they will invoke the constructors and destructors automagically for you. Otherwise, you will simply want to use malloc, calloc, realloc and free instead: * realloc allows you to resize buffers more easily (if possible, it will simply extend the current chunk of memory, rather than allocating a new one). * There is no distinction between single entities and arrays, as is the case with the C++ allocation operators. * The C++ allocation operators are likely to call malloc and free anyway. So in the end, your resize method will look like this: ``` bool ByteStream::resize(size_t size) { char *data = NULL; size = next_power_of_two(size); if (this.size == size) { return true; } data = (char *)realloc(size); if (data == NULL) { return false; } this.data = data; this.size = size; return true; } ``` Additionally, your naming convention is confusing, as you tend to use the same style (capitalised camelcase) for both classes and methods. I'd encourage you to use capitalised camelcase (e.g. FooBar) for classes, and plain camelcase (e.g. fooBar) for methods. If your goal is to read data from files, or write data to files (or across the wire), then you will have to use stdint.h, as this header will define the following types for you: * int8_t: signed 8-bit integer. * int16_t: signed 16-bit integer. * int32_t: signed 32-bit integer. * int64_t: signed 64-bit integer. * uint8_t: unsigned 8-bit integer. * uint16_t: unsigned 16-bit integer. * uint32_t: unsigned 32-bit integer. * uint64_t: unsigned 64-bit integer. Furthermore, you will have to deal with endianness, as some architectures use big endian (e.g. some POWER-processors) rather than little endian (e.g. all x86-processors). Additionally, you want to avoid storing floats and doubles, directly. As these are encoded differently per architecture as well. My suggestion here is to encode and decode them as IEEE-754 32-bit and 64-bit floating-point numbers respectively. You will also want to avoid using structures directly, as the compiler may introduce padding to ensure that the processor can efficiently access the members within the structure. Therefore, I encourage you to use the members of the structure instead. Finally, you don't want to use integers to represent memory sizes, as integers may not be sufficiently large enough to represent every possible memory address. Instead, you'll want to use size_t to represent memory sizes. Yours faithfully, S.J.R. van Schaik.
  21. In order to elevate your process during run-time, you have to import "ShellExecuteEx" from shell32.dll and declare a structure that looks exactly like [this](http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784%28v=vs.85%29.aspx). You will then have to set up that structure before calling the function, these are required to set up an elevated process: * Set lpVerb to "runas". * Set lpFile to the path of the executable (which can be found by using GetModuleFileName, which can be imported from kernel32.dll). You can then use this code to create new processes (http://stackoverflow.com/a/4762460): ``` Public Enum ShowConstants SW_HIDE = 0 SW_NORMAL = 1 SW_SHOWMINIMIZED = 2 SW_SHOWMAXIMIZED = 3 SW_SHOWNOACTIVATE = 4 SW_SHOW = 5 SW_MINIMIZE = 6 SW_SHOWMINNOACTIVE = 7 SW_SHOWNA = 8 SW_RESTORE = 9 SW_SHOWDEFAULT = 10 End Enum Private Type SHELLEXECUTEINFO cbSize As Long fMask As Long hwnd As Long lpVerb As String lpFile As String lpParameters As String lpDirectory As String nShow As Long hInstApp As Long lpIDList As Long lpClass As String hkeyClass As Long dwHotKey As Long hIcon As Long hProcess As Long End Type Private Declare Function ShellExecuteEx Lib "shell32.dll" Alias "ShellExecuteExA" (pExecInfo As SHELLEXECUTEINFO) As Long Public Function ExecuteProcess(ByVal FilePath As String, ByVal hwnd As Long, ByVal nShow As ShowConstants, Optional lpParameters As String = "", Optional LaunchElevated As Boolean = False) Dim ExecInfo As SHELLEXECUTEINFO On Error Goto Hell With ExecInfo ' Set up the structure. .cbSize = Len(ExecInfo) .fMask = .lpFile = FilePath .nShow = nShow .lpDirectory = ExtractDirectoryFromPath(FilePath) .lpParameters = lpParameters .hwnd = hwnd ' On Microsoft Windows Vista and later, one can use runas instead of Open, in order to execute the ' process as an elevated process. In that case, the user will be asked whether he or she wants to ' run the process as an administrator. If LaunchElevated = True Then .lpVerb = "runas" Else .lpVerb = "Open" End If End ExecInfo ExecuteProcess = ShellExecuteEx(ExecInfo) Exit Function Hell: ExecuteProcess = False End Function Private Function ExtractDirectoryFromPath(Path As String) As String On Error Resume Next Dim Position As Long ' Find the right-most slash. Position = InStrRev(Path, "\") ' Extract everything on the left. ExtractDirectoryFromPath = Left$(Path, Position - 1) End Function ``` Additionally, you will have to check if the running process does have administrator rights, as you won't have to elevate the process if it does. For this you will have to use AllocateAndInitializeSid, FreeSid and CheckTokenMembership which can all be imported from advapi32.dll (http://stackoverflow.com/a/4762460): ``` Private Const SECURITY_BUILTIN_DOMAIN_RID As Long = &H20 Private Const DOMAIN_ALIAS_RID_ADMINS As Long = &H220 Private Declare Function AllocateAndInitializeSid Lib "advapi32.dll" (pIdentifierAuthority As Any, ByVal nSubAuthorityCount As Byte, ByVal nSubAuthority0 As Long, ByVal nSubAuthority1 As Long, ByVal nSubAuthority2 As Long, ByVal nSubAuthority3 As Long, ByVal nSubAuthority4 As Long, ByVal nSubAuthority5 As Long, ByVal nSubAuthority6 As Long, ByVal nSubAuthority7 As Long, lpPSid As Long) As Long Private Declare Sub FreeSid Lib "advapi32.dll" (ByVal pSid As Long) Private Declare Function CheckTokenMembership Lib "advapi32.dll" (ByVal hToken As Long, ByVal pSidToCheck As Long, pbIsMember As Long) As Long Private Type SID_IDENTIFIER_AUTHORITY Value(0 To 5) As Byte End Type Private Function IsAdministrator() As Boolean Dim NtAuthority As SID_IDENTIFIER_AUTHORITY Dim pAdministratorGroup As Long Dim lResult As Long NtAuthority.Value(5) = 5 If AllocateAndInitializeSid(NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_AlIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, pAdministratorGroup) 0 Then If CheckTokenMembership(0, pAdministratorGroup, lResult) 0 Then IsAdministrator = (lResult 0) Exit Function End If Call FreeSid(pAdministratorGroup) End If IsAdministrator = False End Function ``` You can then use this code to elevate your own process: ``` Public Const MAX_PATH = 206 Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" ( ByVal lpModuleName As String) As Long Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" ( ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long Public Function SelfElevate() As Boolean Dim FilePath As String Dim hModule As Long Dim lResult As Long FilePath = Space$(MAX_PATH) hModule = GetModuleHandle(App.EXEName) lResult = GetModuleFileName(hModule, FilePath, MAX_PATH) If lResult = 0 Then SelfElevate = False Exit Function End If If IsAdministrator() Then SelfElevate = True Exit Function End If SelfElevate = ExecuteProcess(FilePath, 0, SW_NORMAL, "", True) End Function ``` Yours faithfully, S.J.R. van Schaik.
  22. > With that said, I like to debug the few errors I get with numerous console outputs. If I narrow the error down to one function, I'll try to output "AAA" or "BBB" in different locations to narrow it down. The majority of the time, it just ends up being a stupid mistake that I've made– nothing too bad. You might want to consider looking into gdb and valgrind (which are irrelevant to Visual Basic 6). Additionally, the smallest mistakes usually have the most disastrous consequences. > I agree with Mrsh more so than I do SJR, but he (SJR) does have a point. Most beginners will forego the data management and logical flow-charting in lieu of just designing things as they go. Do both. Diagram or at least plan prior to coding AND use debugging tools to fine tune your code. The problem with most programmers is that they tend to write a lot of code in a short period of time, without testing it occasionally, whereupon they'll start fixing all the mistakes that have been pointed out by the compiler one by one. The horrible part being all the mistakes that occur at run-time (including segmentation faults for some programming languages). Therefore, it is a better idea to actually think about what your code is supposed to do, and how it will achieve that, before, whilst and even after programming, because keeping a model or image of your code base in mind will certainly help you with spotting flaws. Additionally, it is also a good idea to split up your code into smaller units, so that you can test your code more often. In the end, you'll find yourself relying on debugging tools less often, which is a good thing as debugging itself is usually more expensive than writing code. However, in those cases you'll be glad, if the hints they provide are actually useful. Yours faithfully, S.J.R. van Schaik.
  23. Happy birthday. Yours faithfully, S.J.R. van Schaik.
  24. I rarely find myself using debugging tools, actually. Mostly because I feel that having a clear understanding of your code is probably going to be the best debugging utility available to you. Yours faithfully, S.J.R. van Schaik.
  25. > Why you installed ubuntu with gnome and alot shit, when you can just install some clean distro and then install xfce4, what will consume alot less computer resources. Since when is GNOME, and more importantly X11 being shipped with Ubuntu's **server** edition, and why do you want him to install X11, or even worse XFCE 4 on a server, where a graphical environment isn't required, and mostly discouraged? Besides, GNOME (not GNOME 3) itself isn't really that bad for desktop environments, actually. Exactly because of the amount of programmes, and the user experience it has to offer, and in the case you don't want some of its applications, you can always get rid of them, or simply not install them (depending on whether they are actually being shipped with your distribution or not). On top of that, XFCE 4 and LXDE are mostly interesting desktop environments for low-end desktop computers, that will still heavily depend on several applications that are part of GNOME. Otherwise, it's likely you just want GNOME (or something similar) instead, simply because of the experience it has to offer. As for a different kind of experience, you are usually going to be looking to replace some of the default applications, such as the window manager, rather than the entire desktop environment. Yours faithfully, S.J.R. van Schaik.
×
×
  • Create New...