Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6889787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:12:01+00:00 2026-05-27T06:12:01+00:00

Momentarily I’m trying to write a raycaster engine with OpenCL and Java (LWJGL). However

  • 0

Momentarily I’m trying to write a raycaster engine with OpenCL and Java (LWJGL).

However on running the kernel, I can not printf, or write to a debug variable for that matter. I have the feeling the kernel is abruptly being cut off, also since times reported (outside opencl) are showing very fast results (60fps), faster than in the mandelbrot example!

I’m looking at gDEBugger but, I do not think it will support Java.

Any comments on my code-makeup are very much welcome as well, since I’m a beginner. Also comments on my raycast-mathmatics are also welcome.

#ifdef USE_TEXTURE
    #define OUTPUT_TYPE __write_only image2d_t
#else
    #define OUTPUT_TYPE global uint *
#endif

#define MAX_RAY_LENGTH 1024


bool isSolid(int x, int y, int z, global uchar *objectIsSolidStorage, int width, int height, int depth) {
    uint placex = x / 8;
    uint placey = y / 8;
    uint placez = z / 8;

    uint widthbychar = (width/8);
    uint heightbychar = (height/8);
    int calcbychar = placex + placey * widthbychar + placez * widthbychar * heightbychar;

    int leftover = x % 8;
    uchar solidchar = objectIsSolidStorage[calcbychar];

    if (x > width || y > height || z >> depth ||
        x < 0 || y < 0 || z < 0) return 1;

    if ((solidchar & ( 1 << leftover )) >> leftover) {
        return 1;
    }
    return 0;
}

int getColor(int x, int y, int z)
{
        return 0xFFFFFFFF;
}

kernel void raycast(
        const int width,
        const int height,
        const float positionX,
        const float positionY,
        const float positionZ,
        const float directionX,
        const float directionY,
        const float directionZ,
        OUTPUT_TYPE output,
        global uchar *objectIsSolidStorage,
        const int objectStorageWidth,
        const int objectStorageHeight,
        const int objectStorageDepth,
        global uint *objectColorStorage,
        global uint *smallObjectsMap,
        global uint *hangableObjectsMap,
        global uint *largeObjectsMap,
        const int objectMapWidth,
        const int objectMapHeight,
        const float frustrumAngleX,
        const float frustrumAngleY,
        global char debug
) {

    unsigned int rayx = get_global_id(0);
    unsigned int rayy = get_global_id(1);

    bool hit = false;
    int itr = 0;
    float x = positionX;
    float y = positionY;
    float z = positionZ;

    printf("work");
    int addX = (rayx - width / 2) * frustrumAngleX;
    int addY = (rayy - height / 2) * frustrumAngleY;
    int color = 0xFFAAFF;
    while(!hit) {
        x += addX;
        y += addY;
        z += itr;
        if (MAX_RAY_LENGTH < itr) {
            hit = true;
            color = 0xFFFFFFFF;
            break;
        } else if (isSolid(x,y,z,objectIsSolidStorage,objectStorageWidth,objectStorageHeight,objectStorageDepth)) {
            hit = true;
            color = 0xAAAAAAAA;
            break;
        }
        itr++;
    }

    #ifdef USE_TEXTURE
        float4 oc = (float4)(
            (c & 0xFF) >> 0,
            (c & 0xFF00) >> 8,
            (c & 0xFF0000) >> 16,
            255.0f
        );
        write_imagef(output, (int2)(rayx, rayy), color / 255.0f);
    #else
        output[rayy * width + rayx] = color;
    #endif
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:12:02+00:00Added an answer on May 27, 2026 at 6:12 am

    it’s should be applicable for your OpenCL+java development: attach to java process and debugging OpenCL kernels with easy

    http://suhorukov.blogspot.com/2011/12/opencl-kernel-debugging-for-java-host.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to create a div that we can control its content via ajax
I have a div (.header) contained within other divs. When my page loads, momentarily
I am not even sure this is a previous command or a non-finished command
A very strange thing is happening. I am running a script on a new
I have a pagination functionality, where the user can either enter page number OR
I'm not new to JavaScript, but I've never really had too much in-depth knowledge
In fact, this is the same question as this post: How can I make
I have an AJAX heavy website. There's hundreds of buttons that momentarily put up
I am watching a somewhat cruel behaviour momentarily: I have a ViewController for building
In trying to update my SDK to the latest, some things installed, but others*

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.